You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2aa6af6
Browse filesBrowse the repository at this point in the historyBrowse files
fix(snowflake): unload a table, not an inline query
The COPY INTO grammar places the source immediately before its copy options, so
an inlined query sits one parenthesis from being able to rewrite them. Guarding
that means matching Snowflake's tokenizer exactly, and three successive versions
of the guard were each defeated: // line comments, $$ dollar quoting, and a bare
carriage return, which the scanner did not treat as a line terminator but
Snowflake does. Each fix was a guess at a lexer the public docs do not specify.
Removes the inline-query source instead of guessing a fourth time. A table name
goes through qualifiedIdentifier, which is provably safe. Exporting a query
result now means materializing it first — a view, or CREATE TABLE AS SELECT via
Execute SQL — which the tool description, the block skill and the docs all say.
Also from the final audit:
- optionalBoolean accepts the string forms a direct tool call delivers, matching
the other boolean readers on this block, and its TSDoc no longer states the
serializer rule backwards
- the five JSON editors declare language: 'json', so invalid JSON is caught
inline instead of at execution
- bound the RESULT_SCAN read in SQL, not only by rows_per_resultset
- pin every migration target to a live subblock id, for all blocks
Copy file name to clipboardExpand all lines: apps/docs/content/docs/en/integrations/snowflake-service-account.mdx
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,14 @@ With a credential selected, these fields become pickers backed by metadata-only
96
96
97
97
Each picker runs as the token's user under its **default** role — not the execution role set on the block — so an empty list is usually a privilege gap rather than an empty account. Switch any field to advanced mode to type a name directly or reference an upstream block's output instead.
98
98
99
+
<Callouttype="info">
100
+
**Unload Data exports a table, not a query.** The COPY INTO grammar places the
101
+
source immediately before its options, so an inline query would sit one
102
+
parenthesis away from being able to rewrite them. To export a query result,
103
+
materialize it first — a view, or `CREATE TABLE AS SELECT` via Execute SQL —
104
+
then unload that object.
105
+
</Callout>
106
+
99
107
## Rotating and Revoking
100
108
101
109
A token's expiry is fixed at creation. To rotate, generate a new token on the same user and update the credential in Sim — the old one stays valid until you remove it. `ALTER USER ... REMOVE PROGRAMMATIC ACCESS TOKEN <name>` revokes immediately and cannot be undone.
@@ -386,8 +386,7 @@ Export a table or query result to files in a Snowflake stage with COPY INTO.
386
386
|`database`| string | Yes | Database name |
387
387
|`schema`| string | Yes | Schema name |
388
388
|`stagePath`| string | Yes | Destination stage reference, for example @EXPORTS/daily|
389
-
|`table`| string | No | Source table to unload; provide either this or a statement, not both |
390
-
|`statement`| string | No | Source SELECT statement to unload; provide either this or a table, not both |
389
+
|`table`| string | Yes | Source table to unload. To export a query result, materialize it first as a view or with CREATE TABLE AS SELECT, then unload that |
391
390
|`fileFormat`| string | No | Named file format applied to the unloaded files |
392
391
|`header`| boolean | No | Whether to write column headings into the unloaded files; supported for CSV and Parquet only |
393
392
|`overwrite`| boolean | No | Whether to replace existing files with matching names in the stage |
'Generate one Snowflake SQL statement for the described request. For Execute SQL, use positional ? placeholders for any values that will be bound; for Unload Data, write a complete SELECT with literal values and no placeholders. Return ONLY the SQL statement - no explanations, no extra text.',
311
+
'Generate one Snowflake SQL statement for the described request. Use positional ? placeholders for any values that will be bound. Return ONLY the SQL statement - no explanations, no extra text.',
description: 'Unload a table or query result to files in a Snowflake stage.',
1212
1226
content:
1213
-
'# Export Snowflake Results\n\n## Steps\n1. Confirm the destination stage path and whether existing files may be overwritten.\n2. Choose exactly one source: a table, or a SELECT statement.\n3. Pick a named file format, and decide on column headings and whether one file or several.\n4. Run the unload and review the reported file count and row totals.\n\n## Output\nReturn the stage path, files written, and rows unloaded.',
1227
+
'# Export Snowflake Results\n\n## Steps\n1. Confirm the destination table and the stage path, and whether existing files may be overwritten.\n2. To export a query result rather than a whole table, materialize it first — create a view or use CREATE TABLE AS SELECT via Execute SQL — then unload that object.\n3. Pick a named file format, and decide on column headings and whether one file or several.\n4. Run the unload and review the reported file count and row totals.\n\n## Output\nReturn the stage path, files written, and rows unloaded.',
0 commit comments