Skip to content

Commit

Permalink
fix(bigquery): more table qualification edge cases closes #3083
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed Mar 5, 2024
1 parent aace4ad commit 8c4400b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlglot/dialects/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def _parse_table_parts(
if rest and this:
this = exp.Dot.build(t.cast(t.List[exp.Expression], [this, *rest]))

table = exp.Table(this=this, db=db, catalog=catalog)
table = exp.Table(this=this, db=db, catalog=catalog or table.args.get("db"))
table.meta["quoted_table"] = True

return table
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_bigquery(self):
self.assertEqual(table.name, "_y")

self.validate_identity("SELECT * FROM x-0.y")
self.assertEqual(exp.to_table("`x`.`y.z`", dialect="bigquery").sql(), '"x"."y"."z"')
self.assertEqual(exp.to_table("`x.y.z`", dialect="bigquery").sql(), '"x"."y"."z"')
self.assertEqual(exp.to_table("`x.y.z`", dialect="bigquery").sql("bigquery"), "`x.y.z`")
self.assertEqual(exp.to_table("`x`.`y`", dialect="bigquery").sql("bigquery"), "`x`.`y`")
Expand Down

0 comments on commit 8c4400b

Please sign in to comment.