From 64575ca23c94a0697cb184a163db9fe7aa425453 Mon Sep 17 00:00:00 2001 From: Taylor Murphy Date: Mon, 27 Jul 2020 10:32:17 -0500 Subject: [PATCH 1/3] log package and model name in warning --- macros/sql/surrogate_key.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/sql/surrogate_key.sql b/macros/sql/surrogate_key.sql index 04d38e23..8e9c7b21 100644 --- a/macros/sql/surrogate_key.sql +++ b/macros/sql/surrogate_key.sql @@ -2,7 +2,7 @@ {%- if varargs|length >= 1 or field_list is string %} -{%- do exceptions.warn("Warning: the `surrogate_key` macro now takes a single list argument instead of multiple string arguments. Support for multiple string arguments will be deprecated in a future release of dbt-utils.") -%} +{%- do exceptions.warn("Warning: package: the `surrogate_key` macro now takes a single list argument instead of multiple string arguments. Support for multiple string arguments will be deprecated in a future release of dbt-utils. The " ~ model.package_name ~ "." ~ model.name ~ " model triggered this warning.") -%} {# first argument is not included in varargs, so add first element to field_list_xf #} {%- set field_list_xf = [field_list] -%} From f9bde74df2a2a8c47a6c1c0936ff5bde0a35678b Mon Sep 17 00:00:00 2001 From: Taylor Murphy Date: Mon, 27 Jul 2020 10:55:31 -0500 Subject: [PATCH 2/3] remove extra chars --- macros/sql/surrogate_key.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/sql/surrogate_key.sql b/macros/sql/surrogate_key.sql index 8e9c7b21..45098be5 100644 --- a/macros/sql/surrogate_key.sql +++ b/macros/sql/surrogate_key.sql @@ -2,7 +2,7 @@ {%- if varargs|length >= 1 or field_list is string %} -{%- do exceptions.warn("Warning: package: the `surrogate_key` macro now takes a single list argument instead of multiple string arguments. Support for multiple string arguments will be deprecated in a future release of dbt-utils. The " ~ model.package_name ~ "." ~ model.name ~ " model triggered this warning.") -%} +{%- do exceptions.warn("Warning: the `surrogate_key` macro now takes a single list argument instead of multiple string arguments. Support for multiple string arguments will be deprecated in a future release of dbt-utils. The " ~ model.package_name ~ "." ~ model.name ~ " model triggered this warning.") -%} {# first argument is not included in varargs, so add first element to field_list_xf #} {%- set field_list_xf = [field_list] -%} From 63dfc98056f9e7d44620499113068ead30992c7a Mon Sep 17 00:00:00 2001 From: Taylor Murphy Date: Mon, 27 Jul 2020 13:32:24 -0500 Subject: [PATCH 3/3] reformat all deprecation warnings --- macros/cross_db_utils/identifier.sql | 8 ++++++-- macros/sql/get_relations_by_prefix.sql | 8 ++++++-- macros/sql/surrogate_key.sql | 8 +++++++- macros/sql/union.sql | 8 ++++++-- macros/sql/unpivot.sql | 7 ++++++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/macros/cross_db_utils/identifier.sql b/macros/cross_db_utils/identifier.sql index 5c337369..ede09f66 100644 --- a/macros/cross_db_utils/identifier.sql +++ b/macros/cross_db_utils/identifier.sql @@ -1,5 +1,9 @@ {% macro identifier(value) %} - {% do exceptions.warn("Warning: the `identifier` macro is no longer supported and will be deprecated in a future release of dbt-utils. Use `adapter.quote` instead") %} + {%- set error_message = ' + Warning: the `identifier` macro is no longer supported and will be deprecated in a future release of dbt-utils. \ + Use `adapter.quote` instead. The {}.{} model triggered this warning. \ + '.format(model.package_name, model.name) -%} + {%- do exceptions.warn(error_message) -%} {{ adapter_macro('dbt_utils.identifier', value) }} {% endmacro %} @@ -9,4 +13,4 @@ {% macro bigquery__identifier(value) -%} `{{ value }}` -{%- endmacro %} \ No newline at end of file +{%- endmacro %} diff --git a/macros/sql/get_relations_by_prefix.sql b/macros/sql/get_relations_by_prefix.sql index 9d143f16..895ec795 100644 --- a/macros/sql/get_relations_by_prefix.sql +++ b/macros/sql/get_relations_by_prefix.sql @@ -23,8 +23,12 @@ {% endmacro %} {% macro get_tables_by_prefix(schema, prefix, exclude='', database=target.database) %} - - {% do exceptions.warn("Warning: the `get_tables_by_prefix` macro is no longer supported and will be deprecated in a future release of dbt-utils. Use the `get_relations_by_prefix` macro instead") %} + {%- set error_message = ' + Warning: the `get_tables_by_prefix` macro is no longer supported and will be deprecated in a future release of dbt-utils. \ + Use the `get_relations_by_prefix` macro instead. \ + The {}.{} model triggered this warning. \ + '.format(model.package_name, model.name) -%} + {%- do exceptions.warn(error_message) -%} {{ return(dbt_utils.get_relations_by_prefix(schema, prefix, exclude, database)) }} diff --git a/macros/sql/surrogate_key.sql b/macros/sql/surrogate_key.sql index 45098be5..b992c733 100644 --- a/macros/sql/surrogate_key.sql +++ b/macros/sql/surrogate_key.sql @@ -2,7 +2,13 @@ {%- if varargs|length >= 1 or field_list is string %} -{%- do exceptions.warn("Warning: the `surrogate_key` macro now takes a single list argument instead of multiple string arguments. Support for multiple string arguments will be deprecated in a future release of dbt-utils. The " ~ model.package_name ~ "." ~ model.name ~ " model triggered this warning.") -%} +{%- set error_message = ' +Warning: the `surrogate_key` macro now takes a single list argument instead of \ +multiple string arguments. Support for multiple string arguments will be \ +deprecated in a future release of dbt-utils. The {}.{} model triggered this warning. \ +'.format(model.package_name, model.name) -%} + +{%- do exceptions.warn(error_message) -%} {# first argument is not included in varargs, so add first element to field_list_xf #} {%- set field_list_xf = [field_list] -%} diff --git a/macros/sql/union.sql b/macros/sql/union.sql index 8dbd40f6..b6956f70 100644 --- a/macros/sql/union.sql +++ b/macros/sql/union.sql @@ -85,8 +85,12 @@ {%- endmacro -%} {%- macro union_tables(tables, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_table') -%} - - {%- do exceptions.warn("Warning: the `union_tables` macro is no longer supported and will be deprecated in a future release of dbt-utils. Use the `union_relations` macro instead") -%} + {%- set error_message = ' + Warning: the `union_tables` macro is no longer supported and will be deprecated in a future release of dbt-utils. \ + Use the `union_relations` macro instead. \ + The {}.{} model triggered this warning. \ + '.format(model.package_name, model.name) -%} + {%- do exceptions.warn(error_message) -%} {{ return(dbt_utils.union_relations(tables, column_override, include, exclude, source_column_name)) }} diff --git a/macros/sql/unpivot.sql b/macros/sql/unpivot.sql index 34426e47..de1a1b5c 100644 --- a/macros/sql/unpivot.sql +++ b/macros/sql/unpivot.sql @@ -15,7 +15,12 @@ Arguments: {% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value', table=none) -%} {% if table %} - {% do exceptions.warn("Warning: the `unpivot` macro no longer accepts a `table` parameter. This parameter will be deprecated in a future release of dbt-utils. Use the `relation` parameter instead") %} + {%- set error_message = ' + Warning: the `unpivot` macro no longer accepts a `table` parameter. \ + This parameter will be deprecated in a future release of dbt-utils. Use the `relation` parameter instead. \ + The {}.{} model triggered this warning. \ + '.format(model.package_name, model.name) -%} + {%- do exceptions.warn(error_message) -%} {% endif %} {% if relation and table %}