-
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
wrap models using macros #356
Merged
cmcarthur
merged 39 commits into
feature/schema-tests-defined-by-macros
from
kill-model-py
Apr 5, 2017
Merged
Changes from 8 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c591815
code cleanup + fix full-refresh opt
drewbanin 3d4d72d
make integration tests actually test flags
drewbanin f651568
accidently create operations
drewbanin e080f73
Handle concurrent `DROP ... CASCADE`s in Redshift (#349)
cmcarthur fe79e07
working with a few rough edges
da6c467
Fix/full refresh (#350)
drewbanin f94f455
Merge branch 'development' into feature/already-exists-compilation-co…
drewbanin 7f54175
test that should be green if macro parsing works the right way
23d42d2
wip
drewbanin cacf5c9
Merge branch 'feature/already-exists-compilation-context' into contex…
drewbanin b43be9e
validate macros don't use context vars
drewbanin ace4b49
fix tests
drewbanin bc0e1c2
working with a few rough edges
694d07b
test that should be green if macro parsing works the right way
c55ff34
inject into jinja with custom extension
drewbanin 8537229
wip
drewbanin 4846515
validate macros don't use context vars
drewbanin c06ae6d
fix tests
drewbanin e03f804
Merge branch 'contextless-macros' of github.com:fishtown-analytics/db…
drewbanin 2b3f46e
add test for `target` in macros, disallow target
drewbanin e2c279b
add license to RTD
drewbanin ce96825
wip - materialize via macros
drewbanin 5ffe4a5
always release connections at the end of execute_node (#354)
cmcarthur d907fca
merged development
ab4d5a3
tests passing
a266308
integration tests passing, again
e533b36
unit tests & pep8 passing
d3d2da5
merge contextless macros branch
cb2bba4
functional test tweaks
f1f39c1
remove extra raise
0b810c6
fix integration tests
4f663a0
allow global project macros to be referenced without a namespace
837bff4
handle compilation errors
0574958
add manifest file
drewbanin 1063500
include global project files in dbt dist
drewbanin 161d70c
Merge pull request #361 from fishtown-analytics/include-global-project
drewbanin 8b59748
rename funcs to adapter
b7044d9
remove compile task
2921a00
don't throw compilr error for this/target in macro
drewbanin 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
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import multiprocessing | ||
|
||
from dbt.adapters.postgres import PostgresAdapter | ||
from dbt.logger import GLOBAL_LOGGER as logger # noqa | ||
from dbt.compat import basestring | ||
|
||
|
||
drop_lock = multiprocessing.Lock() | ||
|
||
|
||
class RedshiftAdapter(PostgresAdapter): | ||
|
@@ -30,7 +36,7 @@ def sort_qualifier(cls, sort_type, sort): | |
.format(sort_type, valid_sort_types) | ||
) | ||
|
||
if type(sort) == str: | ||
if isinstance(sort, basestring): | ||
sort_keys = [sort] | ||
else: | ||
sort_keys = sort | ||
|
@@ -42,3 +48,28 @@ def sort_qualifier(cls, sort_type, sort): | |
return "{sort_type} sortkey({keys_csv})".format( | ||
sort_type=sort_type, keys_csv=keys_csv | ||
) | ||
|
||
@classmethod | ||
def drop(cls, profile, relation, relation_type, model_name=None): | ||
global drop_lock | ||
|
||
to_return = None | ||
|
||
try: | ||
drop_lock.acquire() | ||
|
||
connection = cls.get_connection(profile, model_name) | ||
|
||
cls.commit(connection) | ||
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. @cmcarthur is there any problem with committing if there is no open transaction? |
||
cls.begin(profile, connection.get('name')) | ||
|
||
to_return = super(PostgresAdapter, cls).drop( | ||
profile, relation, relation_type, model_name) | ||
|
||
cls.commit(connection) | ||
cls.begin(profile, connection.get('name')) | ||
|
||
return to_return | ||
|
||
finally: | ||
drop_lock.release() |
Oops, something went wrong.
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.
great catch