Skip to content

Snowflake: CREATE DYNAMIC TABLE #1960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yoavcloud
Copy link
Contributor

Added support for CREATE DYNAMIC TABLE in Snowflake:

  1. Extended CreateTableBuilder with new options
  2. Removed the CreateTableBuilder::validate_schema_info function and related tests because, in my opinion, it introduces semantic validation, which is out of scope for the parser.
  3. As so many options exist for creating tables, we should evaluate whether specifying them explicitly is robust enough, or a generic parsing of options is a better alternative. Food for thought.

fn parse_create_dynamic_table() {
snowflake().verified_stmt(r#"CREATE OR REPLACE DYNAMIC TABLE my_dynamic_table TARGET_LAG='20 minutes' WAREHOUSE=mywh AS SELECT product_id, product_name FROM staging_table"#);
snowflake()
.parse_sql_statements(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the usages of parse_sql_statements can we instead use snowflake().one_statement_parses_to(sql, canonical) in the cases that verified_stmt isnt applicable?

@@ -1104,6 +1066,56 @@ fn parse_sf_create_table_or_view_with_dollar_quoted_comment() {
);
}

#[test]
fn parse_create_dynamic_table() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include scenarios for the BEFORE and RefreshMode variants? those don't seem to be covered by the existing tests?

@yoavcloud yoavcloud force-pushed the sf_create_dynamic_table branch from c314bdd to e6dbd03 Compare July 24, 2025 15:15
@yoavcloud yoavcloud requested a review from iffyio July 24, 2025 15:16
"CREATE DYNAMIC TABLE my_dynamic_table",
" TARGET_LAG='DOWNSTREAM'",
" WAREHOUSE=mywh",
" REFRESH_MODE=AUTO",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add similar coverage for REFRESH_MODE=FULL and REFRESH_MODE=INCREMENTAL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants