Skip to content

Drop unnecessary EXEC() wrapper from fabric__create_table_as#378

Open
sdebruyn wants to merge 1 commit into
microsoft:mainfrom
sdebruyn:fix/05-ctas-exec-wrapper
Open

Drop unnecessary EXEC() wrapper from fabric__create_table_as#378
sdebruyn wants to merge 1 commit into
microsoft:mainfrom
sdebruyn:fix/05-ctas-exec-wrapper

Conversation

@sdebruyn
Copy link
Copy Markdown
Collaborator

@sdebruyn sdebruyn commented May 19, 2026

Why this change is needed

Filed as #377.

fabric__create_table_as wraps the CREATE TABLE AS SELECT in EXEC('...') and manually escapes single quotes in the query label via .replace("'", "''"). Fabric Warehouse supports CTAS as a first-class statement, so the wrapper is unnecessary, and the manual escape is fragile — it double-escapes pre-escaped apostrophes if a user-configured query_tag ever contains ''. See #377 for details.

How

Drop the EXEC() wrapper in the non-contract branch of fabric__create_table_as and emit a plain CTAS. The query_label_option intermediate (which only existed to call .replace("'", "''") on the label) is removed; the macro now uses query_label directly. The contract-enforced branch a few lines above already emits its INSERT INTO ... SELECT without an EXEC() wrapper, so this only brings the non-contract branch into line.

Test

I'm a non-Microsoft contributor and cannot run the CI against the Microsoft Fabric tenant. Happy to add a local test-run screenshot if a maintainer wants to engage with the change.

Closes #377

Fabric Warehouse supports CREATE TABLE AS SELECT as a first-class
statement. Wrapping it in EXEC('...') is unnecessary and forces manual
single-quote escaping of the query label via replace("'", "''"),
which is brittle. Emitting plain CTAS removes the wrapper and the
escape step.
@sdebruyn sdebruyn marked this pull request as ready for review May 19, 2026 08:18
@sdebruyn sdebruyn marked this pull request as draft May 19, 2026 08:26
@sdebruyn sdebruyn marked this pull request as ready for review May 19, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fabric__create_table_as wraps CTAS in EXEC('...') and manually escapes the query label

1 participant