You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "finchxxia (via GitHub)" <gi...@apache.org> on 2026/05/01 13:20:08 UTC

Re: [PR] Databricks: Add support for `UPDATE SET *` and `INSERT *` in MERGE statements [datafusion-sqlparser-rs]

finchxxia commented on code in PR #2325:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2325#discussion_r3173305006


##########
src/parser/merge.rs:
##########
@@ -120,7 +121,13 @@ impl Parser<'_> {
 
                     let update_token = self.get_current_token().clone();
                     self.expect_keyword_is(Keyword::SET)?;
-                    let assignments = self.parse_comma_separated(Parser::parse_assignment)?;
+                    let kind = if self.dialect.supports_merge_star_syntax()

Review Comment:
   > I looks like we should be able to drop the dialect method and let the parser accept the `*` syntax anytime it shows up?
   
   done



##########
tests/sqlparser_databricks.rs:
##########
@@ -738,3 +738,61 @@ fn parse_cte_without_as() {
         .parse_sql_statements("WITH cte (SELECT 1) SELECT * FROM cte")
         .is_err());
 }
+
+#[test]
+fn test_merge_update_set_star_and_insert_star() {
+    let sql = "MERGE INTO target USING source ON target.id = source.id WHEN MATCHED THEN UPDATE SET * WHEN NOT MATCHED THEN INSERT *";
+    databricks_and_generic().verified_stmt(sql);
+
+    match databricks().verified_stmt(sql) {
+        Statement::Merge(merge) => {
+            assert_eq!(merge.clauses.len(), 2);
+
+            match &merge.clauses[0].action {
+                MergeAction::Update(update_expr) => {
+                    assert!(matches!(update_expr.kind, MergeUpdateKind::Star));
+                }
+                _ => panic!("Expected UPDATE action"),
+            }
+
+            match &merge.clauses[1].action {
+                MergeAction::Insert(insert_expr) => {
+                    assert!(matches!(insert_expr.kind, MergeInsertKind::Star));
+                    assert!(insert_expr.columns.is_empty());
+                }
+                _ => panic!("Expected INSERT action"),
+            }
+        }
+        _ => panic!("Expected MERGE statement"),
+    }
+}
+
+#[test]

Review Comment:
   > the tests can be merged into a single function? (maybe into the existing MERGE tests we have in common)
   
   done. Thanks for your suggestions.



-- 
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