Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Bump to 0.6.2 - Merge branch 'master' of https://github.com/Datavault…
Browse files Browse the repository at this point in the history
  • Loading branch information
Borna Almasi committed Sep 22, 2020
2 parents 325bd11 + 6bb0768 commit 2e50cd6
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 154 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
<img src="https://user-images.githubusercontent.com/25080503/65772647-89525700-e132-11e9-80ff-12ad30a25466.png">
</p>

[![Documentation Status](https://readthedocs.org/projects/dbtvault/badge/?version=stable)](https://dbtvault.readthedocs.io/en/latest/?badge=stable)
[![Join our Slack](https://img.shields.io/badge/Slack-Join-yellow?style=flat&logo=slack)](https://join.slack.com/t/dbtvault/shared_invite/enQtODY5MTY3OTIyMzg2LWJlZDMyNzM4YzAzYjgzYTY0MTMzNTNjN2EyZDRjOTljYjY0NDYyYzEwMTlhODMzNGY3MmU2ODNhYWUxYmM2NjA)
<p align="center">
<a href="https://dbtvault.readthedocs.io/en/latest/?badge=stable"><img
src="https://readthedocs.org/projects/dbtvault/badge/?version=stable"
alt="Documentation Status"
/></a>
<a href="https://join.slack.com/t/dbtvault/shared_invite/enQtODY5MTY3OTIyMzg2LWJlZDMyNzM4YzAzYjgzYTY0MTMzNTNjN2EyZDRjOTljYjY0NDYyYzEwMTlhODMzNGY3MmU2ODNhYWUxYmM2NjA"><img
src="https://img.shields.io/badge/Slack-Join-yellow?style=flat&logo=slack"
alt="Join our slack"
/></a>

</p>


[Changelog and past doc versions](https://dbtvault.readthedocs.io/en/latest/changelog/stable)
Expand Down Expand Up @@ -35,20 +44,20 @@ Learn quickly with our worked example:

## Installation

Add the following to your ```packages.yml```
Add the following to your `packages.yml`


```yaml
packages:

- git: "https://github.com/Datavault-UK/dbtvault"
revision: v0.6 # Latest stable version
revision: v0.6.2 # Latest stable version
```
And run
```dbt deps```
`dbt deps`

[Read more on package installation](https://docs.getdbt.com/v0.15.0/docs/package-management)
[Read more on package installation](https://docs.getdbt.com/docs/building-a-dbt-project/package-management/#git-packages)

## Usage

Expand Down
8 changes: 4 additions & 4 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: 'dbtvault'
version: '0.6'
require-dbt-version: [">=0.14.0", "<=0.18.0"]

profile: 'dev'
version: '0.6.2'
require-dbt-version: [">=0.14.0", "<=0.18.0"]

source-paths: ["models"]
analysis-paths: ["analysis"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
docs-paths: ["docs"]

target-path: "target"
clean-targets:
Expand Down
24 changes: 15 additions & 9 deletions macros/internal/alias.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@
See the License for the specific language governing permissions and
limitations under the License.
-#}
{%- macro alias(source_column=none, prefix=none) -%}
{%- macro alias(alias_config=none, prefix=none) -%}

{%- if source_column -%}
{{- adapter_macro('dbtvault.alias', alias_config=alias_config, prefix=prefix) -}}

{%- if source_column is iterable and source_column is not string -%}
{%- endmacro %}

{%- if source_column['source_column'] and source_column['alias'] -%}
{%- macro default__alias(alias_config=none, prefix=none) -%}

{%- if alias_config -%}

{%- if alias_config is iterable and alias_config is not string -%}

{%- if alias_config['source_column'] and alias_config['alias'] -%}

{%- if prefix -%}
{{prefix}}.{{ source_column['source_column'] }} AS {{ source_column['alias'] }}
{{prefix}}.{{ alias_config['source_column'] }} AS {{ alias_config['alias'] }}
{%- else -%}
{{ source_column['source_column'] }} AS {{ source_column['alias'] }}
{{ alias_config['source_column'] }} AS {{ alias_config['alias'] }}
{%- endif -%}

{%- endif -%}
Expand All @@ -30,11 +36,11 @@

{%- if prefix -%}

{{- dbtvault.prefix([source_column], prefix) -}}
{{- dbtvault.prefix([alias_config], prefix) -}}

{%- else -%}

{{ source_column }}
{{ alias_config }}

{%- endif -%}

Expand All @@ -44,7 +50,7 @@

{%- if execute -%}

{{ exceptions.raise_compiler_error("Invalid alias configuration:\nexpected format: {source_column: 'column', alias: 'column_alias'}\ngot: " ~ source_column) }}
{{ exceptions.raise_compiler_error("Invalid alias configuration:\nexpected format: {source_column: 'column', alias: 'column_alias'}\ngot: " ~ alias_config) }}

{%- endif -%}

Expand Down
10 changes: 8 additions & 2 deletions macros/internal/alias_all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
See the License for the specific language governing permissions and
limitations under the License.
-#}
{%- macro alias_all(columns, prefix) -%}
{%- macro alias_all(columns=none, prefix=none) -%}

{{- adapter_macro('dbtvault.alias_all', columns=columns, prefix=prefix) -}}

{%- endmacro %}

{%- macro default__alias_all(columns, prefix) -%}

{%- if columns is iterable and columns is not string -%}

{%- for column in columns -%}
{{ dbtvault.alias(column, prefix) }}
{{ dbtvault.alias(alias_config=column, prefix=prefix) }}
{%- if not loop.last -%} , {% endif -%}
{%- endfor -%}

Expand Down
8 changes: 7 additions & 1 deletion macros/internal/as_constant.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-#}
{%- macro as_constant(column_str) -%}
{%- macro as_constant(column_str=none) -%}

{{- adapter_macro('dbtvault.as_constant', column_str=column_str) -}}

{%- endmacro %}

{%- macro default__as_constant(column_str) -%}

{% if column_str is not none %}

Expand Down
22 changes: 0 additions & 22 deletions macros/internal/check_relation.sql

This file was deleted.

32 changes: 14 additions & 18 deletions macros/internal/multikey.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,38 @@
See the License for the specific language governing permissions and
limitations under the License.
-#}
{%- macro multikey(columns=none, aliases=none, type_for=none) -%}

{%- macro multikey(columns, aliases, type_for) -%}
{{- adapter_macro('dbtvault.multikey', columns=columns, aliases=aliases, type_for=type_for) -}}

{%- endmacro %}

{%- macro default__multikey(columns, aliases, type_for) -%}

{% if type_for == 'join' %}

{% for col in columns if not columns is string %}
{% if loop.index == columns|length %}
{{ dbtvault.prefix([col], aliases[0]) }} = {{ dbtvault.prefix([col], aliases[1]) }}
{% else %}
{{ dbtvault.prefix([col], aliases[0]) }} = {{ dbtvault.prefix([col], aliases[1]) }} AND
{% endif %}
{{ dbtvault.prefix([col], aliases[0]) }} = {{ dbtvault.prefix([col], aliases[1]) }}
{% if not loop.last %} AND {% endif %}
{% else %}
{{ dbtvault.prefix([columns], aliases[0]) }} = {{ dbtvault.prefix([columns], aliases[1]) }}
{% endfor %}

{% elif type_for == 'where null'%}
{% elif type_for == 'where null' %}

{% for col in columns if not columns is string %}
{% if loop.index == columns|length %}
{{ dbtvault.prefix([col], aliases[0]) }} IS NULL
{% else %}
{{ dbtvault.prefix([col], aliases[0]) }} IS NULL AND
{% endif %}
{{ dbtvault.prefix([col], aliases[0]) }} IS NULL
{% if not loop.last %} AND {% endif %}
{% else %}
{{ dbtvault.prefix([columns], aliases[0]) }} IS NULL
{% endfor %}

{% elif type_for == 'where not null'%}

{% for col in columns if not columns is string %}
{% if loop.index == columns|length %}
{{ dbtvault.prefix([col], aliases[0]) }} IS NOT NULL
{% else %}
{{ dbtvault.prefix([col], aliases[0]) }} IS NOT NULL AND
{% endif %}
{% else %}
{{ dbtvault.prefix([col], aliases[0]) }} IS NOT NULL
{% if not loop.last %} AND {% endif %}
{% else %}
{{ dbtvault.prefix([columns], aliases[0]) }} IS NOT NULL
{% endfor %}
{% endif %}
Expand Down
7 changes: 6 additions & 1 deletion macros/staging/derive_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-#}

{%- macro derive_columns(source_relation=none, columns=none) -%}

{{- adapter_macro('dbtvault.derive_columns', source_relation=source_relation, columns=columns) -}}

{%- endmacro %}

{%- macro default__derive_columns(source_relation=none, columns=none) -%}

{%- set exclude_columns = [] -%}
{%- set include_columns = [] -%}

Expand Down
14 changes: 7 additions & 7 deletions macros/staging/hash_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
{%- macro hash_columns(columns=none, hash_algo=none) -%}
{#-
Hashes a the values of given list of columns using the provided hash algorithm

Args:
columns {Mapping[str, Union[str, Mapping]} - Column names to hash. Either a string or a mapping with
columns {Mapping[str, Union[str, Mapping]} - Column names to hash. Either a string or a mapping with
a boolean value at the "hashdiff" key and a list of column names as the "columns" key (see example)
hash_algo: str - The identifier of the hashing algorithm to use.

Expand All @@ -36,7 +36,7 @@

Example 2:

if columns is
if columns is

{
EXAMPLE_HK: {
Expand All @@ -46,19 +46,19 @@
}

the resulting output will have columns

EXAMPLE_HK = HASH(A||B||C)


-#}
{%- if columns is mapping -%}
{%- for output_col in columns -%}

{%- set src_col_config = columns[output_col] -%}
{%- set is_hashdiff = src_col_config['hashdiff'] -%}
{%-
if
execute
if
execute
and is_hashdiff is not defined
and src_col_config['columns'] is defined
and src_col_config['columns'] is iterable
Expand Down
64 changes: 0 additions & 64 deletions macros/supporting/cast.sql

This file was deleted.

1 change: 0 additions & 1 deletion macros/supporting/hash.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
limitations under the License.
#}


{%- macro _standardize_hash_input(expr, output_str_if_null='^^') -%}
{#-
Casts any field into a standardized string to prepare for hashing
Expand Down
11 changes: 9 additions & 2 deletions macros/supporting/prefix.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
limitations under the License.
-#}

{%- macro prefix(columns=none, prefix_str=none, alias_target='source') -%}
{%- macro prefix(columns, prefix_str, alias_target) -%}

{{- adapter_macro('dbtvault.prefix', columns=columns, prefix_str=prefix_str, alias_target=alias_target) -}}

{%- endmacro -%}

{%- macro default__prefix(columns=none, prefix_str=none, alias_target='source') -%}

{%- if columns and prefix_str -%}

Expand Down Expand Up @@ -42,8 +48,9 @@
{{- dbtvault.prefix(col, prefix_str) -}}

{%- elif col is not none -%}

{{- prefix_str}}.{{col.strip() -}}
{% else %}
{% else %}

{%- if execute -%}
{{- exceptions.raise_compiler_error("Unexpected or missing configuration for '" ~ this ~ "' Unable to prefix columns.") -}}
Expand Down
Loading

0 comments on commit 2e50cd6

Please sign in to comment.