This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 355a3bfd Support parsing parenthesized wildcard `(*)` (#2123)
355a3bfd is described below
commit 355a3bfd90a43c9cda04f578827d353d8dac04c8
Author: Andriy Romanov <[email protected]>
AuthorDate: Thu Dec 18 20:09:33 2025 -0800
Support parsing parenthesized wildcard `(*)` (#2123)
---
src/parser/mod.rs | 9 +++++++++
tests/sqlparser_common.rs | 19 +++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 74b06ec8..d1c4fe05 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -1268,6 +1268,15 @@ 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)));
+ }
+ }
_ => (),
};
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index da8e7b49..9f549e4d 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -17953,3 +17953,22 @@ fn test_parse_set_session_authorization() {
}))
);
}
+
+#[test]
+fn parse_select_parenthesized_wildcard() {
+ // Test SELECT DISTINCT(*) which uses a parenthesized wildcard
+ // The parentheses are syntactic sugar and get normalized to just *
+ let sql = "SELECT DISTINCT (*) FROM table1";
+ let canonical = "SELECT DISTINCT * FROM table1";
+ let select = all_dialects().verified_only_select_with_canonical(sql,
canonical);
+ assert_eq!(select.distinct, Some(Distinct::Distinct));
+ assert_eq!(select.projection.len(), 1);
+ assert!(matches!(select.projection[0], SelectItem::Wildcard(_)));
+
+ // Also test without spaces: SELECT DISTINCT(*)
+ let sql_no_spaces = "SELECT DISTINCT(*) FROM table1";
+ let select2 =
all_dialects().verified_only_select_with_canonical(sql_no_spaces, canonical);
+ assert_eq!(select2.distinct, Some(Distinct::Distinct));
+ assert_eq!(select2.projection.len(), 1);
+ assert!(matches!(select2.projection[0], SelectItem::Wildcard(_)));
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]