Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle double dashes in BigQuery project names #3783

Open
erindru opened this issue Feb 4, 2025 · 4 comments
Open

Correctly handle double dashes in BigQuery project names #3783

erindru opened this issue Feb 4, 2025 · 4 comments
Assignees

Comments

@erindru
Copy link
Collaborator

erindru commented Feb 4, 2025

Currently, trying to specify a BigQuery project with dashes in it just produces errors trying to fetch column info.

Against our sqlmesh init example structure, with the following config:

gateways:
  bigquery:
    connection:
      type: bigquery
      project: "`arcx--dev`" #or project: "arcx--dev"

BigQuery produces errors like:

google.api_core.exceptions.Forbidden: 403 Access Denied: Table arcx:sqlmesh__sqlmesh_example.INFORMATION_SCHEMA.COLUMNS: User does not have permission to query table arcx:sqlmesh__sqlmesh_example.INFORMATION_SCHEMA.COLUMNS, or perhaps it does not exist.;

(notice SQLMesh tried arcx:sqlmesh__sqlmesh_example instead of arcx--dev:sqlmesh__sqlmesh_example)

Also, the proper catalog is clearly missing from the model names in the plan:

Image

@georgesittas georgesittas self-assigned this Feb 4, 2025
@georgesittas
Copy link
Contributor

I don't think using backticks there is the right syntax. Both project: foo-bar and project: "foo-bar" work as is for me. I'll go ahead and close this as a non-issue, but let me know if I missed something.

@tanghyd
Copy link

tanghyd commented Feb 4, 2025

I don't think using backticks there is the right syntax. Both project: foo-bar and project: "foo-bar" work as is for me. I'll go ahead and close this as a non-issue, but let me know if I missed something.

Have you tried project: "foo--bar"? The issue was specifically about double dashes.

@erindru erindru changed the title Correctly handle dashes in BigQuery project names Correctly handle double dashes in BigQuery project names Feb 5, 2025
@erindru erindru reopened this Feb 5, 2025
@erindru
Copy link
Collaborator Author

erindru commented Feb 5, 2025

@georgesittas -- is a SQL comment, right? I bet we aren't handling this properly somewhere.

For example, using exp.to_table without quoting correctly:

>>> from sqlglot import exp
>>> exp.to_table("foo--bar.baz.bing")
Table(
  this=Identifier(this=foo, quoted=False),
  _comments=[
    bar.baz.bing])

@georgesittas
Copy link
Contributor

Ah nice catch. I definitely missed this :)
Will fix shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants