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

More explicit errors on string literal usage of model definitions #3517

Closed
Ben-Epstein opened this issue Dec 14, 2024 · 0 comments · Fixed by #3534
Closed

More explicit errors on string literal usage of model definitions #3517

Ben-Epstein opened this issue Dec 14, 2024 · 0 comments · Fixed by #3534
Labels
Improvement Improves existing functionality

Comments

@Ben-Epstein
Copy link

Coming out of this discussion: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1734109818343679

It would be really helpful to have more explicit errors on single quote usage (string literals) in sql models, as the arising errors from misuse are very confusing.

Case 1

I had 2 sql models defined, one as

MODEL (
    name sqlmesh_example.runescape_mapping,
    ...

and the other as

MODEL (
    name 'sqlmesh_example.hourly_scrape'
    ...

and was getting the error

❯ uv run sqlmesh plan dev
2024-12-13 12:08:32,038 - MainThread - sqlmesh.core.loader - ERROR - SQLMesh requires all model names and references to have the same level of nesting. (loader.py:634)
Error: Table "db"."sqlmesh_example"."runescape_mapping" must match the schema's nesting level: 1.

The issue was the single quotes breaking the schema's nest level (one dot) but that was really difficult to debug

Use case 2

In that model, the kind was defined as

MODEL (
    name sqlmesh_example.hourly_scrape,
    kind INCREMENTAL_BY_TIME_RANGE (
        time_column 'ts'
    ),
    -- kind FULL,
    start '2024-12-12',
    cron '@hourly',
    grain (item_id, ts),
...

with the time column defined in single quotes. On running, I was getting the error

duckdb.duckdb.ConversionException: Conversion Error: timestamp field value out of range: "ts", expected format is (YYYY-MM-DD 
HH:MM:SS[.US][±HH:MM| ZONE])
LINE 1: ...ample__hourly_scrape__189843799" where 'ts' >= TIMESTAMP '2024-12-12 00:00:00+...

I changed the model kind to FULL and stopped getting the error, but it was unclear that the issue was simply that the timestamp column was literally 'ts'.

Thank you!

@georgesittas georgesittas added the Improvement Improves existing functionality label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improves existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants