-
Notifications
You must be signed in to change notification settings - Fork 753
Databricks: support INSERT BY NAME #2403
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
68ff95d
3aa09e6
353ba80
2447117
123a295
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 |
|---|---|---|
|
|
@@ -19665,3 +19665,18 @@ fn parse_function_arg_call_chain_no_exponential_blowup() { | |
| rx.recv_timeout(Duration::from_secs(5)) | ||
| .expect("parser should reject this quickly, not loop exponentially"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_insert_by_name() { | ||
| verified_stmt("INSERT INTO target BY NAME SELECT 1 AS a"); | ||
|
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. maybe we can also add some scenarios with table options that cover around the new option to ensure that parsing |
||
|
|
||
| match verified_stmt("INSERT INTO target (a) BY NAME SELECT 1 AS a") { | ||
| Statement::Insert(Insert { | ||
| by_name, columns, .. | ||
| }) => { | ||
| assert!(by_name); | ||
| assert_eq!(columns.len(), 1); | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -737,3 +737,34 @@ fn parse_cte_without_as() { | |
| .parse_sql_statements("WITH cte (SELECT 1) SELECT * FROM cte") | ||
| .is_err()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_databricks_insert_by_name() { | ||
| match databricks_and_generic().verified_stmt("INSERT INTO target BY NAME SELECT 1 AS a") { | ||
|
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. we can remove the AST assertion and rely on verified_stmt only for these, (AST is already covered in common) |
||
| Statement::Insert(Insert { | ||
| by_name, | ||
| columns, | ||
| has_table_keyword, | ||
| .. | ||
| }) => { | ||
| assert!(by_name); | ||
| assert!(columns.is_empty()); | ||
| assert!(!has_table_keyword); | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
|
|
||
| match databricks_and_generic().verified_stmt( | ||
| "INSERT INTO TABLE lakehouse.dwd.dwd_event_quality_sla_metric_di BY NAME WITH day AS (SELECT 1 AS event_data_id) SELECT event_data_id FROM day", | ||
| ) { | ||
| Statement::Insert(Insert { | ||
| by_name, | ||
| has_table_keyword, | ||
| .. | ||
| }) => { | ||
| assert!(by_name); | ||
| assert!(has_table_keyword); | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
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.
oh this pattern looks a bit odd, would it make more sense to do the following?