Skip to content

Commit 68f4519

Browse files
committed
Also support ALL AS for BigQuery
This does, similar to regular `ALL`, not store that state on the `Select` struct so it's not tested as a `verified_stmt`.
1 parent 6a774da commit 68f4519

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/parser/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11514,7 +11514,9 @@ impl<'a> Parser<'a> {
1151411514
} else {
1151511515
self.expected("VALUE or STRUCT", self.peek_token())?
1151611516
}
11517-
} else if self.parse_keyword(Keyword::AS) {
11517+
} else if self.parse_keyword(Keyword::AS)
11518+
|| self.parse_keywords(&[Keyword::ALL, Keyword::AS])
11519+
{
1151811520
if self.parse_keyword(Keyword::VALUE) {
1151911521
Some(ValueTableMode::AsValue)
1152011522
} else if self.parse_keyword(Keyword::STRUCT) {

tests/sqlparser_bigquery.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2379,12 +2379,19 @@ fn test_any_type_dont_break_custom_type() {
23792379
}
23802380

23812381
#[test]
2382-
fn test_select_distinct_as_struct_or_value() {
2382+
fn test_select_distinct_or_all_as_struct_or_value() {
23832383
for sql in [
23842384
"SELECT DISTINCT AS STRUCT a, ABS(b) FROM UNNEST(c) AS T",
23852385
"SELECT DISTINCT AS VALUE a, ABS(b) FROM UNNEST(c) AS T",
23862386
"SELECT ARRAY(SELECT DISTINCT AS STRUCT a, b, ABS(c) AS c, ABS(d) AS d FROM UNNEST(e) AS T)",
23872387
] {
23882388
bigquery().verified_stmt(sql);
23892389
}
2390+
2391+
for sql in [
2392+
"SELECT ALL AS STRUCT a, ABS(b) FROM UNNEST(c) AS T",
2393+
"SELECT ALL AS VALUE a, ABS(b) FROM UNNEST(c) AS T",
2394+
] {
2395+
assert!(bigquery().parse_sql_statements(sql).is_ok());
2396+
}
23902397
}

0 commit comments

Comments
 (0)