-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Summary
Snowflake COPY statements are misclassified as "Unknown" statement type, causing them to be rejected when sql_statement_permissions is configured with Copy: true and Unknown: false.
Expected Behavior
When executing a Snowflake COPY statement with Copy: true in permissions, the statement should be recognized as type "Copy" and allowed to execute.
Actual Behavior
The statement is classified as "Unknown" and rejected. Setting Unknown: true is required as a workaround.
Steps to Reproduce
-
Configure
tools_config.yamlwith:sql_statement_permissions: - Copy: true - Unknown: false
-
Execute a Snowflake COPY statement:
COPY INTO @MY_STAGE.EXPORTS/sales_export.csv.gz FROM ( SELECT * FROM MY_DATABASE.PUBLIC.ORDERS LIMIT 10 ) FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP) HEADER = TRUE OVERWRITE = TRUE MAX_FILE_SIZE = 52428800 SINGLE = TRUE;
-
Observe that the query is rejected
-
Change config to
Unknown: true— the query now executes (confirming misclassification)
Additional Context
The issue appears to be in mcp_server_snowflake/query_manager/tools.py where sqlglot.parse_one() is called without specifying dialect="snowflake". This causes the parser to fail on Snowflake-specific syntax.
Verification script:
import sqlglot
COPY_QUERY = """COPY INTO @MY_STAGE.EXPORTS/sales_export.csv.gz
FROM (SELECT * FROM MY_DATABASE.PUBLIC.ORDERS LIMIT 10)
FILE_FORMAT = (TYPE = CSV COMPRESSION = GZIP) HEADER = TRUE OVERWRITE = TRUE
MAX_FILE_SIZE = 52428800 SINGLE = TRUE;"""
# Without dialect - raises ParseError
try:
result = sqlglot.parse_one(COPY_QUERY)
except sqlglot.errors.ParseError:
print("Classified as: Unknown")
# With Snowflake dialect - parses correctly
result = sqlglot.parse_one(COPY_QUERY, dialect="snowflake")
print(f"Classified as: {type(result).__name__}") # Prints "Copy"