Skip to content

Databricks: Add support for UPDATE SET * and INSERT * in MERGE statements#2325

Merged
iffyio merged 4 commits intoapache:mainfrom
finchxxia:feature/merge-star-syntax
May 2, 2026
Merged

Databricks: Add support for UPDATE SET * and INSERT * in MERGE statements#2325
iffyio merged 4 commits intoapache:mainfrom
finchxxia:feature/merge-star-syntax

Conversation

@finchxxia
Copy link
Copy Markdown
Contributor

Add parsing support for the Databricks star shorthand syntax in MERGE statements, allowing UPDATE SET * and INSERT * to reference all columns from the source.

Syntax

[ common_table_expression ]
  MERGE [ WITH SCHEMA EVOLUTION ] INTO target_table_name [target_alias]
     USING source_table_reference [source_alias]
     ON merge_condition
     { WHEN MATCHED [ AND matched_condition ] THEN matched_action |
       WHEN NOT MATCHED [BY TARGET] [ AND not_matched_condition ] THEN not_matched_action |
       WHEN NOT MATCHED BY SOURCE [ AND not_matched_by_source_condition ] THEN not_matched_by_source_action } [...]

matched_action
 { DELETE |
   UPDATE SET * |
   UPDATE SET { column = { expr | DEFAULT } } [, ...] }

not_matched_action
 { INSERT * |
   INSERT (column1 [, ...] ) VALUES ( expr | DEFAULT ] [, ...] )

not_matched_by_source_action
 { DELETE |
   UPDATE SET { column = { expr | DEFAULT } } [, ...] }

Changes

  • Add MergeUpdateKind enum (Set(Vec<Assignment>) | Star) to replace the previous assignments field on MergeUpdateExpr, enforcing valid states at the type level
  • Add MergeInsertKind::Star variant for INSERT * shorthand
  • Add supports_merge_star_syntax() dialect method for Databricks and Generic

…atements

Add parsing support for the Databricks star shorthand syntax in MERGE
statements, allowing `UPDATE SET *` and `INSERT *` to reference all columns
from the source.

- Add `MergeUpdateKind` enum (`Set(Vec<Assignment>)` | `Star`) to replace
  the previous `assignments` field on `MergeUpdateExpr`, enforcing valid
  states at the type level
- Add `MergeInsertKind::Star` variant for `INSERT *` shorthand
- Add `supports_merge_star_syntax()` dialect method for Databricks and Generic
Comment thread src/ast/dml.rs Outdated
Comment thread src/parser/merge.rs Outdated
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()
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.

I looks like we should be able to drop the dialect method and let the parser accept the * syntax anytime it shows up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I looks like we should be able to drop the dialect method and let the parser accept the * syntax anytime it shows up?

done

Comment thread tests/sqlparser_databricks.rs Outdated
}
}

#[test]
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.

the tests can be merged into a single function? (maybe into the existing MERGE tests we have in common)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the tests can be merged into a single function? (maybe into the existing MERGE tests we have in common)

done. Thanks for your suggestions.

finchxxia and others added 2 commits April 30, 2026 12:46
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Copy link
Copy Markdown
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.

LGTM! Thanks @finchxxia!

@iffyio iffyio added this pull request to the merge queue May 2, 2026
Merged via the queue into apache:main with commit a281171 May 2, 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