File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -1268,6 +1268,15 @@ impl<'a> Parser<'a> {
12681268 Token::Mul => {
12691269 return Ok(Expr::Wildcard(AttachedToken(next_token)));
12701270 }
1271+ // Handle parenthesized wildcard: (*)
1272+ Token::LParen => {
1273+ let [maybe_mul, maybe_rparen] = self.peek_tokens_ref();
1274+ if maybe_mul.token == Token::Mul && maybe_rparen.token == Token::RParen {
1275+ let mul_token = self.next_token(); // consume Mul
1276+ self.next_token(); // consume RParen
1277+ return Ok(Expr::Wildcard(AttachedToken(mul_token)));
1278+ }
1279+ }
12711280 _ => (),
12721281 };
12731282
Original file line number Diff line number Diff line change @@ -17979,3 +17979,22 @@ fn test_parse_set_session_authorization() {
1797917979 }))
1798017980 );
1798117981}
17982+
17983+ #[test]
17984+ fn parse_select_parenthesized_wildcard() {
17985+ // Test SELECT DISTINCT(*) which uses a parenthesized wildcard
17986+ // The parentheses are syntactic sugar and get normalized to just *
17987+ let sql = "SELECT DISTINCT (*) FROM table1";
17988+ let canonical = "SELECT DISTINCT * FROM table1";
17989+ let select = all_dialects().verified_only_select_with_canonical(sql, canonical);
17990+ assert_eq!(select.distinct, Some(Distinct::Distinct));
17991+ assert_eq!(select.projection.len(), 1);
17992+ assert!(matches!(select.projection[0], SelectItem::Wildcard(_)));
17993+
17994+ // Also test without spaces: SELECT DISTINCT(*)
17995+ let sql_no_spaces = "SELECT DISTINCT(*) FROM table1";
17996+ let select2 = all_dialects().verified_only_select_with_canonical(sql_no_spaces, canonical);
17997+ assert_eq!(select2.distinct, Some(Distinct::Distinct));
17998+ assert_eq!(select2.projection.len(), 1);
17999+ assert!(matches!(select2.projection[0], SelectItem::Wildcard(_)));
18000+ }
You can’t perform that action at this time.
0 commit comments