Supported queries for dynamic tables¶
Dynamic tables support standard SQL expressions and Snowflake-supported functions, including mathematical operations, string functions, date functions, etc. This topic describes the expressions, constructs, functions, operators, and clauses that dynamic tables support in incremental and full refresh modes.
If a query uses expressions, keywords, operators, or clauses that are not supported for incremental refresh, the automated refresh process uses a full refresh instead, which might incur an additional cost.
For guidance on how different operators affect incremental refresh performance, see Optimize queries for incremental refresh.
Supported data types¶
Dynamic tables support all Snowflake SQL data types for both incremental and full refresh, except:
- Structured data types (structured OBJECT, ARRAY, and MAP). This limitation applies to both incremental and full refresh. Semi-structured types (VARIANT, OBJECT, ARRAY without a defined schema) are fully supported.
- Geospatial data types (full refresh only).
Supported queries in incremental and full refresh modes¶
| Keyword | Incremental Refresh Mode | Full Refresh Mode |
|---|---|---|
| DISTINCT | Supported | Supported |
| External functions | Not supported | Not supported |
| FROM | Source tables, views, Snowflake-managed Apache Iceberg™ tables, and other dynamic tables. Subqueries outside of FROM clauses (for example, WHERE EXISTS) are not supported. | Supported |
| GROUP BY | Supported | Supported |
| CROSS JOIN | Supported. You can specify any number of tables in the join, and updates to all tables in the join are reflected in the results of the query. | Supported |
| INNER JOIN | Supported. You can specify any number of tables in the join, and updates to all tables in the join are reflected in the results of the query. | Supported |
| LATERAL JOIN | Not supported. However, you can use LATERAL with FLATTEN(). For example: Note the following behavior for using lateral flatten with incremental refresh:
| Supported. |
| OUTER-EQUI JOIN. | Supported. You can specify any number of tables in the join, and updates to all tables in the join are reflected in the results of the query. | Supported |
| [{LEFT | RIGHT | FULL }] OUTER JOIN | The following is not supported:
Self-joins (where both sides of the outer join reference the same table) are supported. Otherwise, you can specify any number of tables in an outer join, and updates to all tables in the join are reflected in the results of the query. | Supported |
| ML or LLM functions | Supported in the SELECT clause. | Supported |
| PIVOT and UNPIVOT | Not supported | Not supported |
| SAMPLE / TABLESAMPLE | Not supported | Not supported |
| Scalar Aggregates | Supported | Supported |
| SELECT | Expressions including those using deterministic built-in functions and immutable user-defined functions. | Supported |
| Set operators (UNION, MINUS, EXCEPT, INTERSECT) | Not supported, except for UNION. In incremental refresh, the UNION set operator works like the combination of the UNION ALL and SELECT DISTINCT operators. | Supported |
| Sequences. | Not supported | Not supported |
| All subquery operators. | Not supported | Supported |
| UNION ALL | Supported | Supported |
| User-defined functions (UDFs) | Supported, except for the following limitations:
| Supported |
| User-defined table functions (UDTFs) | Supported, except for the following limitations:
| Supported |
| WHERE / HAVING / QUALIFY | Filters with the same expressions that are valid in SELECT are supported. Filters with the CURRENT_TIMESTAMP, CURRENT_TIME, and CURRENT_DATE functions and their aliases are supported. | Supported. Filters with the CURRENT_TIMESTAMP, CURRENT_TIME, and CURRENT_DATE functions and their aliases are supported. |
| Window functions | Supported, except for the following limitations:
| Supported |
| WITH | Common table expressions (CTEs) that use incremental refresh supported features in the subquery are supported. WITH RECURSIVE is not supported. | Supported |
Supported non-deterministic functions in incremental and full refresh modes¶
| Non-deterministic Function | Incremental Refresh Mode | Full Refresh Mode |
|---|---|---|
| ANY_VALUE | Not supported | Not supported |
| CLASSIFY_TEXT (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
| COMPLETE (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
| CURRENT_ACCOUNT | Not supported | Supported |
| CURRENT_DATE (and aliases) | Supported only as a part of a WHERE/HAVING/QUALIFY clause. | Supported only as a part of a WHERE/HAVING/QUALIFY clause. |
| CURRENT_REGION | Not supported | Supported |
| CURRENT_ROLE | Not supported | Supported |
| CURRENT_TIME (and aliases) | Supported only as a part of a WHERE/HAVING/QUALIFY clause. | Supported only as a part of a WHERE/HAVING/QUALIFY clause. |
| CURRENT_TIMESTAMP (and aliases) | Supported only as a part of a WHERE/HAVING/QUALIFY clause. | Supported only as a part of a WHERE/HAVING/QUALIFY clause. |
| Functions that rely on CURRENT_USER. | Not supported. Dynamic table refreshes act as their owner role with a special SYSTEM user. | Not supported. Dynamic table refreshes act as their owner role with a special SYSTEM user. |
| CURRENT_WAREHOUSE | Not supported | Supported |
| DENSE_RANK | Supported | Supported |
| EMBED_TEXT_768 (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
| EMBED_TEXT_1024 (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
| EXTRACT_ANSWER (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
| FINETUNE (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
| FIRST_VALUE | Supported | Supported |
| LAST_VALUE | Supported | Supported |
| MAX_BY | Supported | Supported |
| MIN_BY | Supported | Supported |
| NTH_VALUE | Supported | Supported |
| RANK | Supported | Supported |
| ROW_NUMBER | Supported | Supported |
| SENTIMENT (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
Sequence functions (e.g., SEQ1, SEQ2) | Not supported | Supported |
| TRANSLATE (SNOWFLAKE.CORTEX) | Supported in the SELECT clause | Supported |
| VOLATILE user-defined functions | Not supported | Supported |
Supported Snowflake Cortex AI functions¶
You can use Snowflake Cortex AI Functions (including LLM functions) in the SELECT clause for dynamic tables in incremental refresh mode. The same availability restrictions as described in Cortex AI functions apply.
Cortex AI Functions let you add AI-powered insights directly to your dynamic tables, automatically analyzing data as it updates. For example, it can classify customer reviews, support tickets, or survey responses as positive/negative or assign categories.
In the following example, review_sentiment uses AI_FILTER to evaluate each review with an LLM. Cortex AI Functions combine
the prompt The reviewer enjoyed the restaurant with the actual review text. The output column enjoyed is the classification
generated using Cortex AI Functions based on the prompt, indicating whether the reviewer enjoyed the restaurant.
Support for incremental refresh¶
Dynamic tables support two refresh modes: incremental and full. You can either set the refresh mode to AUTO or set it explicitly. For more information, see Dynamic table refresh modes and Choose a refresh mode.
Incremental refresh on full-refresh dynamic tables¶
Dynamic tables in incremental refresh mode can’t consume an upstream dynamic table with full refresh mode unless the upstream full-refresh dynamic table has a system-derived reliable unique key. When such a reliable unique key exists, Snowflake can compute row-level changes across full refreshes, enabling downstream incremental processing.
To use this capability, set REFRESH_MODE = INCREMENTAL explicitly on the downstream dynamic table. REFRESH_MODE = AUTO doesn’t
resolve to incremental in this scenario.
For more information, see Understanding primary keys in dynamic tables.
Masking and row access policies¶
Masking or row access policies on a dynamic table don’t affect its refresh mode. However, policies applied on base tables might affect the refresh mode:
- Incremental refresh is supported if the policies on base tables use the CURRENT_ROLE or IS_ROLE_IN_SESSION function.
- Incremental refresh isn’t supported if the policies on base tables use any other functions, INFORMATION_SCHEMA views, or query a table (for example, a mapping table lookup).
- Changes to the policies on base objects of dynamic tables with incremental refresh trigger reinitialization.
Replication¶
Replicated dynamic tables with incremental refresh reinitialize after failover before they can resume incremental refresh.
For more information, see Replication and dynamic tables.
Cloning¶
Cloned incremental dynamic tables might need to reinitialize during their first refresh after being created.
If a dynamic table is cloned from another dynamic table with dropped base tables, the clone will be suspended and can’t be resumed or refreshed.