dbt-core
dbt-core copied to clipboard
[Bug] Macro added twice during partial parsing
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
While in main/master branch, received compilation error:
dbt found two macros named "<user_macro>" in the project "<user_project>"
To fix this error, rename or remove one of the following macros:
- /macros/foo/bar.sql
- /macros/foo/bar.sql
The error points to the same file twice, seems like the macro in question is duplicated within that file. Could not locate the duplicated entry in the file. The *.yml
file was clear of duplicates as well.
Expected Behavior
No compiler errors, possibly 3 warnings for this user.
Steps To Reproduce
Possible user steps:
- Create new file with 2 macros while in development environment and under new branch.
- Add both macros to macros yml file.
- Save commits and switch to main branch.
- Compilation error is raised.
Forced error steps:
- Create new file with 2 macros while in development environment and under new branch.
- Add only one of the macros to macros yml file.
- Compilation error is raised.
Relevant log output
Error was seen during partial parsing compilation
Environment
- dbt: 0.21.0
What database are you using dbt with?
redshift
For More Recent Instance:
Relevant log output
08:46:39 Encountered an error:
Compilation Error
dbt found two macros named "<macros_name>" in the project "<project_name>".
To fix this error, rename or remove one of the following macros:
- macros/foo/bar.sql
- macros/foo/bar.sql
08:46:39 Command `dbt compile` failed at 11:46:39.886922 after 1.85 seconds
08:46:39 Flushing usage events
Environment
- Python: 3.10.4
- dbt: 1.6.2
Is this a new bug in dbt-core? I believe this is a new bug in dbt-core I have searched the existing issues, and I could not find an existing issue for this bug Current Behavior While run, compile or other command for partial parsing received Compilation Error:
dbt found two macros named "<user_macro>" in the project "<user_project>"
To fix this error, rename or remove one of the following macros:
- /macros/foo/bar.sql
- /macros/foo/bar.sql Expected Behavior No error
Steps To Reproduce
Create macros.sql file with 2 macros inside
Create macros.yml with documenation for this 2 macros
Run dbt compile
Change something in macros.yml
Run dbt compile again
Relevant log output
08:46:39 Encountered an error:
Compilation Error
dbt found two macros named "<macros_name>" in the project "<project_name>".
To fix this error, rename or remove one of the following macros:
- macros/foo/bar.sql
- macros/foo/bar.sql
08:46:39 Command dbt compile
failed at 11:46:39.886922 after 1.85 seconds
08:46:39 Flushing usage events
Environment
- Python: 3.10.4
- dbt: 1.6.2 Which database adapter are you using with dbt? other (mention it in "Additional Context")
Additional Context
dbt-adapter: dbt-athena: 1.6.1
Additional Context
No response
+1 dbt Cloud user (running the IDE on v1.0.x (PRERELEASE patch - fixes only)
)
Error raised was (slightly obscured):
Compilation Error
dbt found two macros named “create_myview” in the project “bi_schema”.
To fix this error, rename or remove one of the following macros:
- macros/integration.sql
- macros/integration.sql
Additional information:
- User is defining several macros in one file
- deleting the partial parse file seems to temporarily help address the compilation error
- compilation error arises when they add 2 similarly named macros to their *.yml file
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days.
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest; add a comment to notify the maintainers.
This was automatically closed as "stale" on Sep 17, 2022. Based on the report in https://github.com/dbt-labs/dbt-core/issues/8775, it was not resolved by https://github.com/dbt-labs/dbt-core/issues/4771.
Re-opening.
Reprex as reported in #8775:
- Create
macros/macros.sql
file with 2 macros inside- Create
macros/macros.yml
with documentation for these 2 macros- Run
dbt compile
- Change something in
macros/macros.yml
- Run
dbt compile
again
Implementation hints
https://github.com/dbt-labs/dbt-core/pull/4773 might have some ideas for implementation.
This issue still exists. I can reproduce it the same way OP did.
Thank you for confirming @cegarciar2305
Does it resolve the error for you if you use the --no-partial-parse flag?
dbt compile --no-partial-parse
This the workaround that that we've been recommending in the meantime for this type of error message.
Hello @dbeatty10 ! I am also seeing this same issue after upgrading my dbt version to 1.6.17 .
There is a problem in your dbt project. Compilation failed: Compilation Error dbt found two macros named "materialization_materialized_view_default" in the project "dbt". To fix this error, rename or remove one of the following macros: - macros/materializations/models/materialized_view/materialized_view.sql - macros/materializations/models/materialized_view.sql
However I cannot locate these filepaths in my project at all. The recommended workaround
dbt compile --no-partial-parse
did not fix it.
@jasmin-hemdani What is the output of dbt --version
? That way, I can see all the dbt adapter plugins you have installed (and their versions).
Do you have any dbt packages installed via dbt deps
? If so, could you share the contents of your relevant packages.yml
/ dependencies.yml
file?
Thank you for confirming @cegarciar2305
Does it resolve the error for you if you use the --no-partial-parse flag?
dbt compile --no-partial-parse
This the workaround that that we've been recommending in the meantime for this type of error message.
Unfortunately that does not seem to fix it, but I found that deleting manifest.json
does. However I'm scared that doing this might break other stuff (although that doesn't appear to be the case).