Skip to content

Conversation

ldaIas
Copy link

@ldaIas ldaIas commented Jul 10, 2025

This PR seeks to resolve this issue: #2245 (comment).

  • In the OrderByElement() JJTree rule, introduced a new Token collateToken to capture the literal or quoted identifier following COLLATE.
  • Added a lookahead for <K_COLLATE> in the grammar so that if COLLATE appears after the expression, we wrap the existing columnReference in a new CollateExpression(columnReference, collateToken.image).
  • This ensures that COLLATE 'UND-X-ICU' (or an identifier) is parsed correctly in ORDER BY clauses.

For example, the following SQL statement would fail:

select *
from a
order by cast(a.xyz as text) collate "und-x-icu" asc nulls first

with error:
Encountered unexpected token: "COLLATE" "COLLATE" at line 1, column 46. Was expecting one of: <EOF> <ST_SEMICOLON>

Now this same statement can be parsed succesfully.

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.

1 participant