Skip to content

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

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

LucaCappelletti94 wants to merge 3 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.37%. Comparing base (ada8314) to head (787fab3).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2484      +/-   ##
==========================================
+ Coverage   81.28%   81.37%   +0.09%     
==========================================
  Files          42       42              
  Lines       33920    34074     +154     
  Branches    33920    34074     +154     
==========================================
+ Hits        27571    27727     +156     
+ Misses       2785     2784       -1     
+ Partials     3564     3563       -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.

@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.

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