Snowflake SQL
Igloo’s SQL is DuckDB’s (see SQL and clients). A session can choose Snowflake’s dialect instead: Igloo then translates each statement into DuckDB’s dialect before it checks and runs it, so queries, dashboards and dbt models written for Snowflake run without being rewritten.
SET sql_dialect = 'snowflake';
SELECT IFF(amount > 100, 'large', 'small') AS size, DATEADD(month, 1, order_date) AS next_month, payload:customer.email::string AS emailFROM ordersQUALIFY ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC) = 1;The translation covers the functions, syntax and types that analytics SQL uses most. What it cannot translate faithfully it refuses with an error that names the construct; where DuckDB cannot reproduce Snowflake’s behaviour exactly, the translation is the closest one and the difference is listed under known differences.
Turning it on
Section titled “Turning it on”The dialect is a setting, sql_dialect, with two values: duckdb, the
default, and snowflake. Any user may change it for their own sessions; it
changes how their SQL is read, never what they may do.
| Where | How |
|---|---|
| A session | SET sql_, or ALTER SESSION SET sql_; SET sql_ turns it off, RESET sql_ returns to the connection’s or the user’s default, SHOW sql_ says which applies |
| A connection | The startup option -c sql_: PGOPTIONS=‘-c sql_ for psql and libpq, options=-c%20sql_ in a JDBC URL, options=‘-c sql_ for psycopg. A startup parameter named sql_ works too. An unknown value fails the login with SQLSTATE 22023 |
| A user or role | ALTER USER ana SET sql_ or ALTER ROLE analysts SET sql_ (admins), a role setting like query_: the user’s own, otherwise their custom roles’ (the first role by name), otherwise their built-in role’s |
A session’s own SET wins over its connection’s option, which wins over
the user’s or role’s setting.
- Arrow Flight SQL sessions take
SET sql_dialectand the user’s or role’s setting. The web console takes the setting, and a worksheet can start withSET sql_dialect = 'snowflake';. The console’s own pages and Flight SQL’s catalog calls are always read as DuckDB’s. - Drivers’ and BI tools’ catalog queries, which name
pg_catalog,pg_functions and tables or use PostgreSQL’sE'...'strings, pass untranslated whatever the dialect. Other statements a tool writes for PostgreSQL are read as Snowflake’s in a Snowflake session; give a role the setting only when its clients send Snowflake SQL. - Views, tasks, pipes, alerts and materialized views created in
Snowflake’s dialect store their translation, which is DuckDB SQL: they run
the same in every session, and
DESCRIBEandduckdb_views()show the translation. Translations call macros namedsf_...(such assf_add_days) that every session has. - Scripts sent as one query are split as Snowflake splits them, so a
;inside a'it\'s; fine'string or after a//comment does not end a statement. A statement that changessql_dialectapplies to the ones after it.
What Igloo checks
Section titled “What Igloo checks”Translation is not a security boundary. Igloo checks the translated
statement (the user’s role, grants, masking and row access policies, file
access, workload limits) exactly as it checks a statement sent in DuckDB’s
dialect, so a statement in Snowflake’s dialect reaches only what its
DuckDB translation would. IDENTIFIER('name') and IDENTIFIER($variable)
are resolved before the checks. The query history
records the translated statement.
Errors use SQLSTATE codes:
| Code | Meaning |
|---|---|
0A000 |
The construct is valid Snowflake SQL that Igloo does not translate. The message names it, and the hint says what to write instead where there is an alternative |
42601 |
The statement is not valid SQL as Snowflake reads it, or a function has the wrong number of arguments |
22023 |
A value is not valid, such as an unknown format element or a session variable that is not set |
Statements that Igloo accepts but that change nothing, or translates with a
caveat, send a notice (SQLSTATE 01000), which psql and most drivers show:
CLUSTER BY of expressions, USE WAREHOUSE, HASH (whose values are not
Snowflake’s) and the like. The web console and Flight SQL do not show
notices.
- Unquoted identifiers are case-insensitive, as in Snowflake.
- Result columns are named as Snowflake names them: an unquoted alias in
upper case (
AS totalgivesTOTAL), a quoted one as written, an expression after its text in upper case (COUNT(*),DATEADD(DAY, 1, D)), and a table’s column after its name in the catalog, in upper case unless it has upper-case letters or the statement quotes it. CREATE TABLE ... ASand views keep their columns’ names as written (AS totalstorestotal); reading them in Snowflake’s dialect showsTOTAL.- A table’s alias, a CTE’s name, the names in their column lists and a
select item’s alias may be words that DuckDB keeps as keywords, as in
Snowflake:
CROSS JOIN totals at,at.total,SELECT 1 year. Igloo quotes them for DuckDB as its keyword list (duckdb_keywords()) says, a table’s in upper case and a select item’s as written, so they name what the word does.SEMI,ANTIandPOSITIONALafter a table are its alias, as in Snowflake, not the start of DuckDB’s joins of those kinds;AT (...)andASOF JOINare the clauses. IDENTIFIER('db.schema.table'),IDENTIFIER($name),TABLE('name')andTABLE($name)name an object.- A three-part name’s database is the catalog’s name,
lakeunlessIGLOO_CATALOG_NAMEsets another: give the catalog the name of the Snowflake database whose SQL you run, or use two-part names.
What is translated
Section titled “What is translated”Literals and lexical rules
Section titled “Literals and lexical rules”- Strings with Snowflake’s backslash escapes (
'it\'s','\n','\u00e9'),$$...$$strings,//comments,X'...'binary literals. - Session variables:
SET x = 10(orSET x = (SELECT ...)),$x,UNSET x,SHOW VARIABLES.SETof one of Igloo’s or PostgreSQL’s settings (such assearch_pathorstatement_timeout) sets the setting. - Typed literals such as
TIMESTAMP_LTZ '2024-01-01 10:00',{'a': 1}object constants and[1, 2]array constants.
Semi-structured data
Section titled “Semi-structured data”VARIANT, OBJECT and ARRAY values are JSON. Columns of them are
Iceberg’s own types where Iceberg has one, so that other engines read them
and Igloo reads them without parsing text (see columns
below): an ARRAY column is a list of strings (VARCHAR[]), an OBJECT
column a map of strings (MAP(VARCHAR, VARCHAR)), and a VARIANT column
the JSON text of its values (VARCHAR). Everything below reads all three,
JSON and JSON text alike.
- Paths:
v:a.b[0],v['a'],v:"Quoted Key",x::VARIANT[0], with casts (v:a::string,v:n::number(10,2)). A path compared with a string, used in a string function or cast to a string reads the value as a string; one compared with a number or used in arithmetic reads it as a number. PARSE_JSON,TRY_PARSE_JSON,CHECK_JSON,TO_JSON,TO_VARIANT,TO_OBJECT,TO_ARRAY,GET,GET_PATH,TYPEOF,IS_*andAS_*,STRIP_NULL_VALUE.OBJECT_CONSTRUCT,OBJECT_CONSTRUCT_KEEP_NULL,OBJECT_INSERT,OBJECT_KEYS,OBJECT_AGG.ARRAY_CONSTRUCT,ARRAY_CONSTRUCT_COMPACT,ARRAY_AGG(withWITHIN GROUPandDISTINCT),ARRAY_UNIQUE_AGG,ARRAY_SIZE,ARRAY_CONTAINS,ARRAY_POSITION,ARRAY_TO_STRING,ARRAY_SLICE,ARRAY_APPEND,ARRAY_PREPEND,ARRAY_CAT,ARRAY_COMPACT,ARRAY_DISTINCT,ARRAY_INTERSECTION,ARRAYS_OVERLAP,ARRAY_FLATTEN,ARRAY_GENERATE_RANGE,SPLIT,STRTOK_TO_ARRAY.[LATERAL] FLATTEN(input => ..., path => ..., outer => ..., recursive => ..., mode => ...)andTABLE(FLATTEN(...)), with the columnsSEQ,KEY,PATH,INDEX,VALUEandTHIS. It joins after a comma or withJOIN,INNER JOINorLEFT [OUTER] JOIN, withoutONas Snowflake writes it, andSPLIT_TO_TABLEandGENERATORjoin so too; aLEFT JOINkeeps a row for whichFLATTENgives no rows, withNULLs, asOUTER => TRUEdoes.FLATTENof anARRAYorOBJECTcolumn unnests its list or map directly, andFLATTENof an array constant ([OBJECT_CONSTRUCT(...), ...],ARRAY_CONSTRUCT(...)) unnests its elements without building the array: over 15 million elements, 0.3 s instead of 1 s from JSON text. AWHEREin the select of aFLATTENthat is its lastFROMitem becomes theONof that join when every join is an inner one, and when a secondFLATTENreads the first’s elements, theARRAYandOBJECTcolumns the first builds them from are turned into JSON before the join, unless the select reads them elsewhere: in both cases DuckDB would otherwise hold each row’s lists or maps in a dependent join, at several times the cost. AFLATTENof a column whose select reads only itsVALUEtakes one of two forms. In one, the lateral subquery computes the column’s list, which DuckDB 1.5.6 plans as a dependent join: it copies the rows the joins before theFLATTENkeep and joins them back on their lists, the faster form when those joins keep few rows. In the other, the column’s table computes the list in a select list of its own, for all its rows, before the joins, and the lateral subquery unnests it where it reads it, the faster form when the joins keep most rows: over tens of millions of rows aFLATTEN, one dashboard query took 0.9 s the first way and 3.5 s the second, another 88 s and 56 s. Igloo picks for each statement shape: the first statement takes the form DuckDB’s estimates point to (the second when a quarter or more of the tables’ rows reach the dependent joins), the next the other form, and from then on the shape takes the form whose latest runs took the less of the replica at best: the more of their CPU time over its cores and of their memory over its memory limit for as long as they ran, so that a form that takes less CPU but holds the memory other statements wait for is not taken; a statement that runs on workers, by its time on each of them. Either way, conditions that read nothing of theFLATTENbut itsVALUE(WHERE f.value <> 'unknown') filter the list it unnests (list_filter).FLATTENof an array constant ofOBJECT_CONSTRUCTandOBJECT_CONSTRUCT_KEEP_NULLcalls with string literals for keys, whoseVALUEits select reads only by a key (f.value:k,f.value['k'],GET_PATH(f.value, 'k'),GET(f.value, 'k'), with any cast or path after; CTEs that reuse the alias count apart), makes its objects DuckDB structs rather than JSON: a string reads as itself, and a laterFLATTEN(INPUT => f.value:items)unnests anARRAYcolumn’s list from the struct without writing it as JSON text, parsing it back or a dependent join (over 29 million elements of 2 million rows’ five lists, 0.4 s instead of 1.6 s). When the objects are built from oneFROMitem’s columns and the select reads only their keys, that item’s select list builds them, for each of its rows joined to the range of their indexes (CROSS JOIN range(n)), and a second select list around it unnests a secondFLATTEN‘s key, with no lateral join at all; DuckDB estimates that join at the objects’ number, where it takes an unnest for as many rows as it reads, so that a join of the objects with a smaller table builds its hash table on that table. DuckDB makes a lateralFLATTENof string columns a dependent join, and one of structs too once it pushes a filter down onto it, such as a BI tool’s outerWHEREon a key the report groups by. When every read of the secondFLATTEN’s elements casts them to a type that is not semi-structured, asCAST(v.value AS TEXT)does, it unnests their text rather than JSON of each, and a key that every read casts so is a field of its text alone. Where the objects are not built so, aWHEREthere stays out of the joins: its conditions on the tables go into theONof the firstFLATTEN‘s join, which DuckDB pushes down to the tables, those on the objects’ keys filter the objects, and those on a secondFLATTEN‘s elements filter the elements when the statement reads nothing of thatFLATTENbut itsVALUE. Any other read ofVALUE, a star at that level, a subquery that names the alias, or a secondFLATTENof it withOUTER,PATHor a longer path keeps the objects JSON; so do, when a secondFLATTENreads them, aWHEREthat cannot stay out of the joins (a condition on another of theFLATTENs’ columns, a subquery or a select item’s alias, or a table after the firstFLATTEN), anONafter theFLATTENand aHAVINGon the groups’ keys: DuckDB then plans a dependent join, which holds structs of lists at a higher cost than JSON text.
Semi-structured columns
Section titled “Semi-structured columns”Iceberg tables of the format versions Igloo’s catalog allows (1 and 2) have
no semi-structured type; Iceberg’s variant needs version 3, which
erasure requests cannot rewrite yet. Igloo stores Snowflake’s
types as follows, in CREATE TABLE, ALTER TABLE ... ADD COLUMN and
tables copied from Snowflake connections:
| Snowflake | Iceberg | DuckDB | What it holds |
|---|---|---|---|
ARRAY |
list<string> |
VARCHAR[] |
Each element as Snowflake’s TO_ writes it: a string as itself, any other value as its JSON text (1, true, {"k":"v"}); JSON null as NULL |
OBJECT |
map<string, |
MAP(VARCHAR, |
Each value likewise |
VARIANT |
string |
VARCHAR |
The value’s JSON text |
ARRAY(type), OBJECT(name type,, MAP(type, |
list, struct, map of the types |
type[], STRUCT(…, MAP(… |
The values as typed |
This is how Snowflake itself converts semi-structured values to
ARRAY(VARCHAR) and MAP(VARCHAR, VARCHAR), so INSERT INTO t SELECT ARRAY_CONSTRUCT(...) and PARSE_JSON(...) store them that way. Reading
them back, an element or value that is the JSON text of an object or an
array reads as that object or array, so paths into an ARRAY of objects
(f.value:name) work; one that is a number or a boolean reads as a string,
which compares, casts and sums as the number (see known
differences). A VARIANT column, or JSON text in any
VARCHAR column, reads as the JSON it holds. A function that builds a
value of such a column (ARRAY_AGG, OBJECT_AGG, ARRAY_CONSTRUCT,
OBJECT_CONSTRUCT, TO_JSON, ::VARIANT and the others) takes its text
as an element of an ARRAY column reads: the JSON text of an object or an
array as that object or array, any other text as a string. So
ARRAY_AGG(location) of a VARIANT column copied from Snowflake gives its
objects, [{"zip_code":"55603"}, ...], as in Snowflake. Text an expression
computes, such as x::STRING, stays a string.
CREATE TABLE ... AS SELECT makes ARRAY and OBJECT columns of what is
known to be one: ARRAY_AGG, ARRAY_CONSTRUCT, [...], SPLIT,
::ARRAY and the other functions that return an ARRAY, and
OBJECT_CONSTRUCT, OBJECT_AGG, {...} and ::OBJECT, as columns of the
query’s SELECT (not of a UNION’s). Any other semi-structured value,
PARSE_JSON(...) among them, makes a VARIANT column, the JSON text of its
values; cast it to ARRAY or OBJECT for a list or a map.
A statement in Snowflake’s dialect sends each ARRAY and OBJECT value to
the client as one value of PostgreSQL’s json type, the JSON text of the
whole array or object, whether it computes the value or selects a column
that holds it; a VARIANT value it computes (PARSE_JSON(s), v:a) is
json too, and a VARIANT column of an Iceberg table, which holds its
values’ JSON text, is sent as that text (text). An ARRAY or OBJECT
column goes out as TO_JSON reads it, its elements’ objects and arrays as
objects and arrays: after CREATE TABLE t AS SELECT ARRAY_AGG(OBJECT_CONSTRUCT('zip_code', z)) AS zips ..., SELECT zips FROM t sends [{"zip_code":"55603"}], as the ARRAY_AGG itself does. In
DuckDB’s dialect the same column arrives as JSON of its strings,
["{\"zip_code\":\"55603\"}"]. Structured ARRAY(type), OBJECT(...) and
MAP(...) columns are json too, their values as typed, except that
ARRAY(VARCHAR) and MAP(VARCHAR, VARCHAR), the same DuckDB types as
ARRAY and OBJECT columns, go out as those do.
Functions
Section titled “Functions”| Kind | Functions |
|---|---|
| Conditional | IFF, NVL, IFNULL, NVL2, ZEROIFNULL, NULLIFZERO, DECODE, EQUAL_, DIV0, DIV0NULL, GREATEST, LEAST (NULL if any argument is), GREATEST_, LEAST_, BOOLAND, BOOLOR, BOOLXOR, BOOLNOT |
| Dates and times | DATEADD, TIMEADD, TIMESTAMPADD, DATEDIFF, TIMEDIFF, TIMESTAMPDIFF, DATE_, TRUNC of a date, DATE_ and EXTRACT (including DAYOFWEEK, DAYOFWEEKISO, WEEKISO, YEAROFWEEK, EPOCH_ and the other parts), LAST_, NEXT_, PREVIOUS_, DAYNAME, MONTHNAME, ADD_, MONTHS_, TIME_, DATE_, TIME_, TIMESTAMP_, CONVERT_, SYSDATE, CURRENT_, CURRENT_ |
| Conversion | TO_, TO_, TO_, , , TO_, TO_, TO_, TO_, TO_, TO_, TO_, TO_, TO_, their TRY_ forms, CAST and :: to Snowflake’s types; date, time and number formats such as ‘YYYY-MM-DD HH24:MI:SS., ‘MON DD, and ‘999,; epoch seconds and milliseconds |
| Strings | LEN, LENGTH, CHARINDEX, POSITION, CONTAINS, STARTSWITH, ENDSWITH, LEFT, RIGHT, SUBSTR (position 0 as 1), SPLIT_ (part 0 as 1), STRTOK, CONCAT, CONCAT_, LPAD, RPAD, REPLACE, INITCAP (Snowflake’s delimiters), SPACE, CHR, EDITDISTANCE, JAROWINKLER_, ILIKE, LIKE ANY/ALL, ILIKE ANY/ALL, RLIKE, REGEXP_, REGEXP_, REGEXP_, REGEXP_, REGEXP_, REGEXP_ (with Snowflake’s c, i, m, e and s parameters), SEARCH |
| Binary and hashes | MD5, MD5_, SHA1, SHA1_, SHA2 (256 bits), HASH (see below), HEX_, HEX_, HEX_, BASE64_, BASE64_, BASE64_, UUID_ |
| Numbers | SQUARE, TRUNC, ROUND, CEIL and FLOOR with a scale, DIV0, WIDTH_, RANDOM, UNIFORM, NORMAL, BITAND, BITOR, BITXOR, BITNOT, BITSHIFTLEFT, BITSHIFTRIGHT, GETBIT |
| Aggregates | LISTAGG (with WITHIN GROUP and DISTINCT), COUNT(DISTINCT a,, MEDIAN, MODE, APPROX_ and HLL (of one or more values), HLL_, HLL_, HLL_, APPROX_, APPROX_, BOOLAND_, BOOLOR_, BITAND_, BITOR_, BITXOR_, SKEW, VARIANCE_, VARIANCE_ |
| Windows | RATIO_, CONDITIONAL_, IGNORE NULLS after LAG, LEAD, FIRST_, LAST_ and NTH_ |
| Vectors | VECTOR_, VECTOR_, VECTOR_, VECTOR_, in double precision; vectors of different dimensions are an error |
| AI (AI functions) | AI_, AI_, AI_, AI_, AI_, AI_, AI_, AI_, AI_, AI_, AI_, AI_, PROMPT, AI_, AI_ (Databricks’ ai_), and SNOWFLAKE.‘s COMPLETE, CLASSIFY_, SENTIMENT, EXTRACT_, SUMMARIZE, TRANSLATE, EMBED_, EMBED_ and COUNT_, with your own providers’ keys through an AI integration |
| Generators | SEQ1, SEQ2, SEQ4, SEQ8 with TABLE(GENERATOR(ROWCOUNT => n)), TABLE(SPLIT_ |
| Context | CURRENT_, CURRENT_, CURRENT_, CURRENT_, CURRENT_; CURRENT_, CURRENT_, CURRENT_, CURRENT_ and similar return NULL |
Functions not listed whose name and meaning DuckDB shares (ABS, UPPER,
COALESCE, SUM, ROW_NUMBER and most others) pass as written.
TO_VARCHAR, TO_CHAR and ::VARCHAR without a format write values in
Snowflake’s default output formats, so text compared or stored is the same
in both:
| Type | Text |
|---|---|
FLOAT |
Up to 12 significant digits, without trailing zeros: 9244, 999., 0., in scientific notation from 1e+12 and below 0.; NaN, inf, -inf |
NUMBER |
With its scale: 1. |
TIMESTAMP_ |
YYYY-MM-DD HH24:MI:SS.: 2026-10-07 15:58:37. |
TIMESTAMP_, TIMESTAMP_ |
YYYY-MM-DD HH24:MI:SS., in the session’s time zone: 2026-10-07 08:58:37. |
TIME, DATE |
HH24:MI:SS, YYYY-MM-DD |
BINARY |
Hex: 0A0B |
A format’s TZH and TZM write the offset as Snowflake does (TZH:TZM is
+05:30, TZHTZM is +0530).
Implicit conversions
Section titled “Implicit conversions”Snowflake converts a value where DuckDB asks for a cast:
- A string function (
UPPER,TRIM,LENGTH,SUBSTR,REPLACE,CONTAINS,SPLIT_PARTand the others) andLIKEread any value as text, written asTO_VARCHARwrites it:TRIM(5)is'5',LENGTH('2024-01-01 10:00'::timestamp)is 23. - Text compared with a date, a time, a timestamp or a number, with
=,<and the like orBETWEEN, is cast to its type:'10' > 9is true, where'10' > '9'is false.
Which conversion a statement needs depends on its columns’ types, which
the translation does not know. So Igloo translates a statement without
them, and only when DuckDB cannot bind it for want of a cast does it
translate it again with Snowflake’s conversions and run that; a
statement that binds as written is never changed. The query history
records the statement once, as it ran, and
igloo_snowflake_implicit_conversions_total counts these statements. If
the conversions do not help either, the statement fails with DuckDB’s
error for it as first translated.
The conversions apply to operands that stand alone: a column, a call, a
semi-structured path or a parenthesized expression. In a || b < t the
comparison reads a || b, which Igloo does not convert; write
(a || b) < t or cast it.
Syntax
Section titled “Syntax”QUALIFY,MINUS(asEXCEPT),SELECT TOP n,FROM VALUES (...)with columnsCOLUMN1,COLUMN2…,SAMPLEandTABLESAMPLE(BERNOULLI,ROW,SYSTEM,BLOCK,n ROWS,SEED/REPEATABLE),PIVOTwith a list of values andUNPIVOT, named as Snowflake names their columns,* EXCLUDE,* RENAME,* REPLACE,* ILIKE.ASOF JOIN ... MATCH_CONDITION (...) [ON ...], which keeps the left rows without a match, as Snowflake does.DIRECTEDjoins.WITHwhose CTE refers to itself, withoutRECURSIVE.ORDER BYputs NULLs last ascending and first descending, as Snowflake does, in queries, windows andWITHIN GROUP.- In an
ORDER BYexpression a select list’s alias comes before a column of the same name, as in Snowflake:SELECT COALESCE(a.k, b.k) AS k ... ORDER BY CASE k WHEN ...sorts by the alias, where DuckDB would readkas a column (and find it in both tables). Not forSELECT DISTINCTor a set operation. - Time travel with
AT (TIMESTAMP => ...)andAT (OFFSET => -seconds), the table’s alias written after it as Snowflake does.
| Snowflake | Igloo |
|---|---|
NUMBER, DECIMAL, NUMERIC (default (38,) |
DECIMAL(p, |
INT, INTEGER, BIGINT, SMALLINT, TINYINT, BYTEINT |
BIGINT |
FLOAT, FLOAT4, FLOAT8, DOUBLE, DOUBLE PRECISION, REAL |
DOUBLE |
VARCHAR(n), STRING, TEXT, CHAR(n) |
VARCHAR |
BINARY, VARBINARY |
BLOB |
DATE, TIME |
DATE, TIME |
TIMESTAMP, TIMESTAMP_, DATETIME |
TIMESTAMP |
TIMESTAMP_, TIMESTAMP_ |
TIMESTAMPTZ |
VARIANT, OBJECT, ARRAY |
JSON; columns of them as above |
ARRAY(type), OBJECT(name type,, MAP(type, |
type[], STRUCT(name type,, MAP(type, |
GEOGRAPHY, GEOMETRY |
GEOMETRY |
VECTOR(FLOAT,, VECTOR(INT, (n up to 4096) |
FLOAT[n], INTEGER[n]; a column of an Iceberg table is a list, FLOAT[] or INTEGER[] |
DuckDB-Iceberg has no fixed-size arrays, so an Iceberg table’s VECTOR
column, and its column of any of DuckDB’s fixed-size arrays (FLOAT[3]),
holds a list of the same type, which other engines read as Iceberg’s
list<float>: the table does not keep the dimension, and a value of
another dimension can be stored. A cast to VECTOR(FLOAT, n) checks it,
and the vector functions refuse vectors of different dimensions.
Statements
Section titled “Statements”CREATE [OR REPLACE] [TRANSIENT | TEMPORARY | VOLATILE] TABLE, with Snowflake’s types;DATA_RETENTION_TIME_IN_DAYSand similar options are accepted and ignored with a notice,COPY GRANTSsilently (Igloo keeps a replaced table’s grants as Snowflake’sCOPY GRANTSwould).COMMENT = '...'is ignored with a notice: useCOMMENT ON.- Clustering keys:
CLUSTER BY (a, b)onCREATE TABLE(once the table is created) andALTER TABLE ... CLUSTER BY (a, b)set the table’s clustering key, andALTER TABLE ... DROP CLUSTERING KEYdrops it; table maintenance then clusters the table’s files, as Snowflake’s automatic clustering does. Keys must be columns:CLUSTER BYof expressions (to_date(ts)), on a temporary table or withIF NOT EXISTSis ignored with a notice. Igloo’sBUCKET(n, column)in the list (CLUSTER BY (BUCKET(32, customer_id), day)) partitions the table bybucket(n, column)instead, as its bucketed tables are, which workers join and group on that column bucket by bucket; the list’s columns are its clustering key as before.ALTER TABLE ... RECLUSTERandSUSPEND | RESUME RECLUSTERchange nothing and say so.SYSTEM$CLUSTERING_DEPTH('t' [, '(columns)'])returns the table’s average clustering depth, by the first column given or its key’s; a predicate as a third argument is not supported, nor isSYSTEM$CLUSTERING_INFORMATION. - Temporary tables and views named in a schema, as dbt’s incremental models
make them (
CREATE OR REPLACE TEMPORARY TABLE db.schema.m__dbt_tmp AS ...), live in DuckDB’stempcatalog, which keeps every temporary object, for the session that made them. The session’s later statements that name one in its schema, with or without the database, read it there, as Snowflake finds a session’s temporary object before a table of the same name; dropping it ends that.information_schema.tableslists them in thetempcatalog. - Dynamic tables:
CREATE [OR REPLACE] DYNAMIC TABLE name TARGET_LAG = '...' | DOWNSTREAM WAREHOUSE = w [REFRESH_MODE = AUTO | FULL | INCREMENTAL] [INITIALIZE = ON_CREATE | ON_SCHEDULE] AS query, with its query translated,ALTER DYNAMIC TABLE ... SUSPEND | RESUME | REFRESH | SET TARGET_LAG,DROP DYNAMIC TABLEandSHOW DYNAMIC TABLES [LIKE ...]. Igloo refreshes them incrementally when the query allows, as Snowflake’sAUTOdoes;WAREHOUSE,COMMENTandDATA_RETENTION_TIME_IN_DAYSare accepted and ignored with a notice (see dynamic tables). CREATE [OR REPLACE] [SECURE] VIEW(SECUREignored with a notice),ALTER TABLE ... ADD COLUMNwith Snowflake’s types,DESC[RIBE] TABLE,USE DATABASE,USE SCHEMA. As in Snowflake, a view’s column list names every column its query returns, no fewer: one that names fewer is refused (“invalid column definition list”), where DuckDB’s dialect names the first columns and keeps the rest’s own names.USE WAREHOUSE,USE ROLEandGRANT USAGE ON DATABASE | SCHEMA | WAREHOUSEchange nothing and say so in a notice.GRANT ... TO ROLE randGRANT ROLE r TO USER uare Igloo’sGRANT.ALTER SESSION SET:TIMEZONE,STATEMENT_TIMEOUT_IN_SECONDSandSTATEMENT_QUEUED_TIMEOUT_IN_SECONDSset Igloo’s settings,QUERY_TAGthe query tag,USE_CACHED_RESULTwhether the session uses the result cache;WEEK_START,WEEK_OF_YEAR_POLICY,TIMESTAMP_TYPE_MAPPING, the input formats and the output formats are accepted at the values Igloo follows (0,TIMESTAMP_NTZ,AUTO, the default output formats above) and refused at others; parameters about clients, caching and queuing change nothing.ALTER SESSION UNSETresets them.- Snowflake’s ML classes:
CREATE SNOWFLAKE.ML.FORECAST,ANOMALY_DETECTION,CLASSIFICATIONandTOP_INSIGHTS,DROP,SHOWandGRANTof models,CALL m!METHOD(...),SELECT * FROM TABLE(m!METHOD(...))andm!PREDICT(INPUT_DATA => {*}), withSYSTEM$REFERENCE,SYSTEM$QUERY_REFERENCEandTABLE(...)inputs; and the same statements for Igloo’s own classes,IGLOO.ML.<class>, which bring BigQuery ML’s model types. See ML functions.
Known differences
Section titled “Known differences”What Igloo cannot reproduce exactly, and what it does instead.
Numbers
/of twoNUMBERs gives Snowflake’s quotient, rounded half away from zero to the dividend’s scale plus 6 digits (at least 6, at most 12):1/3*3is0.999999in both. It is aDOUBLE, though, not aNUMBER(p,s), so a quotient divided again is not rounded to Snowflake’s scale:(1/3)/(2/3)is0.499999250000375in Igloo,0.499999250000in Snowflake. Cast toNUMBER(p,s)where the scale matters. AFLOATon either side gives aFLOAT, as in Snowflake.- Integer types are
BIGINT, notNUMBER(38,0): arithmetic that leaves 64 bits fails with an overflow error where Snowflake’s 38 digits would hold it. - A
FLOATor timestamp that becomes text withoutTO_VARCHARor a cast, as inx || 'a'orCONCAT(x, 'a'), is DuckDB’s text (9244.0, an offset of+00);TO_VARCHAR(x)andx::VARCHARgive Snowflake’s.
Semi-structured data
- A JSON
nullread by a path is SQLNULLwhen sent to a client; Snowflake showsnull.ARRAY_CONSTRUCT(1, NULL)shows[1,null], where Snowflake shows[1, undefined]. - A path’s value used where a string is expected (
v:a = 'x',UPPER(v:a)) is the string itself; Snowflake compares the variant. The result is the same except for strings that hold JSON numbers or booleans. ORDER BY,MINandMAXof a path order numbers before strings, each by value; Snowflake orders variants by type, then value, which differs for mixed types.GROUP BYa path groups1and1.0apart.- Objects list their keys in alphabetical order, as Snowflake shows them;
OBJECT_CONSTRUCT_KEEP_NULLandOBJECT_INSERTkeepnullvalues. - An
ARRAYorOBJECTcolumn holds numbers and booleans as their text (["1","true"]):TYPEOF(a[0])isVARCHAR, andTO_JSON(a)and selecting the column show them quoted, where Snowflake showsINTEGERand[1,true]. Comparing, casting and summing them gives the number. Objects and arrays inside it read and show as objects and arrays. Store a value whose types matter in aVARIANTcolumn. - A
VARIANTcolumn and aVARCHARcolumn are both text in Iceberg, so Igloo reads aVARCHARcolumn that holds the JSON text of an object or an array as that object or array, also where it builds a value of it:ARRAY_AGG(s)of aVARCHARcolumnsthat holds{"k":1}gives[{"k":1}], where Snowflake gives["{\"k\":1}"]. Cast the column (s::STRING) to build of it as a string. - A masking policy on an
ARRAYorOBJECTcolumn returns its type, as the column holds it: Igloo casts what its expression returns, soOBJECT_CONSTRUCT(...)works. ARRAY_INTERSECTIONreturns each common value once, without Snowflake’s multiset counts.FLATTEN’sSEQisNULL.
Dates and times
- Sessions start in UTC; Snowflake’s in
America/Los_Angelesunless the account sets another.ALTER SESSION SET TIMEZONE = '...'sets it. Until it does, aTIMESTAMP_LTZshows as2026-10-07 15:58:37.862 +0000where Snowflake shows2026-10-07 08:58:37.862 -0700. TIMESTAMP_TZis stored as an instant (TIMESTAMPTZ) and shown in the session’s time zone: the offset it was written with is not kept.CONVERT_TIMEZONE(target, ts)with two arguments returns the wall-clock time intargetwithout a zone (TIMESTAMP), not aTIMESTAMP_TZ.- Times and timestamps have microseconds; nanoseconds are truncated.
DATEADD,DATE_TRUNCand similar keep aDATEaDATE, as Snowflake does, except when the date is an aggregate or window function other thanMIN,MAX,ANY_VALUE,FIRST_VALUE,LAST_VALUE,LAGandLEAD, or a statement parameter: then the result is aTIMESTAMPat midnight.- Weeks start on Monday and
DAYOFWEEKcounts from Sunday = 0, as with Snowflake’s defaults (WEEK_START = 0); otherWEEK_STARTvalues are refused.
Other functions
HASHreturns DuckDB’s 64-bit hash: as well distributed as Snowflake’s, but different values. Do not compare them with hashes Snowflake stored.RANDOM(seed)andUNIFORM(..., RANDOM(seed))ignore the seed (with a notice);SAMPLE ... SEED (n)repeats.APPROX_COUNT_DISTINCTandHLLcount with DataSketches’ HyperLogLog of 4,096 registers, as many as Snowflake’s, so their error is Snowflake’s: about 1.6% (one standard deviation), exact up to about 300 values. Their results differ from Snowflake’s within that error. In a select withGROUP BYand as window functions they count exactly, asCOUNT(DISTINCT).approx_count_distinctin DuckDB’s dialect counts the same way (see SQL); DuckDB’s own has 64 registers and errs by about 13%.APPROX_PERCENTILEis DuckDB’sapprox_quantile, approximate within its own error.APPROX_TOP_Kcounts exactly.MODEchooses among equally frequent values differently.CURRENT_ROLE()returns the user’s name;CURRENT_WAREHOUSE(),CURRENT_ACCOUNT()and the like returnNULL.
Performance
APPROX_COUNT_DISTINCTandHLLcount exactly when grouped, since a sketch per group is slower thanCOUNT(DISTINCT x)with many groups (13 s rather than 0.5 s for 7.9 million groups of 37 million rows). Ungrouped, as when profiling columns, the sketch is as fast as DuckDB’s ownapprox_count_distinct. Grouped by a few thousand groups or fewer, counting exactly takes up to three times as long as DuckDB’s own approximation (0.8 s rather than 0.24 s for 270 groups of 37 million rows).- Statements whose translations call the
sf_macros (FLATTEN,DATEADD,DATE_TRUNC,TO_DATE,TIME_SLICEand others) run on workers like any other: workers define the same macros. A session that redefines one of them runs such statements on one machine.
Names and catalog
- Identifiers are case-insensitive even when quoted:
"col"andCOLname the same column, where Snowflake would see two. - A column whose name DuckDB reserves or keeps for types and functions
(
AT,LEFT,SEMI) must be quoted where a statement reads it alone (SELECT "AT" FROM t,ORDER BY "AT"); Igloo quotes such a name for DuckDB only as an alias or a qualifier (names). - Views run with their reader’s privileges, as Igloo’s always do;
SECUREdoes not hide their definition. information_schemaandSHOWare DuckDB’s, with the Snowflake columns that tools check for:information_schema.tableshaslast_altered,comment,is_transient(alwaysNO) andis_temporary,information_schema.columnshascomment,information_schema.functionslists the macros admins create, andinformation_schema.proceduresis empty. Their other columns and rows differ from Snowflake’s. Igloo’s own catalog views list tables, columns and their usage.
Refused
Section titled “Refused”These fail with SQLSTATE 0A000 and a hint:
- Stages (
@stage,CREATE STAGE,PUT,GET,LIST,REMOVE): load files withCOPY INTOfrom a location inIGLOO_ALLOWED_LOCATIONS(see loading data). - Snowflake Scripting (
BEGIN ... END,DECLARE,EXECUTE IMMEDIATE,CALLof a procedure) andCREATE FUNCTIONorPROCEDURE: send the statements one at a time; admins can create DuckDB macros.CALLof a model’s method is Igloo’s. INSERT OVERWRITE,INSERT ALLandINSERT FIRST;ALTER TABLE ... SWAP WITH;UNDROP;CREATE DATABASE,WAREHOUSE,SEQUENCEandSTREAM; a dynamic table’s column list (CREATE DYNAMIC TABLE t (a, b) ...: name the columns in its query);AUTOINCREMENTandIDENTITYcolumns;COLLATE.CONNECT BY, the(+)outer join,MATCH_RECOGNIZE,CHANGES,BEFORE (...)andAT (STATEMENT => ...),RESULT_SCANandSEMANTIC_VIEW.- Snowflake’s ML classes other than those Igloo has
(
SNOWFLAKE.ML.CUSTOM_CLASSIFIERand the like), the Model Registry’sMODEL(...)!method, a model’s methods in an expression other than those that score rows (PREDICT, and Igloo’s classes’EXPLAIN_PREDICTand the like; call the others withCALLorTABLE(...)), and views, macros and materialized views that call a model’s methods. PIVOT ... IN (ANY),IN (SELECT ...)andDEFAULT ON NULL: list the values.OBJECT_CONSTRUCT(*)and{*}, except as a model’sPREDICTinput: name the keys and values.- Functions without a faithful translation, such as
OBJECT_DELETE,OBJECT_PICK,ARRAY_SORT,PARSE_XML,SOUNDEX,CONDITIONAL_CHANGE_EVENT,ENCRYPTandDECRYPT,REGEXP_REPLACEof one occurrence after the first,SHA2of other than 256 bits, and arguments Igloo must know when it translates (a format, a date part or a scale) given as expressions rather than literals. - Session parameters at values Igloo does not follow (
WEEK_START = 1,TIMESTAMP_TYPE_MAPPING = TIMESTAMP_LTZand the like).
Functions Igloo does not know at all pass through, and DuckDB reports them
as unknown (SQLSTATE 42883).