Skip to content

Commit

Permalink
Fix BigQuery hythenated ObjectName with numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ayman-sigma committed Dec 12, 2024
1 parent 63245f6 commit 4f92baa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8747,7 +8747,9 @@ impl<'a> Parser<'a> {
}
Token::Number(s, false) if s.chars().all(|c| c.is_ascii_digit()) => {
ident.value.push_str(&s);
true
// If next token is period, then it is part of an ObjectName and we don't expect whitespace
// after the number.
!matches!(self.peek_token().token, Token::Period)
}
_ => {
return self
Expand Down
20 changes: 20 additions & 0 deletions tests/sqlparser_bigquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,26 @@ fn parse_hyphenated_table_identifiers() {
"SELECT * FROM foo-bar AS f JOIN baz-qux AS b ON f.id = b.id",
);

assert_eq!(
bigquery()
.verified_only_select_with_canonical(
"select * from foo-123.bar",
"SELECT * FROM foo-123.bar"
)
.from[0]
.relation,
TableFactor::Table {
name: ObjectName(vec![Ident::new("foo-123"), Ident::new("bar")]),
alias: None,
args: None,
with_hints: vec![],
version: None,
partitions: vec![],
with_ordinality: false,
json_path: None,
}
);

assert_eq!(
bigquery()
.verified_only_select_with_canonical(
Expand Down

0 comments on commit 4f92baa

Please sign in to comment.