Skip to content

PostgreSQL: Support the VARIADIC function call argument marker - #2484

Open
LucaCappelletti94 wants to merge 4 commits into
apache:mainfrom
LucaCappelletti94:pg-variadic-function-arg
Open

LucaCappelletti94 wants to merge 4 commits into
apache:mainfrom
LucaCappelletti94:pg-variadic-function-arg

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

PostgreSqlDialect could not parse the VARIADIC argument marker in a function call, in any position:

Parser::parse_sql(&PostgreSqlDialect {}, "SELECT concat(VARIADIC a)");
// Err: sql parser error: Expected: ), found: a at Line: 1, Column: 24

The marker is added as FunctionArg::Variadic. Parsing is gated on Dialect::supports_variadic_function_argument, enabled for PostgreSQL and the generic dialect.

As in PostgreSQL, the marker is rejected on a wildcard operand, in combination with DISTINCT or ALL, and on any but the final argument.

@LucaCappelletti94
LucaCappelletti94 marked this pull request as ready for review September 3, 2026 20:13
@LucaCappelletti94
LucaCappelletti94 force-pushed the pg-variadic-function-arg branch 4 times, most recently from e358745 to 66f00a5 Compare September 22, 2026 21:20
LucaCappelletti94 added a commit to LucaCappelletti94/sqlparser-rs that referenced this pull request Oct 1, 2026
@codecov-commenter

codecov-commenter commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.90%. Comparing base (8fe5a1a) to head (01e8b71).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2484      +/-   ##
==========================================
+ Coverage   81.84%   81.90%   +0.05%     
==========================================
  Files          42       42              
  Lines       34667    34764      +97     
  Branches    34667    34764      +97     
==========================================
+ Hits        28373    28472      +99     
+ Misses       2753     2752       -1     
+ Partials     3541     3540       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94
LucaCappelletti94 force-pushed the pg-variadic-function-arg branch from 94a4362 to efb39cc Compare October 2, 2026 16:14
@LucaCappelletti94
LucaCappelletti94 force-pushed the pg-variadic-function-arg branch 2 times, most recently from b959e40 to 9212127 Compare October 18, 2026 14:22

@sabir-akhadov-localstack sabir-akhadov-localstack left a comment

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.

One non-blocking comment inline.

Comment thread src/ast/spans.rs
arg,
operator: _,
} => name.span().union(&arg.span()),
FunctionArg::Variadic(arg) => arg.span(),

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.

This span starts at the operand, so for SELECT f(VARIADIC a, b) the "must be the last function argument" error points at a rather than at VARIADIC; capturing the keyword's span (or using self.peek_token_ref().span.start in the position check) would put it on the marker.

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.

Fixed it, but span really is a mess of its own and we'll have to handle it some time after the tokenizer refactoring. Thanks for pointing this one out.

@LucaCappelletti94
LucaCappelletti94 force-pushed the pg-variadic-function-arg branch 4 times, most recently from 8707007 to a26e66a Compare October 24, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants