You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "yoavcloud (via GitHub)" <gi...@apache.org> on 2025/07/08 20:47:20 UTC
[PR] Sf create table as [datafusion-sqlparser-rs]
yoavcloud opened a new pull request, #1931:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1931
The code that parses `CREATE TABLE` in the Snowflake dialect assumed that if the `AS`, `LIKE` or `CLONE` options are used, then no other options can be specified. That is not true, so that restriction is now removed.
For example:
`CREATE TEMP TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Snowflake: support trailing options in `CREATE TABLE` [datafusion-sqlparser-rs]
Posted by "yoavcloud (via GitHub)" <gi...@apache.org>.
yoavcloud commented on code in PR #1931:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1931#discussion_r2199758669
##########
tests/sqlparser_snowflake.rs:
##########
@@ -995,6 +995,21 @@ fn test_snowflake_create_iceberg_table_without_location() {
);
}
+#[test]
+fn test_snowflake_create_table_trailing_options() {
+ snowflake()
+ .parse_sql_statements(
+ "CREATE TEMP TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS",
+ )
+ .unwrap();
+ snowflake()
+ .parse_sql_statements("CREATE TEMP TABLE tbl LIKE customers ON COMMIT PRESERVE ROWS;")
+ .unwrap();
+ snowflake()
+ .parse_sql_statements("CREATE TEMP TABLE tbl CLONE customers ON COMMIT PRESERVE ROWS;")
+ .unwrap();
Review Comment:
Improved the tests, note Snowflake supports specifying the options either before or after the "source" definition while the SQL output assumes one. Added tests for both options.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Snowflake: support trailing options in `CREATE TABLE` [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #1931:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1931
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Snowflake trailing options in CREATE TABLE [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #1931:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1931#discussion_r2198043261
##########
src/ast/helpers/stmt_create_table.rs:
##########
@@ -383,6 +383,16 @@ impl CreateTableBuilder {
self
}
+ /// Returns true if information on the structure of the table
+ /// to be created was provided to the builder. If not, the
+ /// statement is invalid.
+ pub fn has_schema_info(&self) -> bool {
+ !self.columns.is_empty()
+ || self.query.is_some()
+ || self.like.is_some()
+ || self.clone.is_some()
Review Comment:
could we add tests covering this behavior? e.g a test that fails when only a query, columns, like etc is provided in a create statement
##########
tests/sqlparser_snowflake.rs:
##########
@@ -995,6 +995,21 @@ fn test_snowflake_create_iceberg_table_without_location() {
);
}
+#[test]
+fn test_snowflake_create_table_trailing_options() {
+ snowflake()
+ .parse_sql_statements(
+ "CREATE TEMP TABLE dst AS (SELECT * FROM src) ON COMMIT PRESERVE ROWS",
+ )
+ .unwrap();
+ snowflake()
+ .parse_sql_statements("CREATE TEMP TABLE tbl LIKE customers ON COMMIT PRESERVE ROWS;")
+ .unwrap();
+ snowflake()
+ .parse_sql_statements("CREATE TEMP TABLE tbl CLONE customers ON COMMIT PRESERVE ROWS;")
+ .unwrap();
Review Comment:
can we use verified_stmt here or similar roundtrip assertion?
##########
src/ast/helpers/stmt_create_table.rs:
##########
@@ -383,6 +383,16 @@ impl CreateTableBuilder {
self
}
+ /// Returns true if information on the structure of the table
+ /// to be created was provided to the builder. If not, the
+ /// statement is invalid.
+ pub fn has_schema_info(&self) -> bool {
Review Comment:
```suggestion
pub(crate) fn has_schema_info(&self) -> bool {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org