Skip to content

Commit 4f92baa

Browse files
committed
Fix BigQuery hythenated ObjectName with numbers
1 parent 63245f6 commit 4f92baa

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/parser/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8747,7 +8747,9 @@ impl<'a> Parser<'a> {
87478747
}
87488748
Token::Number(s, false) if s.chars().all(|c| c.is_ascii_digit()) => {
87498749
ident.value.push_str(&s);
8750-
true
8750+
// If next token is period, then it is part of an ObjectName and we don't expect whitespace
8751+
// after the number.
8752+
!matches!(self.peek_token().token, Token::Period)
87518753
}
87528754
_ => {
87538755
return self

tests/sqlparser_bigquery.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,26 @@ fn parse_hyphenated_table_identifiers() {
15221522
"SELECT * FROM foo-bar AS f JOIN baz-qux AS b ON f.id = b.id",
15231523
);
15241524

1525+
assert_eq!(
1526+
bigquery()
1527+
.verified_only_select_with_canonical(
1528+
"select * from foo-123.bar",
1529+
"SELECT * FROM foo-123.bar"
1530+
)
1531+
.from[0]
1532+
.relation,
1533+
TableFactor::Table {
1534+
name: ObjectName(vec![Ident::new("foo-123"), Ident::new("bar")]),
1535+
alias: None,
1536+
args: None,
1537+
with_hints: vec![],
1538+
version: None,
1539+
partitions: vec![],
1540+
with_ordinality: false,
1541+
json_path: None,
1542+
}
1543+
);
1544+
15251545
assert_eq!(
15261546
bigquery()
15271547
.verified_only_select_with_canonical(

0 commit comments

Comments
 (0)