-
Notifications
You must be signed in to change notification settings - Fork 15
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
Lift + shift for cross-db macros #25
Changes from all commits
2a329b7
b41d8b6
b63d6d4
b1e1022
d0f33a2
506f1bb
08aa4c5
c103b95
d5c7dbc
bcc00ed
3b7367e
c1e8d3d
8f01640
a943272
1dbafb6
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 |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
/**/dbt_packages/ | ||
/**/logs/ | ||
/**/env/ | ||
/**/__pycache__/ | ||
test.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: 'spark_utils' | ||
version: '0.3.0' | ||
config-version: 2 | ||
require-dbt-version: [">=1.0.0", "<2.0.0"] | ||
require-dbt-version: [">=1.2.0", "<2.0.0"] | ||
macro-paths: ["macros"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pytest | ||
pyodbc==4.0.32 | ||
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core | ||
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter | ||
git+https://github.com/dbt-labs/dbt-spark.git#egg=dbt-spark[ODBC] | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
select | ||
{{ dbt_utils.date_trunc('day', dbt_utils.current_timestamp()) }} as today |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro assert_not_null(function, arg) -%} | ||
{{ return(adapter.dispatch('assert_not_null', 'dbt')(function, arg)) }} | ||
{%- endmacro %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro spark__concat(fields) -%} | ||
{{ return(adapter.dispatch('concat', 'dbt')(fields)) }} | ||
{%- endmacro %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{# numeric ------------------------------------------------ #} | ||
|
||
{% macro spark__type_numeric() %} | ||
decimal(28, 6) | ||
{{ return(adapter.dispatch('type_numeric', 'dbt')()) }} | ||
{% endmacro %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% macro spark__dateadd(datepart, interval, from_date_or_timestamp) %} | ||
-- dispatch here gets very very confusing | ||
-- we just need to hint to dbt that this is a required macro for resolving dbt.spark__datediff() | ||
-- {{ assert_not_null() }} | ||
{{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }} | ||
{% endmacro %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% macro spark__datediff(first_date, second_date, datepart) %} | ||
-- dispatch here gets very very confusing | ||
-- we just need to hint to dbt that this is a required macro for resolving dbt.spark__datediff() | ||
-- {{ assert_not_null() }} | ||
{{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }} | ||
{% endmacro %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro spark__split_part(string_text, delimiter_text, part_number) %} | ||
{{ return(adapter.dispatch('split_part', 'dbt')(string_text, delimiter_text, part_number)) }} | ||
{% endmacro %} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[pytest] | ||
filterwarnings = | ||
ignore:.*'soft_unicode' has been renamed to 'soft_str'*:DeprecationWarning | ||
ignore:unclosed file .*:ResourceWarning | ||
env_files = | ||
test.env | ||
testpaths = | ||
tests/functional | ||
Comment on lines
+1
to
+8
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. Last Week I Learned (LWIL):
ExampleLet's say I have an environment variable defined locally: And By default, pytest-dotenv will keep the former and ignore the latter. Scroll down to see how to configure the opposite behavior. Override default behaviorSo it depending on how we want pytest + pytest-dotenv to behave, we either will want to include the following (or not!):
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. A great LWIL! This makes sense to me, insofar as I might have a
I would indeed expect the env var I've just supplied to override the one in |
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.
This is helpful!