-
Notifications
You must be signed in to change notification settings - Fork 377
Feat!: Create physical tables as part of evaluation #5189
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
Changes from 20 commits
81581a5
727103b
79869df
f4326da
1262d1a
8ace714
d3717b3
3a5953d
d5e5acc
2cca48f
7effa65
ea49c00
608bd46
088c38c
8dadf8b
58f5f9d
e139601
3317c3a
6336f43
76aff43
9f60b52
4e5d28f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| MODEL ( | ||
| name bronze.a | ||
| name bronze.a, | ||
| kind FULL | ||
| ); | ||
|
|
||
| SELECT | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| MODEL ( | ||
| name bronze.b | ||
| name bronze.b, | ||
| kind FULL | ||
| ); | ||
|
|
||
| SELECT | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| MODEL ( | ||
| name silver.c | ||
| name silver.c, | ||
| kind FULL | ||
| ); | ||
|
|
||
| SELECT DISTINCT col_a | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| MODEL ( | ||
| name silver.d | ||
| name silver.d, | ||
| kind FULL | ||
| ); | ||
|
|
||
| SELECT | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| MODEL ( | ||
| name silver.e | ||
| name silver.e, | ||
| kind FULL | ||
| ); | ||
|
|
||
| SELECT | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -443,14 +443,20 @@ def replace_query( | |
| target_table=target_table, | ||
| source_columns=source_columns, | ||
| ) | ||
| if not target_columns_to_types and table_exists: | ||
| target_columns_to_types = self.columns(target_table) | ||
| query = source_queries[0].query_factory() | ||
| target_columns_to_types = target_columns_to_types or self.columns(target_table) | ||
| self_referencing = any( | ||
| quote_identifiers(table) == quote_identifiers(target_table) | ||
| for table in query.find_all(exp.Table) | ||
| ) | ||
| # If a query references itself then it must have a table created regardless of approach used. | ||
| if self_referencing: | ||
| if not target_columns_to_types: | ||
| raise SQLMeshError( | ||
| f"Cannot create a self-referencing table {target_table.sql(dialect=self.dialect)} without knowing the column types. " | ||
| "Try casting the columns to an expected type or defining the columns in the model metadata. " | ||
| ) | ||
| self._create_table_from_columns( | ||
| target_table, | ||
| target_columns_to_types, | ||
|
|
@@ -472,6 +478,7 @@ def replace_query( | |
| **kwargs, | ||
| ) | ||
| if self_referencing: | ||
| assert target_columns_to_types is not None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be an explicit check?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just sharing this thread for some more context.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have an explicit check for this on line 455. This is our 2nd entry into the |
||
| with self.temp_table( | ||
| self._select_columns(target_columns_to_types).from_(target_table), | ||
| name=target_table, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.