You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "romanoff (via GitHub)" <gi...@apache.org> on 2025/12/03 22:49:23 UTC
[PR] Support parsing parenthesized wildcard `(*)` [datafusion-sqlparser-rs]
romanoff opened a new pull request, #2123:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2123
Support parsing parenthesized wildcard `(*)`
Example of query:
```
SELECT DISTINCT (*) FROM table1
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support parsing parenthesized wildcard `(*)` [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #2123:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2123#discussion_r2606325817
##########
src/parser/mod.rs:
##########
@@ -1222,6 +1222,17 @@ impl<'a> Parser<'a> {
Token::Mul => {
return Ok(Expr::Wildcard(AttachedToken(next_token)));
}
+ // Handle parenthesized wildcard: (*)
+ Token::LParen => {
+ let [maybe_mul, maybe_rparen] = self.peek_tokens_ref();
+ if maybe_mul.token == Token::Mul && maybe_rparen.token == Token::RParen {
+ let mul_token = self.next_token(); // consume Mul
+ self.next_token(); // consume RParen
+ return Ok(Expr::Wildcard(AttachedToken(mul_token)));
+ }
+ // Not a (*), fall through to reset index and call parse_expr
+ self.prev_token();
Review Comment:
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support parsing parenthesized wildcard `(*)` [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #2123:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2123
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support parsing parenthesized wildcard `(*)` [datafusion-sqlparser-rs]
Posted by "romanoff (via GitHub)" <gi...@apache.org>.
romanoff commented on code in PR #2123:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2123#discussion_r2633243117
##########
src/parser/mod.rs:
##########
@@ -1222,6 +1222,17 @@ impl<'a> Parser<'a> {
Token::Mul => {
return Ok(Expr::Wildcard(AttachedToken(next_token)));
}
+ // Handle parenthesized wildcard: (*)
+ Token::LParen => {
+ let [maybe_mul, maybe_rparen] = self.peek_tokens_ref();
+ if maybe_mul.token == Token::Mul && maybe_rparen.token == Token::RParen {
+ let mul_token = self.next_token(); // consume Mul
+ self.next_token(); // consume RParen
+ return Ok(Expr::Wildcard(AttachedToken(mul_token)));
+ }
+ // Not a (*), fall through to reset index and call parse_expr
+ self.prev_token();
Review Comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support parsing parenthesized wildcard `(*)` [datafusion-sqlparser-rs]
Posted by "romanoff (via GitHub)" <gi...@apache.org>.
romanoff commented on PR #2123:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2123#issuecomment-3614888304
@iffyio Updated. Thank you for reviewing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Support parsing parenthesized wildcard `(*)` [datafusion-sqlparser-rs]
Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #2123:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2123#discussion_r2588286103
##########
src/parser/mod.rs:
##########
@@ -1222,6 +1222,15 @@ impl<'a> Parser<'a> {
Token::Mul => {
return Ok(Expr::Wildcard(AttachedToken(next_token)));
}
+ // Handle parenthesized wildcard: (*)
+ Token::LParen => {
+ let inner_token = self.next_token();
+ if inner_token.token == Token::Mul && self.peek_token().token == Token::RParen {
+ self.next_token(); // consume RParen
+ return Ok(Expr::Wildcard(AttachedToken(inner_token)));
+ }
+ // Not a (*), reset and fall through to parse_expr
Review Comment:
this looks incorrect per the comment, by reset should we have called `prev_token()` or similar to undo the consumed inner token `*`?
##########
tests/sqlparser_common.rs:
##########
@@ -17905,3 +17905,22 @@ fn test_parse_set_session_authorization() {
}))
);
}
+
+#[test]
+fn parse_select_distinct_parenthesized_wildcard() {
Review Comment:
```suggestion
fn parse_select_parenthesized_wildcard() {
```
thinking since the syntax isn't implemented solely on the distinct keyword?
##########
src/parser/mod.rs:
##########
@@ -1222,6 +1222,15 @@ impl<'a> Parser<'a> {
Token::Mul => {
return Ok(Expr::Wildcard(AttachedToken(next_token)));
}
+ // Handle parenthesized wildcard: (*)
+ Token::LParen => {
+ let inner_token = self.next_token();
+ if inner_token.token == Token::Mul && self.peek_token().token == Token::RParen {
Review Comment:
can this be simplified by calling `self.peek_tokens_ref(Token::MUL, Token::RParen)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org