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

Don't create temp tables at plan time unless they're actually needed #2496

Closed
georgesittas opened this issue Apr 23, 2024 · 1 comment · Fixed by #3258
Closed

Don't create temp tables at plan time unless they're actually needed #2496

georgesittas opened this issue Apr 23, 2024 · 1 comment · Fixed by #3258
Labels
Improvement Improves existing functionality

Comments

@georgesittas
Copy link
Contributor

georgesittas commented Apr 23, 2024

We currently create temporary tables at plan time preemptively, even though they may not necessarily be needed. This behavior was introduced before we started to create tables on demand (i.e., if they're missing), but we can move away from it now.

For instance, the initial plan application for the example project produces the following tables in duckdb:

CREATE TABLE sqlmesh__sqlmesh_example.sqlmesh_example__full_model__3031530868(item_id INTEGER, num_orders BIGINT);
CREATE TABLE sqlmesh__sqlmesh_example.sqlmesh_example__full_model__3031530868__temp(item_id INTEGER, num_orders BIGINT);
CREATE TABLE sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__141311533(id INTEGER, item_id INTEGER, event_date DATE);
CREATE TABLE sqlmesh__sqlmesh_example.sqlmesh_example__incremental_model__141311533__temp(id INTEGER, item_id INTEGER, event_date DATE);
CREATE TABLE sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__1248844913(id INTEGER, item_id INTEGER, event_date DATE);
CREATE TABLE sqlmesh__sqlmesh_example.sqlmesh_example__seed_model__1248844913__temp(id INTEGER, item_id INTEGER, event_date DATE);
@georgesittas georgesittas added the Improvement Improves existing functionality label Apr 23, 2024
@erindru
Copy link
Collaborator

erindru commented Jul 2, 2024

This would also help with having less tables for the janitor to clean up.

Recent changes have made the actual snapshot deployability available in the strategy create() method (previously, only a doctored DeployabilityIndex was available that always returned "not deployable").

So we could use this to skip creating the dev preview ("__temp") tables if the snapshot being created is deployable

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