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.
Supported data types¶
Dynamic tables support all Snowflake SQL data types for both incremental and full refresh, except:
Structured data types.
Geospatial data types (full refresh only).
Supported queries in incremental and full refresh modes¶
Keyword |
Incremental Refresh Mode |
Full Refresh Mode |
---|---|---|
Supported |
Supported |
|
Not supported |
Not supported |
|
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 |
|
Supported |
Supported |
|
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 |
|
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: CREATE TABLE persons
AS
SELECT column1 AS id, parse_json(column2) AS entity
FROM values
(12712555,
'{ name: { first: "John", last: "Smith"},
contact: [
{ business:[
{ type: "phone", content:"555-1234" },
{ type: "email", content:"j.smith@example.com" } ] } ] }'),
(98127771,
'{ name: { first: "Jane", last: "Doe"},
contact: [
{ business:[
{ type: "phone", content:"555-1236" },
{ type: "email", content:"j.doe@example.com" } ] } ] }');
CREATE DYNAMIC TABLE my_dynamic_table
TARGET_LAG = DOWNSTREAM
WAREHOUSE = mywh
AS
SELECT p.id, f.value, f.path
FROM persons p,
LATERAL FLATTEN(input => p.entity) f;
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:
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 |
Supported in the SELECT clause. |
Supported |
|
Not supported |
Not supported |
|
Not supported |
Not supported |
|
Scalar Aggregates |
Supported |
Supported |
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 |
Not supported |
Not supported |
|
All subquery operators. |
Not supported |
Supported |
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 |
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. |
|
Supported, except for the following limitations:
|
Supported |
|
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 |
---|---|---|
Not supported |
Not supported |
|
Supported in the SELECT clause |
Supported |
|
Supported in the SELECT clause |
Supported |
|
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. |
Not supported |
Supported |
|
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. |
Not supported |
Supported |
|
Supported |
Supported |
|
Supported in the SELECT clause |
Supported |
|
Supported in the SELECT clause |
Supported |
|
Supported in the SELECT clause |
Supported |
|
Supported in the SELECT clause |
Supported |
|
Supported |
Supported |
|
Supported |
Supported |
|
Supported |
Supported |
|
Supported |
Supported |
|
Supported |
Supported |
|
Supported in the SELECT clause |
Supported |
|
Sequence functions (e.g., |
Not supported |
Supported |
Supported in the SELECT clause |
Supported |
|
VOLATILE user-defined functions |
Not supported |
Supported |
Supported Snowflake Cortex AISQL functions¶
You can use Snowflake Cortex AISQL (including LLM functions) in the SELECT clause for dynamic tables in incremental refresh mode. The same availability restrictions as described in AISQL functions apply.
Cortex AISQL lets 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 AISQL combines
the prompt The reviewer enjoyed the restaurant
with the actual review text. The output column enjoyed
is the classification
generated using Cortex AISQL based on the prompt, indicating whether the reviewer enjoyed the restaurant.
CREATE OR REPLACE TABLE reviews AS
SELECT 'Wow... Loved this place.' AS review
UNION ALL
SELECT 'The pizza is not good.' AS review;
CREATE OR REPLACE DYNAMIC TABLE review_sentiment
TARGET_LAG = DOWNSTREAM
WAREHOUSE = mywh
REFRESH_MODE = INCREMENTAL
AS
SELECT review, AI_FILTER(CONCAT('The reviewer enjoyed the restaurant', review), {'model': 'llama3.1-70b'}) AS enjoyed FROM reviews;