-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
re adds the dbt compile command #407
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
04c327c
re adds the dbt compile command
eogilvy12 73c64b9
clean up connections + run fewer introspective queries
eogilvy12 b10ac0c
compile analysis files
eogilvy12 63b7f37
pep8
eogilvy12 e02d470
don't use FileExistsError -- added in py3.3
eogilvy12 f5dcb10
Merge branch 'development' into re-add-compile-command
eogilvy12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
46 changes: 26 additions & 20 deletions
46
dbt/include/global_project/macros/materializations/table.sql
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 |
---|---|---|
@@ -1,32 +1,38 @@ | ||
|
||
{% macro dbt__simple_create_table(schema, identifier, dist, sort, sql) -%} | ||
create table "{{ schema }}"."{{ identifier }}" | ||
{{ dist }} {{ sort }} as ( | ||
{{ sql }} | ||
); | ||
{%- endmacro %} | ||
|
||
{% macro dbt__create_table(schema, model, dist, sort, sql, flags, adapter) -%} | ||
|
||
{%- set identifier = model['name'] -%} | ||
{%- set already_exists = adapter.already_exists(schema, identifier) -%} | ||
{%- set non_destructive_mode = flags.NON_DESTRUCTIVE == True -%} | ||
|
||
{% if non_destructive_mode and already_exists -%} | ||
create temporary table {{ identifier }}__dbt_tmp {{ dist }} {{ sort }} as ( | ||
{{ sql }} | ||
); | ||
{% if non_destructive_mode -%} | ||
{%- if adapter.already_exists(schema, identifier) -%} | ||
create temporary table {{ identifier }}__dbt_tmp {{ dist }} {{ sort }} as ( | ||
{{ sql }} | ||
); | ||
|
||
{% set dest_columns = adapter.get_columns_in_table(schema, identifier) %} | ||
{% set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') %} | ||
{% set dest_columns = adapter.get_columns_in_table(schema, identifier) %} | ||
{% set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') %} | ||
|
||
insert into {{ schema }}.{{ identifier }} ({{ dest_cols_csv }}) | ||
( | ||
select {{ dest_cols_csv }} | ||
from "{{ identifier }}__dbt_tmp" | ||
); | ||
insert into {{ schema }}.{{ identifier }} ({{ dest_cols_csv }}) | ||
( | ||
select {{ dest_cols_csv }} | ||
from "{{ identifier }}__dbt_tmp" | ||
); | ||
{%- else -%} | ||
{{ dbt__simple_create_table(schema, identifier, dist, sort, sql) }} | ||
{%- endif -%} | ||
{%- elif non_destructive_mode -%} | ||
create table "{{ schema }}"."{{ identifier }}" | ||
{{ dist }} {{ sort }} as ( | ||
{{ sql }} | ||
); | ||
{{ dbt__simple_create_table(schema, identifier, dist, sort, sql) }} | ||
{%- else -%} | ||
create table "{{ schema }}"."{{ identifier }}__dbt_tmp" | ||
{{ dist }} {{ sort }} as ( | ||
{{ sql }} | ||
); | ||
{% set tmp_identifier = identifier + '__dbt_tmp' %} | ||
{{ dbt__simple_create_table(schema, tmp_identifier, dist, sort, sql) }} | ||
{%- 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
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
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,19 @@ | ||
from __future__ import print_function | ||
|
||
from dbt.logger import GLOBAL_LOGGER as logger | ||
from dbt.runner import RunManager | ||
|
||
|
||
class CompileTask: | ||
def __init__(self, args, project): | ||
self.args = args | ||
self.project = project | ||
|
||
def run(self): | ||
runner = RunManager( | ||
self.project, self.project['target-path'], self.args | ||
) | ||
|
||
runner.compile_models(self.args.models, self.args.exclude) | ||
|
||
logger.info('Done.') |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