-
Notifications
You must be signed in to change notification settings - Fork 100
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
feat: Allow different schema for tmp tables created during table materialization #664
base: main
Are you sure you want to change the base?
feat: Allow different schema for tmp tables created during table materialization #664
Conversation
@pierrebzl is this ready for review? If so we can move it from the draft state, and I can start to review it. |
Yes, sorry I was away for the past 2 weeks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the feature seems to be pretty useful. Pls review my comments regarding code style and all materialisation types
functional test seems to be failed, pls take a look there |
{%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%} | ||
{%- set old_tmp_relation = adapter.get_relation(identifier=identifier ~ '__ha', | ||
schema=schema, | ||
database=database) -%} | ||
{%- if temp_schema is not none and old_tmp_relation is not none-%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully get this check, why do you need to include a check for old_tmp_relation not being none here? If old_tmp_relation is none, we still want to create the new tmp table in the tmp schema.
@@ -36,6 +36,14 @@ | |||
{%- endcall %} | |||
{%- endmacro %} | |||
|
|||
{% macro set_table_relation_schema(relation, schema) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add some comments to this method?
{% macro set_table_relation_schema(relation, schema) %} | ||
{%- if temp_schema is not none -%} | ||
{%- set relation = relation.incorporate(path={"schema": schema}) -%} | ||
{%- do create_schema(relation) -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% convinced by this. pretty_much create_schema will be called by every model where we setup the temp_schema. It will be good too find a a better way to handle that.
@@ -36,6 +36,14 @@ | |||
{%- endcall %} | |||
{%- endmacro %} | |||
|
|||
{% macro set_table_relation_schema(relation, schema) %} | |||
{%- if temp_schema is not none -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{%- if temp_schema is not none -%} | |
{%- if schema is not none -%} |
or could you explain how do you get temp_schema here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of of all thanks for the contribution, I left some comments, please have a look.
Also, I would like to know if this feature works also for hive tables with ha=true, maybe consider to add a test for those, and be sure to include them in the implementation.
Description
As described in #662, this intend to extend
temp_schema
option table materialization that requires to create transient temporary tables.After this PR, with
temp_schema
set on all your models that use table maaterialization, you should not see any tmp tables created inside model target schemas.Models used to test - Optional
Checklist