-
Notifications
You must be signed in to change notification settings - Fork 755
Databricks: support CREATE TABLE USING, MAP<K, V> columns and LONG as BIGINT #2425
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -737,3 +737,55 @@ fn parse_cte_without_as() { | |
| .parse_sql_statements("WITH cte (SELECT 1) SELECT * FROM cte") | ||
| .is_err()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_create_table_using() { | ||
| match databricks().verified_stmt("CREATE TABLE t (id BIGINT) USING DELTA") { | ||
| Statement::CreateTable(CreateTable { hive_formats, .. }) => { | ||
| assert_eq!( | ||
| hive_formats.unwrap().storage, | ||
| Some(HiveIOFormat::Using { | ||
| format: Ident::new("DELTA") | ||
| }) | ||
| ); | ||
| } | ||
| s => panic!("Unexpected statement: {s:?}"), | ||
| } | ||
|
|
||
| databricks().verified_stmt("CREATE TABLE IF NOT EXISTS t (id BIGINT) USING PARQUET"); | ||
|
|
||
| assert!(all_dialects_where(|d| !d.supports_create_table_using()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding the analogous assert also for the other flags you have set
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I believe that since this assertion regards all dialects except databricks, it should not be in the databricks tests, but in common. |
||
| .parse_sql_statements("CREATE TABLE t (id BIGINT) USING DELTA") | ||
| .is_err()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_create_table_map_type() { | ||
| match databricks().verified_stmt("CREATE TABLE t (m MAP<STRING, INT>)") { | ||
| Statement::CreateTable(CreateTable { columns, .. }) => { | ||
| assert_eq!( | ||
| columns[0].data_type, | ||
| DataType::Map( | ||
| Box::new(DataType::String(None)), | ||
| Box::new(DataType::Int(None)), | ||
| MapBracketKind::AngleBrackets | ||
| ) | ||
| ); | ||
| } | ||
| s => panic!("Unexpected statement: {s:?}"), | ||
| } | ||
|
|
||
| databricks().verified_stmt("CREATE TABLE t (m MAP<STRING, ARRAY<INT>>)"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_long_type_as_bigint() { | ||
| match databricks() | ||
| .one_statement_parses_to("CREATE TABLE t (id LONG)", "CREATE TABLE t (id BIGINT)") | ||
| { | ||
| Statement::CreateTable(CreateTable { columns, .. }) => { | ||
| assert_eq!(columns[0].data_type, DataType::BigInt(None)); | ||
| } | ||
| s => panic!("Unexpected statement: {s:?}"), | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are adding support for Spark flags in Databricks, I believe you should also add
supports_pipe_operatorandparse_infixforDIV.