Skip to content

Commit

Permalink
Merge pull request #475 from mweso-softserve/type_string_macro_handli…
Browse files Browse the repository at this point in the history
…ng_all_cases
  • Loading branch information
b-per authored Aug 19, 2024
2 parents 1e66191 + a4f2a82 commit 68486e5
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Currently, the following adapters are supported:

Check [dbt Hub](https://hub.getdbt.com/dbt-labs/dbt_project_evaluator/latest/) for the latest installation instructions, or [read the docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.

### Additional setup for Databricks/Spark/DuckDB/Redshift
### Additional setup for Databricks/Spark/DuckDB

In your `dbt_project.yml`, add the following config:

Expand Down
3 changes: 0 additions & 3 deletions macros/cross_db_shim/redshift_shims.sql

This file was deleted.

File renamed without changes.
11 changes: 11 additions & 0 deletions macros/cross_db_shim/type_string.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{%- macro type_string_dpe() -%}
{{ return(adapter.dispatch('type_string_dpe', 'dbt_project_evaluator')()) }}
{%- endmacro -%}

{%- macro default__type_string_dpe() -%}
{{ return(dbt.type_string()) }}
{%- endmacro -%}

{%- macro redshift__type_string_dpe() -%}
{{ return(api.Column.string_type(600)) }}
{%- endmacro -%}
8 changes: 4 additions & 4 deletions macros/unpack/get_relationship_values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

{%- set values_line =
[
"cast('" ~ node.unique_id ~ "' as " ~ dbt.type_string() ~ ")",
"cast(NULL as " ~ dbt.type_string() ~ ")",
"cast('" ~ node.unique_id ~ "' as " ~ dbt_project_evaluator.type_string_dpe() ~ ")",
"cast(NULL as " ~ dbt_project_evaluator.type_string_dpe() ~ ")",
"FALSE",
]
%}
Expand All @@ -37,8 +37,8 @@

{%- set values_line =
[
"cast('" ~ node.unique_id ~ "' as " ~ dbt.type_string() ~ ")",
"cast('" ~ parent ~ "' as " ~ dbt.type_string() ~ ")",
"cast('" ~ node.unique_id ~ "' as " ~ dbt_project_evaluator.type_string_dpe() ~ ")",
"cast('" ~ parent ~ "' as " ~ dbt_project_evaluator.type_string_dpe() ~ ")",
"" ~ loop.last ~ "" if node.unique_id.split('.')[0] == 'test' else "FALSE"
]
%}
Expand Down
2 changes: 1 addition & 1 deletion macros/wrap_string_with_quotes.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro wrap_string_with_quotes(str) %}
{% if str is none %}
{{ return('cast(NULL as ' ~ dbt.type_string() ~ ')') }}
{{ return('cast(NULL as ' ~ dbt_project_evaluator.type_string_dpe() ~ ')') }}
{% else %}
{{ dbt.string_literal(str) }}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions models/staging/graph/base/base_exposure_relationships.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ with dummy_cte as (
)

select
cast(null as {{ dbt.type_string()}}) as resource_id,
cast(null as {{ dbt.type_string()}}) as direct_parent_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as resource_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as direct_parent_id,
cast(True as boolean) as is_primary_relationship

from dummy_cte
Expand Down
4 changes: 2 additions & 2 deletions models/staging/graph/base/base_metric_relationships.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ with dummy_cte as (
)

select
cast(null as {{ dbt.type_string()}}) as resource_id,
cast(null as {{ dbt.type_string()}}) as direct_parent_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as resource_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as direct_parent_id,
cast(True as boolean) as is_primary_relationship

from dummy_cte
Expand Down
10 changes: 5 additions & 5 deletions models/staging/graph/base/base_node_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ with dummy_cte as (
)

select
cast(null as {{ dbt.type_string() }}) as node_unique_id,
cast(null as {{ dbt.type_string()}}) as name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as node_unique_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as name,
cast(null as {{ dbt_project_evaluator.type_large_string()}}) as description,
cast(null as {{ dbt.type_string()}}) as data_type,
cast(null as {{ dbt.type_string()}}) as constraints,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as data_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as constraints,
cast(True as boolean) as has_not_null_constraint,
cast(0 as {{ dbt.type_int() }}) as constraints_count,
cast(null as {{ dbt.type_string()}}) as quote
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as quote

from dummy_cte
where false
4 changes: 2 additions & 2 deletions models/staging/graph/base/base_node_relationships.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ with dummy_cte as (
)

select
cast(null as {{ dbt.type_string()}}) as resource_id,
cast(null as {{ dbt.type_string()}}) as direct_parent_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as resource_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as direct_parent_id,
cast(True as boolean) as is_primary_relationship

from dummy_cte
Expand Down
10 changes: 5 additions & 5 deletions models/staging/graph/base/base_source_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ with dummy_cte as (
)

select
cast(null as {{ dbt.type_string() }}) as node_unique_id,
cast(null as {{ dbt.type_string()}}) as name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as node_unique_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as name,
cast(null as {{ dbt_project_evaluator.type_large_string()}}) as description,
cast(null as {{ dbt.type_string()}}) as data_type,
cast(null as {{ dbt.type_string()}}) as constraints,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as data_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as constraints,
cast(True as boolean) as has_not_null_constraint,
cast(0 as {{ dbt.type_int() }}) as constraints_count,
cast(null as {{ dbt.type_string()}}) as quote
cast(null as {{ dbt_project_evaluator.type_string_dpe()}}) as quote

