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

Project fails to load when model names contain backticks, asterisk or quotes #3

Open
giovannipcarvalho opened this issue Sep 25, 2024 · 1 comment

Comments

@giovannipcarvalho
Copy link
Contributor

giovannipcarvalho commented Sep 25, 2024

First of all, thanks for tackling this integration. This is huge!

--

I'm trying it out with our sqlmesh project and it fails due to some of our (external) models having unusual naming.

The external model is actually a set of tables named:

  • analytics_12345.events_20240925
  • analytics_12345.events_20240926
  • ...

So far, nothing unusual here, but to facilitate local development we mock these tables as a single table in duckdb. And to make our external-model schema work in both cases (multiple tables in bigquery vs a single table in duckdb), we declare it as:

# file: external_models/bigquery_ga4_export_schema.yaml
- name: 'analytics_12345.`events_*`'
  columns:
[...] 

(The table in duckdb actually contains an * in its name, and not as a wildcard.)

That's when things get messy (we also had trouble with sqlmesh initially, but it now supports these).

In short, our external models contain backticks, stars and quotes (when normalized by sqlmesh).

I've checked that replacing these extra characters makes our project load just fine. I'm happy to contribute a patch, but first would like to know how you'd want these handled. Just naively adding more string replacements to sqlmesh_model_name_to_key and key_to_sqlmesh_model_name seems like a recipe for disaster.

--

Error message:

dagster._core.errors.DagsterInvalidDefinitionError: "analytics_12345_dot__`events_*`" is not a valid name in Dagster. Names must be in regex ^[A-Za-z0-9_]+$.
@giovannipcarvalho giovannipcarvalho changed the title Project fails to load when models have names containing backticks, asterisk or quotes Project fails to load when models names contain backticks, asterisk or quotes Sep 25, 2024
@giovannipcarvalho giovannipcarvalho changed the title Project fails to load when models names contain backticks, asterisk or quotes Project fails to load when model names contain backticks, asterisk or quotes Sep 25, 2024
@ravenac95
Copy link
Member

@giovannipcarvalho apologies for a very delayed response! I've been so heads down writing things around our own sqlmesh configuration that I didn't notice my notification for an issue on this repository. This is definitely an interestiong problem! I'll have to ponder this one.

Thanks so much for the issue 😄

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

2 participants