Skip to content

Commit

Permalink
Merge pull request #3165 from cgopalan/dup-macro-message
Browse files Browse the repository at this point in the history
Raise proper error message if duplicate macros found
  • Loading branch information
jtcohen6 authored Mar 17, 2021
2 parents 9a6d30f + 369b595 commit 7435828
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)

Expand Down
21 changes: 20 additions & 1 deletion core/dbt/parser/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}".
Expand All @@ -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
Expand Down

0 comments on commit 7435828

Please sign in to comment.