from dummy_cte
where false
22 changes: 11 additions & 11 deletions models/staging/graph/stg_exposures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ with dummy_cte as (

select

cast(null as {{ dbt.type_string() }} ) as unique_id,
cast(null as {{ dbt.type_string() }} ) as name,
cast(null as {{ dbt.type_string() }} ) as resource_type,
cast(null as {{ dbt.type_string() }} ) as file_path,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as unique_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as resource_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as file_path,
cast(True as boolean) as is_described,
cast(null as {{ dbt.type_string() }} ) as exposure_type,
cast(null as {{ dbt.type_string() }} ) as maturity,
cast(null as {{ dbt.type_string() }} ) as package_name,
cast(null as {{ dbt.type_string() }} ) as url,
cast(null as {{ dbt.type_string() }} ) as owner_name,
cast(null as {{ dbt.type_string() }} ) as owner_email,
cast(null as {{ dbt.type_string() }} ) as meta
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as exposure_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as maturity,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as package_name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as url,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as owner_name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as owner_email,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }} ) as meta

from dummy_cte
where false
32 changes: 16 additions & 16 deletions models/staging/graph/stg_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ with dummy_cte as (

select

cast(null as {{ dbt.type_string() }}) as unique_id,
cast(null as {{ dbt.type_string() }}) as name,
cast(null as {{ dbt.type_string() }}) as resource_type,
cast(null as {{ dbt.type_string() }}) as file_path,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as unique_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as resource_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as file_path,
cast(True as boolean) as is_described,
cast(null as {{ dbt.type_string() }}) as metric_type,
cast(null as {{ dbt.type_string() }}) as label,
cast(null as {{ dbt.type_string() }}) as package_name,
cast(null as {{ dbt.type_string() }}) as metric_filter,
cast(null as {{ dbt.type_string() }}) as metric_measure,
cast(null as {{ dbt.type_string() }}) as metric_measure_alias,
cast(null as {{ dbt.type_string() }}) as numerator,
cast(null as {{ dbt.type_string() }}) as denominator,
cast(null as {{ dbt.type_string() }}) as expr,
cast(null as {{ dbt.type_string() }}) as metric_window,
cast(null as {{ dbt.type_string() }}) as grain_to_date,
cast(null as {{ dbt.type_string() }}) as meta
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as metric_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as label,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as package_name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as metric_filter,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as metric_measure,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as metric_measure_alias,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as numerator,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as denominator,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as expr,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as metric_window,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as grain_to_date,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as meta

from dummy_cte
where false
38 changes: 19 additions & 19 deletions models/staging/graph/stg_nodes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ with dummy_cte as (

select

cast(null as {{ dbt.type_string() }}) as unique_id,
cast(null as {{ dbt.type_string() }}) as name,
cast(null as {{ dbt.type_string() }}) as resource_type,
cast(null as {{ dbt.type_string() }}) as file_path,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as unique_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as resource_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as file_path,
cast(True as boolean) as is_enabled,
cast(null as {{ dbt.type_string() }}) as materialized,
cast(null as {{ dbt.type_string() }}) as on_schema_change,
cast(null as {{ dbt.type_string() }}) as model_group,
cast(null as {{ dbt.type_string() }}) as access,
cast(null as {{ dbt.type_string() }}) as latest_version,
cast(null as {{ dbt.type_string() }}) as version,
cast(null as {{ dbt.type_string() }}) as deprecation_date,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as materialized,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as on_schema_change,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as model_group,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as access,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as latest_version,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as version,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as deprecation_date,
cast(True as boolean) as is_contract_enforced,
cast(0 as {{ dbt.type_int() }}) as total_defined_columns,
cast(0 as {{ dbt.type_int() }}) as total_described_columns,
cast(null as {{ dbt.type_string() }}) as database,
cast(null as {{ dbt.type_string() }}) as schema,
cast(null as {{ dbt.type_string() }}) as package_name,
cast(null as {{ dbt.type_string() }}) as alias,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as database,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as schema,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as package_name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as alias,
cast(True as boolean) as is_described,
cast(null as {{ dbt.type_string() }}) as column_name,
cast(null as {{ dbt.type_string() }}) as meta,
cast(null as {{ dbt.type_string() }}) as hard_coded_references,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as column_name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as meta,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as hard_coded_references,
cast(null as {{ dbt.type_int() }}) as number_lines,
cast(null as {{ dbt.type_float() }}) as sql_complexity,
cast(null as {{ dbt.type_string() }}) as macro_dependencies,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as macro_dependencies,
cast(True as boolean) as is_generic_test,
cast(True as boolean) as is_excluded

Expand Down
26 changes: 13 additions & 13 deletions models/staging/graph/stg_sources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ with dummy_cte as (

select

cast(null as {{ dbt.type_string() }}) as unique_id,
cast(null as {{ dbt.type_string() }}) as name,
cast(null as {{ dbt.type_string() }}) as file_path,
cast(null as {{ dbt.type_string() }}) as alias,
cast(null as {{ dbt.type_string() }}) as resource_type,
cast(null as {{ dbt.type_string() }}) as source_name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as unique_id,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as file_path,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as alias,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as resource_type,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as source_name,
cast(True as boolean) as is_source_described,
cast(True as boolean) as is_described,
cast(True as boolean) as is_enabled,
cast(null as {{ dbt.type_string() }}) as loaded_at_field,
cast(null as {{ dbt.type_string() }}) as database,
cast(null as {{ dbt.type_string() }}) as schema,
cast(null as {{ dbt.type_string() }}) as package_name,
cast(null as {{ dbt.type_string() }}) as loader,
cast(null as {{ dbt.type_string() }}) as identifier,
cast(null as {{ dbt.type_string() }}) as meta,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as loaded_at_field,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as database,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as schema,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as package_name,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as loader,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as identifier,
cast(null as {{ dbt_project_evaluator.type_string_dpe() }}) as meta,
cast(True as boolean) as is_excluded

from dummy_cte
Expand Down

0 comments on commit 68486e5

Please sign in to comment.