fix(parser): support CAST and TRY_CAST expressions#113
Merged
thomasp85 merged 3 commits intoposit-dev:mainfrom Feb 18, 2026
Merged
fix(parser): support CAST and TRY_CAST expressions#113thomasp85 merged 3 commits intoposit-dev:mainfrom
thomasp85 merged 3 commits intoposit-dev:mainfrom
Conversation
Add a dedicated cast_expression rule to handle CAST(expr AS type) and TRY_CAST(expr AS type) syntax. Previously these were parsed as regular function calls, which failed because the AS keyword inside function arguments was unexpected. The cast_expression rule is added to select_body, subquery_body, and positional_arg so casts work at top level, in subqueries, and nested inside function arguments (e.g. SUM(CAST(x AS INT))). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
georgestagg
approved these changes
Feb 16, 2026
Collaborator
georgestagg
left a comment
There was a problem hiding this comment.
LGTM, once the merge conflict is resolved.
…ssion # Conflicts: # tree-sitter-ggsql/test/corpus/basic.txt
350424c to
e79da48
Compare
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cast_expressionrule to handleCAST(expr AS type)andTRY_CAST(expr AS type)syntaxASkeyword inside function arguments was unexpectedselect_body,subquery_body, andpositional_argso casts work at top level, in subqueries, and nested inside function arguments (e.g.SUM(CAST(x AS INT)))Test plan
CAST expressionandTRY_CAST nested in function argument🤖 Generated with Claude Code