On this page
Kater CLI Build an analysis source
kater source write
Creates a file, or replaces a whole file, with your text.
Use it for a change that no other kater command makes, such as a hand-written query. Kater checks a SQL file before it saves it.
Examples
# Go to the ad_reporting workspace in your local copy of Kater contentcd connections/snowflake_prod_connection/workspaces/ad_reporting# Create the clicks_by_platform query from the text that followskater source write query_contracts/clicks_by_platform.sql --text-file - <<'SQL'---name: clicks_by_platformmodel_type: query---SELECT ad_reporting.platform, ad_reporting.sum__clicksFROM workspace.ad_reporting AS ad_reportingGROUP BY ad_reporting.platformSQL# Note the revision of the spend_by_platform query before you edit a copy of itbefore=$(shasum -a 256 query_contracts/spend_by_platform.sql | cut -d ' ' -f 1)# Save your edited copy, spend_by_platform_edit.sql, and stop if the query changed sincekater source write query_contracts/spend_by_platform.sql --text-file spend_by_platform_edit.sql --expected-revision "$before"Arguments
Options
It also takes the global options --json, --kater-root, --scope and --help.
What Kater checks before it saves
- A
.sqlfile is formatted and compiled. Kater declares each parameter that the SQL reads and the file does not declare. A file that does not compile is refused with the compiler’s diagnostics, and nothing is saved. - A file in a brainstorm copy of a workspace is saved even when it does not compile. The answer lists its errors.
- Any other text file is saved as you send it. A YAML file must parse.
connection.yamlis saved only when the whole file passes the checks ofkater admin connection update.