fix: raise ProgrammingError for CREATE MACRO instead of creating it as a side effect#350
Open
mdz wants to merge 1 commit into
Open
fix: raise ProgrammingError for CREATE MACRO instead of creating it as a side effect#350mdz wants to merge 1 commit into
mdz wants to merge 1 commit into
Conversation
…ting it Snowflake doesn't support CREATE MACRO, so fakesnow shouldn't either. Previously the DuckDB-only DDL would slip through and actually create the macro as a side effect. Now we detect it early and raise a clean ProgrammingError before DuckDB executes anything. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
CREATE MACROis DuckDB-only DDL that Snowflake doesn't support. Previously fakesnow would silently pass it through to DuckDB, actually creating the macro as a side effect (and in server mode, also raising aProgrammingErrorwhen result post-processing tried toDESCRIBEthe raw DDL string).Per the reviewer's position in #344, the right behavior is for
CREATE MACROto fail cleanly rather than succeeding with a DuckDB-only side effect.How
Added an early guard in
FakeSnowflakeCursor._execute(fakesnow/cursor.py) that detectsCREATE ... MACRO(sqlglot parses this as an opaqueexp.Command) and raises aProgrammingErrorwitherrno=2 / sqlstate=0A000(feature not supported) before DuckDB ever executes it.Test plan
CREATE OR REPLACE MACROraisesProgrammingError: SQL compilation error: Unsupported feature 'CREATE MACRO'.uv run pytest tests/test_cursor.py)🤖 Generated with Claude Code