diff --git a/README.md b/README.md index d59486aa..f12edfb4 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/macros/cross_db_shim/redshift_shims.sql b/macros/cross_db_shim/redshift_shims.sql deleted file mode 100644 index 70110db1..00000000 --- a/macros/cross_db_shim/redshift_shims.sql +++ /dev/null @@ -1,3 +0,0 @@ -{%- macro redshift__type_string() -%} - {{ "VARCHAR(600)" }} -{%- endmacro %} \ No newline at end of file diff --git a/macros/unpack/type_large_string.sql b/macros/cross_db_shim/type_large_string.sql similarity index 100% rename from macros/unpack/type_large_string.sql rename to macros/cross_db_shim/type_large_string.sql diff --git a/macros/cross_db_shim/type_string.sql b/macros/cross_db_shim/type_string.sql new file mode 100644 index 00000000..a93db6db --- /dev/null +++ b/macros/cross_db_shim/type_string.sql @@ -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 -%} diff --git a/macros/unpack/get_relationship_values.sql b/macros/unpack/get_relationship_values.sql index c67ce780..9c9bb302 100644 --- a/macros/unpack/get_relationship_values.sql +++ b/macros/unpack/get_relationship_values.sql @@ -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", ] %} @@ -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" ] %} diff --git a/macros/wrap_string_with_quotes.sql b/macros/wrap_string_with_quotes.sql index cc8c27a0..9b0e7def 100644 --- a/macros/wrap_string_with_quotes.sql +++ b/macros/wrap_string_with_quotes.sql @@ -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 %} diff --git a/models/staging/graph/base/base_exposure_relationships.sql b/models/staging/graph/base/base_exposure_relationships.sql index 4f69c6ce..15b147ae 100644 --- a/models/staging/graph/base/base_exposure_relationships.sql +++ b/models/staging/graph/base/base_exposure_relationships.sql @@ -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 diff --git a/models/staging/graph/base/base_metric_relationships.sql b/models/staging/graph/base/base_metric_relationships.sql index 565643f9..72fdc56d 100644 --- a/models/staging/graph/base/base_metric_relationships.sql +++ b/models/staging/graph/base/base_metric_relationships.sql @@ -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 diff --git a/models/staging/graph/base/base_node_columns.sql b/models/staging/graph/base/base_node_columns.sql index d08954c1..817021e3 100644 --- a/models/staging/graph/base/base_node_columns.sql +++ b/models/staging/graph/base/base_node_columns.sql @@ -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 diff --git a/models/staging/graph/base/base_node_relationships.sql b/models/staging/graph/base/base_node_relationships.sql index 0592e789..ad74a52c 100644 --- a/models/staging/graph/base/base_node_relationships.sql +++ b/models/staging/graph/base/base_node_relationships.sql @@ -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 diff --git a/models/staging/graph/base/base_source_columns.sql b/models/staging/graph/base/base_source_columns.sql index 98705232..f4dcc954 100644 --- a/models/staging/graph/base/base_source_columns.sql +++ b/models/staging/graph/base/base_source_columns.sql @@ -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 \ No newline at end of file diff --git a/models/staging/graph/stg_exposures.sql b/models/staging/graph/stg_exposures.sql index 3014effb..d36cc1e7 100644 --- a/models/staging/graph/stg_exposures.sql +++ b/models/staging/graph/stg_exposures.sql @@ -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 \ No newline at end of file diff --git a/models/staging/graph/stg_metrics.sql b/models/staging/graph/stg_metrics.sql index dd37b9a1..d1549831 100644 --- a/models/staging/graph/stg_metrics.sql +++ b/models/staging/graph/stg_metrics.sql @@ -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 \ No newline at end of file diff --git a/models/staging/graph/stg_nodes.sql b/models/staging/graph/stg_nodes.sql index 71025190..c3165a12 100644 --- a/models/staging/graph/stg_nodes.sql +++ b/models/staging/graph/stg_nodes.sql @@ -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 diff --git a/models/staging/graph/stg_sources.sql b/models/staging/graph/stg_sources.sql index ed018971..4c6caf4d 100644 --- a/models/staging/graph/stg_sources.sql +++ b/models/staging/graph/stg_sources.sql @@ -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