Skip to content

Support predicates in function arguments#457

Open
cpsievert wants to merge 5 commits into
posit-dev:mainfrom
cpsievert:fix/grammar-boolean-ops-in-function-args
Open

Support predicates in function arguments#457
cpsievert wants to merge 5 commits into
posit-dev:mainfrom
cpsievert:fix/grammar-boolean-ops-in-function-args

Conversation

@cpsievert
Copy link
Copy Markdown
Collaborator

@cpsievert cpsievert commented May 20, 2026

Closes #456.

Summary

This PR improves SQL parsing inside function arguments.

The first commit takes the minimal step needed for the original issue by allowing AND / OR in function arguments.

The second commit expands that same area to support additional predicate forms in function arguments and named function-argument values:

  • NOT
  • IN (...)
  • BETWEEN ... AND ...
  • IS NULL
  • LIKE / ILIKE

Examples that now parse include:

SELECT IFF(x = 'a' OR x = 'b', 1, 0) AS rate FROM t
VISUALISE rate AS x
DRAW point
SELECT IFF(NOT x = 'a', 1, 0) AS flag FROM t
VISUALISE flag AS x
DRAW point
SELECT IFF(x IN ('a', 'b'), 1, 0) AS flag FROM t
VISUALISE flag AS x
DRAW point
SELECT IFF(x BETWEEN 1 AND 10, 1, 0) AS flag FROM t
VISUALISE flag AS x
DRAW point

Scope

The richer predicate grammar is still scoped to function arguments rather than being applied to position_arg more generally. This keeps the change focused on the parser gap addressed by this PR instead of turning it into a broader SQL expression refactor.

Verification

  • cargo test -p ggsql function_args -- --nocapture
  • cd tree-sitter-ggsql && tree-sitter generate && tree-sitter test

This comment was marked as resolved.

@cpsievert cpsievert changed the title Fix AND/OR/NOT parsing in function arguments Fix AND/OR parsing in function arguments May 20, 2026
@cpsievert cpsievert force-pushed the fix/grammar-boolean-ops-in-function-args branch from ca44052 to 7885ef5 Compare May 20, 2026 20:38
@cpsievert cpsievert marked this pull request as ready for review May 20, 2026 20:54
@georgestagg
Copy link
Copy Markdown
Collaborator

How much more complex would it be to organise the grammar to also add the extra keywords and allow for the proposed predicates,

not_predicate
in_predicate
between_predicate
is_predicate
like_predicate

IMO if it is not too more more complex we may as well just do it now. Let me know. If you'd prefer to defer it I'll approve and merge.

@cpsievert cpsievert changed the title Fix AND/OR parsing in function arguments Support predicates in function arguments May 21, 2026
@cpsievert cpsievert force-pushed the fix/grammar-boolean-ops-in-function-args branch from 7885ef5 to 1d45ef8 Compare May 21, 2026 14:01
@cpsievert cpsievert force-pushed the fix/grammar-boolean-ops-in-function-args branch from 1d45ef8 to 19465cf Compare May 21, 2026 14:56
@cpsievert cpsievert requested a review from Copilot May 21, 2026 15:04

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as low quality.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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.

position_arg grammar rule missing boolean operators (AND, OR, etc.)

3 participants