Skip to content

Fix COLLATE parsing after compound identifiers#2294

Merged
yoavcloud merged 3 commits intoapache:mainfrom
romanb:collate-after-compound-expr
Apr 13, 2026
Merged

Fix COLLATE parsing after compound identifiers#2294
yoavcloud merged 3 commits intoapache:mainfrom
romanb:collate-after-compound-expr

Conversation

@romanb
Copy link
Copy Markdown
Contributor

@romanb romanb commented Apr 2, 2026

Currently the following valid SQL fails to parse with the MSSQL dialect:

SELECT t1.a COLLATE Latin1_General_CI_AS FROM t1

This PR moves the COLLATE parsing within expressions from the end of parse_prefix to parse_subexpr after parse_compound_expr, so that expr COLLATE collation is also handled correctly when expr is a compound identifier.

Move the COLLATE parsing from the end of `parse_prefix` to
`parse_subexpr` after `parse_compound_expr`, so that `expr COLLATE
collation` is handled correctly when `expr` is a compound identifier
(e.g. `t1.col COLLATE Latin1_General_CI_AS`).

expr = self.parse_compound_expr(expr, vec![])?;

if !self.in_column_definition_state() && self.parse_keyword(Keyword::COLLATE) {
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.

Suggest adding documentation here for future developers to explain why this code is here

@yoavcloud yoavcloud enabled auto-merge April 13, 2026 11:56
@yoavcloud
Copy link
Copy Markdown
Contributor

Looks good @romanb! Please address the conflicts and we should be good to go.

auto-merge was automatically disabled April 13, 2026 12:21

Head branch was pushed to by a user without write access

@yoavcloud yoavcloud added this pull request to the merge queue Apr 13, 2026
Merged via the queue into apache:main with commit b68aae0 Apr 13, 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