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


##########
src/ast/dml.rs:
##########
@@ -90,92 +90,174 @@ pub struct Insert {
     ///
     /// [ClickHouse formats JSON 
insert](https://clickhouse.com/docs/en/interfaces/formats#json-inserting-data)
     pub format_clause: Option<InputFormatClause>,
+    /// For multi-table insert: `INSERT FIRST` vs `INSERT ALL`
+    ///
+    /// When `true`, this is an `INSERT FIRST` statement (only the first 
matching WHEN clause is executed).
+    /// When `false` with non-empty `clauses`, this is an `INSERT ALL` 
statement.
+    ///
+    /// See: 
<https://docs.snowflake.com/en/sql-reference/sql/insert-multi-table>
+    pub insert_first: bool,
+    /// For multi-table insert: additional INTO clauses (unconditional)
+    ///
+    /// Used for `INSERT ALL INTO t1 INTO t2 ... SELECT ...`
+    ///
+    /// See: 
<https://docs.snowflake.com/en/sql-reference/sql/insert-multi-table>
+    pub multi_table_into_clauses: Vec<MultiTableInsertIntoClause>,
+    /// For conditional multi-table insert: WHEN clauses
+    ///
+    /// Used for `INSERT ALL/FIRST WHEN cond THEN INTO t1 ... SELECT ...`
+    ///
+    /// See: 
<https://docs.snowflake.com/en/sql-reference/sql/insert-multi-table>
+    pub multi_table_when_clauses: Vec<MultiTableInsertWhenClause>,
+    /// For conditional multi-table insert: ELSE clause
+    ///
+    /// See: 
<https://docs.snowflake.com/en/sql-reference/sql/insert-multi-table>
+    pub multi_table_else_clause: Option<Vec<MultiTableInsertIntoClause>>,
 }
 
 impl Display for Insert {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let table_name = if let Some(alias) = &self.table_alias {
-            format!("{0} AS {alias}", self.table)
-        } else {
-            self.table.to_string()
-        };
+        // Check if this is a Snowflake multi-table insert
+        let is_multi_table = !self.multi_table_into_clauses.is_empty()
+            || !self.multi_table_when_clauses.is_empty();

Review Comment:
   @iffyio Hi, do you think this is a better way to parse multi-table insert 
statement? I'm not sure if I should refactor the whole insert statement because 
there are too much difference between standard insert and multi-table insert  



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