Skip to content

Databricks: support INSERT BY NAME - #2403

Merged
iffyio merged 13 commits into
apache:mainfrom
finchxxia:dbx-insert-by-name
Sep 14, 2026
Merged

iffyio merged 13 commits into
apache:mainfrom
finchxxia:dbx-insert-by-name

Conversation

@finchxxia

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for Databricks INSERT ... BY NAME syntax.

  • Adds a by_name field to the Insert AST node.
  • Parses BY NAME for the Databricks and Generic dialects.
  • Preserves BY NAME when formatting the AST back to SQL.
  • Adds test coverage for INSERT INTO ... BY NAME with both SELECT and WITH queries.
  • Updates existing Insert AST construction sites with the default by_name: false.

Examples

INSERT INTO target BY NAME
SELECT 1 AS a;
INSERT INTO TABLE target BY NAME
WITH source AS (
    SELECT 1 AS event_data_id
)
SELECT event_data_id FROM source;

Testing

cargo test --test sqlparser_databricks test_databricks_insert_by_name
Relevant PostgreSQL INSERT regression tests

Comment thread src/dialect/mod.rs Outdated
Comment thread src/parser/mod.rs Outdated
@finchxxia

Copy link
Copy Markdown
Contributor Author

Hi @iffyio , I have committed some changes as per your suggestions. Could you plz take a look again?

Comment thread src/parser/mod.rs
Comment thread tests/sqlparser_common.rs Outdated
Comment thread tests/sqlparser_common.rs
Comment thread tests/sqlparser_databricks.rs Outdated
finchxxia and others added 4 commits August 4, 2026 08:25
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Cover BY NAME alongside a PARTITION clause and a table alias to guard
against conflicts with neighbouring INSERT syntax, and rely on
verified_stmt in the Databricks tests since the AST is asserted in the
common tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread tests/sqlparser_postgres.rs
@iffyio

iffyio commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@finchxxia could you take a look to resolve the conflicts on this branch, otherwise I think this looks good

@finchxxia

Copy link
Copy Markdown
Contributor Author

@finchxxia could you take a look to resolve the conflicts on this branch, otherwise I think this looks good

@iffyio done. Thanks for your help.

@iffyio iffyio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks @finchxxia!

@iffyio
iffyio added this pull request to the merge queue Sep 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 9, 2026
@iffyio
iffyio added this pull request to the merge queue Sep 14, 2026
Merged via the queue into apache:main with commit 9296011 Sep 14, 2026
10 checks passed
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