Skip to content
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

Drop fivetran_utils by copying code. #97

Merged
merged 1 commit into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ Third party Apache 2.0 licenses
The following files contain signifant parts of code licensed under third party Apache 2.0 License.

macros/public/validating/regex_dict.sql
macros/utils/fivetran_utils/percentile.sql
macros/utils/fivetran_utils/json_extract.sql


40 changes: 40 additions & 0 deletions macros/utils/fivetran_utils/json_extract.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{#
# This file contains significant part of code derived from
# https://github.com/fivetran/dbt_fivetran_utils/tree/v0.4.0 which is licensed under Apache License 2.0.
#}

{% macro json_extract(string, string_path) -%}

{{ adapter.dispatch('json_extract') (string, string_path) }}

{%- endmacro %}

{% macro default__json_extract(string, string_path) %}

json_extract_path_text({{string}}, {{ "'" ~ string_path ~ "'" }} )

{% endmacro %}

{% macro snowflake__json_extract(string, string_path) %}

json_extract_path_text(try_parse_json( {{string}} ), {{ "'" ~ string_path ~ "'" }} )

{% endmacro %}

{% macro redshift__json_extract(string, string_path) %}

case when is_valid_json( {{string}} ) then json_extract_path_text({{string}}, {{ "'" ~ string_path ~ "'" }} ) else null end

{% endmacro %}

{% macro bigquery__json_extract(string, string_path) %}

json_extract_scalar({{string}}, {{ "'$." ~ string_path ~ "'" }} )

{% endmacro %}

{% macro postgres__json_extract(string, string_path) %}

{{string}}::json->>{{"'" ~ string_path ~ "'" }}

{% endmacro %}
60 changes: 60 additions & 0 deletions macros/utils/fivetran_utils/percentile.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{#
# This file contains significant part of code derived from
# https://github.com/fivetran/dbt_fivetran_utils/tree/v0.4.0 which is licensed under Apache License 2.0.
#}

{% macro percentile(percentile_field, partition_field, percent) -%}

{{ adapter.dispatch('percentile') (percentile_field, partition_field, percent) }}

{%- endmacro %}

--percentile calculation specific to Redshift
{% macro default__percentile(percentile_field, partition_field, percent) %}

percentile_cont(
{{ percent }} )
within group ( order by {{ percentile_field }} )
over ( partition by {{ partition_field }} )

{% endmacro %}

--percentile calculation specific to Redshift
{% macro redshift__percentile(percentile_field, partition_field, percent) %}

percentile_cont(
{{ percent }} )
within group ( order by {{ percentile_field }} )
over ( partition by {{ partition_field }} )

{% endmacro %}

--percentile calculation specific to BigQuery
{% macro bigquery__percentile(percentile_field, partition_field, percent) %}

percentile_cont(
{{ percentile_field }},
{{ percent }})
over (partition by {{ partition_field }}
)

{% endmacro %}

{% macro postgres__percentile(percentile_field, partition_field, percent) %}

percentile_cont(
{{ percent }} )
within group ( order by {{ percentile_field }} )
/* have to group by partition field */

{% endmacro %}

{% macro spark__percentile(percentile_field, partition_field, percent) %}

percentile(
{{ percentile_field }},
{{ percent }})
over (partition by {{ partition_field }}
)

{% endmacro %}
12 changes: 0 additions & 12 deletions macros/utils/json_extract.sql

This file was deleted.

11 changes: 0 additions & 11 deletions macros/utils/percentile.sql

This file was deleted.

3 changes: 0 additions & 3 deletions packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@
packages:
- package: dbt-labs/dbt_utils
version: [">=0.7.0", "<0.9.0"]

- package: fivetran/fivetran_utils
version: 0.3.9