Skip to content

Conversation

@finchxxia
Copy link

@finchxxia finchxxia commented Jan 4, 2026

To solve issue #2150

  1. I found that datafusion-sqlparser-rs cannot support multi-table insert currently.
-- Unconditional multi-table insert
INSERT [ OVERWRITE ] ALL
  intoClause [ ... ]
<subquery>

-- Conditional multi-table insert
INSERT [ OVERWRITE ] { FIRST | ALL }
  { WHEN <condition> THEN intoClause [ ... ] }
  [ ... ]
  [ ELSE intoClause ]
<subquery>
  1. Another case is when I using SAMPLE in subquery, it cannot work normally.
SELECT * FROM (SELECT * FROM (select report_from from my_table) SAMPLE (10000 ROWS)) AS anon_1

Copy link
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @finchxxia!

  • it doesn't seem like we have tests (unless I missed them) for the multitable insert diffs? If not can we add tests that demonstrate the changes in behavior
  • Can we split this PR into two, one for the multitable insert and the other for the sample clause? I think that would make the PR easier to get to, given that they're unrelated changes

Add support for Snowflake's multi-table INSERT statement, including:

1. Unconditional multi-table insert:
   INSERT ALL INTO t1 INTO t2 SELECT ... FROM src

2. Conditional multi-table insert with WHEN clauses:
   INSERT ALL/FIRST WHEN cond THEN INTO t1 ELSE INTO t2 SELECT ... FROM src

3. INSERT OVERWRITE support for multi-table insert

4. INTO clause with optional column list and VALUES clause

See: https://docs.snowflake.com/en/sql-reference/sql/insert-multi-table
…sert-v2

Add Snowflake multi-table INSERT support
@finchxxia
Copy link
Author

Hi @iffyio,

I've added the test about multi-table insert and remove all changes about sample data in subquery to another issue & PR.
Plz take a look again:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants