Targets
Snowflake
Load into Snowflake: the load_method, external stages, and files Snowflake reads itself.
A Snowflake connection needs load_method, which decides how data gets into Snowflake. It has no
default:
[connections.wh]kind = "snowflake"account = "myorg-myaccount"user = "SQLLOAD"auth = { method = "key_pair", private_key_file = "/etc/sqlload/key.p8" }role = "LOADER"warehouse = "LOAD_WH"database = "RAW"load_method.type = "external_stage"load_method.url = "s3://example-bucket/sqlload/"load_method.storage_integration = "LAKE_INT"type |
Data goes through | Setup |
|---|---|---|
external_stage |
An external stage on your S3 prefix. Files sources under url load directly from it. |
A storage integration, or an existing stage, and SQLLoad’s write access to the bucket. |
internal_user_stage |
The user stage @~. |
None. |
internal_table_stage |
The table stage @%table. |
None. |
internal_named_stage |
A named internal stage: name = "DB.SCHEMA.STAGE". |
The stage. |
streaming |
Snowpipe Streaming into a transient staging table. | None. |
insert |
Batched multi-row INSERT into a transient staging table. Very slow; plan warns. |
None. |
A method the role can’t use fails at plan. SQLLoad never falls back to another one.
Signing in
Section titled “Signing in”auth |
Use it for | Notes |
|---|---|---|
{ method = "key_pair", private_key_file = "..." } |
Unattended runs: schedulers, CI, servers. | The only method Snowpipe insertFiles accepts. |
{ method = "pat", token = "${ENV:SNOWFLAKE_TOKEN}" } |
Unattended runs. | A programmatic access token. |
{ method = "oauth_authorization_code" } |
A person at a terminal. | Signs in in the browser. |
oauth_authorization_code uses Snowflake’s built-in SNOWFLAKE$LOCAL_APPLICATION integration, so
nobody has to create one. The first command that connects opens a sign-in address in your browser,
where you sign in as the connection’s user with password and MFA or single sign-on; SQLLoad never
sees your password. Where no browser can open, as over SSH, paste back the address the browser
ended on (a page on 127.0.0.1 that fails to load).
Tokens are cached in ~/.cache/sqlload/snowflake-tokens.json (under XDG_CACHE_HOME when set,
%LOCALAPPDATA% on Windows; readable only by you on Linux and macOS) and refreshed, so later runs
sign in again only once the refresh token expires or is revoked. Deleting the file forgets every
connection’s sign-in on this machine but doesn’t revoke the tokens. sqlload debug shows the method and the cache file. With no
terminal, or with plan --json or contract ... --json, a run that needs to sign in fails at once;
sign in once from a terminal, or use key_pair or pat.
A security integration of your own can stand in for the built-in one. Its redirect URI must be the
one it registered, on http://127.0.0.1, and needs OAUTH_ALLOW_NON_TLS_REDIRECT_URI = TRUE:
auth.method = "oauth_authorization_code"auth.client_id = "..."auth.client_secret = "${ENV:OAUTH_SECRET}"auth.redirect_uri = "http://127.0.0.1:8765/"External stage
Section titled “External stage”| Key | Meaning |
|---|---|
url |
The stage’s location, s3://bucket/prefix/. Use the bucket and folder the stage reads, not a subfolder. |
storage_integration |
SQLLoad creates _SQLLOAD_STAGE in each loader schema with this integration, at apply. |
name |
Or an existing stage on url, as DATABASE.SCHEMA.STAGE. Give exactly one of storage_integration and name. |
region |
The bucket’s region, for SQLLoad’s own writes. |
keep_staged_files |
Keep staged files after their batch commits, and leave this stage out of the cleanup. Default false. |
SQLLoad writes the Parquet it stages with your AWS credentials, found as for an
s3 connection. Staged files are deleted once their batch commits; the
next load removes what failed runs left, after a day.
Files into Snowflake
Section titled “Files into Snowflake”Files of a files source (Parquet, JSON, NDJSON or CSV) under the external stage’s url load
directly: Snowflake reads them itself, with the same values as SQLLoad’s own reader.
- A column the direct
COPYcan’t load exactly, such asFloat16, a decimal over 38 digits or a nested type, failsplan, or the load for a later batch, naming the column. - Files no external stage covers fail
plan, unless the source setscopy_to_internal_stage = true: SQLLoad then uploads each file unchanged to@~, which is much slower, andplanwarns. - A
hash-masked column reaches Snowflake in plain text, in a temporary table that ends with the session, and is hashed there.hmac-masked files go through SQLLoad, since the key must never appear in SQL;planwarns that it’s much slower. - CSV
encodingandskip_rowsbecomeENCODINGandSKIP_HEADER. An encoding Snowflake doesn’t support failsplan. See CSV encodings.
Snowflake sources into Snowflake
Section titled “Snowflake sources into Snowflake”A Snowflake source loads into this target without its rows passing through SQLLoad. See Snowflake loads the rows itself.