-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix snapshot to always drop the staging table (#96)
### Description We introduced Delta constraints at #71 and now that snapshot query could fail when it's violating the constraints. In that case, the temporary view keeps existing because snapshot uses a permanent view and drop it later. We should always drop them.
- Loading branch information
Showing
4 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{# executes a query and explicitly drops the staging table. #} | ||
{% macro statement_with_staging_table(name=None, staging_table=None, fetch_result=False, auto_begin=True) -%} | ||
{%- if execute: -%} | ||
{%- set sql = caller() -%} | ||
|
||
{%- if name == 'main' -%} | ||
{{ log('Writing runtime SQL for node "{}"'.format(model['unique_id'])) }} | ||
{{ write(sql) }} | ||
{%- endif -%} | ||
|
||
{%- set res, table = adapter.execute(sql, auto_begin=auto_begin, fetch=fetch_result, staging_table=staging_table) -%} | ||
{%- if name is not none -%} | ||
{{ store_result(name, response=res, agate_table=table) }} | ||
{%- endif -%} | ||
|
||
{%- endif -%} | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters