diff --git a/CHANGELOG.md b/CHANGELOG.md index c682e43d221..3600952defd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Moving from 'master' to 'HEAD' default branch in git ([#3057](https://github.com/fishtown-analytics/dbt/issues/3057), [#3104](https://github.com/fishtown-analytics/dbt/issues/3104), [#3117](https://github.com/fishtown-analytics/dbt/issues/3117))) - Requirement on `dataclasses` is relaxed to be between `>=0.6,<0.9` allowing dbt to cohabit with other libraries which required higher versions. ([#3150](https://github.com/fishtown-analytics/dbt/issues/3150), [#3151](https://github.com/fishtown-analytics/dbt/pull/3151)) - Add feature to add `_n` alias to same column names in SQL query ([#3147](https://github.com/fishtown-analytics/dbt/issues/3147), [#3158](https://github.com/fishtown-analytics/dbt/pull/3158)) +- Raise a proper error message if dbt parses a macro twice due to macro duplication or misconfiguration. ([#2449](https://github.com/fishtown-analytics/dbt/issues/2449), [#3165](https://github.com/fishtown-analytics/dbt/pull/3165)) ### Features - Add optional configs for `require_partition_filter` and `partition_expiration_days` in BigQuery ([#1843](https://github.com/fishtown-analytics/dbt/issues/1843), [#2928](https://github.com/fishtown-analytics/dbt/pull/2928)) @@ -27,6 +28,7 @@ Contributors: - [@VasiliiSurov](https://github.com/VasiliiSurov) ([#3104](https://github.com/fishtown-analytics/dbt/pull/3104)) - [@bastienboutonnet](https://github.com/bastienboutonnet) ([#3151](https://github.com/fishtown-analytics/dbt/pull/3151)) - [@techytushar](https://github.com/techytushar) ([#3158](https://github.com/fishtown-analytics/dbt/pull/3158)) +- [@cgopalan](https://github.com/cgopalan) ([#3165](https://github.com/fishtown-analytics/dbt/pull/3165)) ## dbt 0.19.1 (Release TBD) diff --git a/core/dbt/parser/results.py b/core/dbt/parser/results.py index f2fc3b9d5f1..cfadfe52b34 100644 --- a/core/dbt/parser/results.py +++ b/core/dbt/parser/results.py @@ -125,7 +125,7 @@ def add_macro(self, source_file: SourceFile, macro: ParsedMacro): # subtract 2 for the "Compilation Error" indent # note that the line wrap eats newlines, so if you want newlines, # this is the result :( - msg = line_wrap_message( + dup_macro_msg = line_wrap_message( f'''\ dbt found two macros named "{macro.name}" in the project "{macro.package_name}". @@ -140,6 +140,25 @@ def add_macro(self, source_file: SourceFile, macro: ParsedMacro): ''', subtract=2 ) + dup_path_msg = line_wrap_message( + f"""\ + The macro {macro.name} in file {macro.original_file_path} + was parsed multiple times by dbt. This error happens when a + macro is defined multiple times in the same file, or when a + path is duplicated in a dbt_project.yml configuration. + To fix this error, check: + + - {macro.original_file_path} + + - The `macro-paths` configurations in dbt_project.yml + """, + subtract=2, + ) + msg = ( + dup_path_msg + if macro.original_file_path == other_path + else dup_macro_msg + ) raise_compiler_error(msg) self.macros[macro.unique_id] = macro