Skip to content

Support parsing parenthesized wildcard (*) - #2123

Merged
iffyio merged 3 commits into
apache:mainfrom
romanoff:allow_parsing_parenthesized_wildcard
Dec 19, 2025
Merged

Support parsing parenthesized wildcard (*)#2123
iffyio merged 3 commits into
apache:mainfrom
romanoff:allow_parsing_parenthesized_wildcard

Conversation

@romanoff

Copy link
Copy Markdown

Support parsing parenthesized wildcard (*)

Example of query:

SELECT DISTINCT (*) FROM table1

Comment threadtests/sqlparser_common.rs Outdated
}

#[test]
fn parse_select_distinct_parenthesized_wildcard() {

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.

Suggested change
fnparse_select_distinct_parenthesized_wildcard(){
fnparse_select_parenthesized_wildcard(){

thinking since the syntax isn't implemented solely on the distinct keyword?

Comment threadsrc/parser/mod.rs Outdated
self.next_token(); // consume RParen
return Ok(Expr::Wildcard(AttachedToken(inner_token)));
}
// Not a (*), reset and fall through to parse_expr

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 looks incorrect per the comment, by reset should we have called prev_token() or similar to undo the consumed inner token *?

Comment threadsrc/parser/mod.rs Outdated
Comment on lines +1227 to +1228
let inner_token = self.next_token();
if inner_token.token == Token::Mul && self.peek_token().token == Token::RParen {

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.

can this be simplified by calling self.peek_tokens_ref(Token::MUL, Token::RParen)?

@romanoff

Copy link
Copy Markdown
Author

@iffyio Updated. Thank you for reviewing

Comment threadsrc/parser/mod.rs Outdated
Comment on lines +1233 to +1234
// Not a (*), fall through to reset index and call parse_expr
self.prev_token();

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.

calling self.prev_token() doesn't seem needed? similar to the _ branch, the fall-through paths call self.index = index; to reset at the end it looks like

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated

@romanoff
romanoffforce-pushed the allow_parsing_parenthesized_wildcard branch from fa70750 to 3732a4aCompareDecember 19, 2025 01:27

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

LGTM! Thanks @romanoff!

@iffyio
iffyio added this pull request to the merge queueDec 19, 2025
Merged via the queue into apache:main with commit 355a3bfDec 19, 2025
10 checks passed
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Feb 3, 2026
fmguerreiro pushed a commit to fmguerreiro/datafusion-sqlparser-rs that referenced this pull request Feb 20, 2026
Sign up for freeto 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.

2 participants

@romanoff@iffyio