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


##########
src/ast/dml.rs:
##########
@@ -649,6 +649,14 @@ pub enum MergeInsertKind {
     /// ```
     /// 
[BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#merge_statement)
     Row,
+    /// The insert expression uses the `*` shorthand to insert all columns.
+    ///
+    /// Example:
+    /// ```sql
+    /// INSERT *
+    /// ```
+    /// 
[Databricks](https://docs.databricks.com/en/sql/language-manual/delta-merge-into.html)
+    Star,

Review Comment:
   ```suggestion
       Wildcard,
   ```
   I think this would be more consistent naming wise?



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



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



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to