dbt-core icon indicating copy to clipboard operation
dbt-core copied to clipboard

[Bug] Macro added twice during partial parsing

Open crystalro0 opened this issue 3 years ago • 8 comments

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:

  1. Create new file with 2 macros while in development environment and under new branch.
  2. Add both macros to macros yml file.
  3. Save commits and switch to main branch.
  4. Compilation error is raised.

Forced error steps:

  1. Create new file with 2 macros while in development environment and under new branch.
  2. Add only one of the macros to macros yml file.
  3. 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

crystalro0 avatar Nov 08 '21 18:11 crystalro0

+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

saraleon1 avatar Mar 14 '22 16:03 saraleon1

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.

github-actions[bot] avatar Sep 11 '22 02:09 github-actions[bot]

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.

github-actions[bot] avatar Sep 18 '22 02:09 github-actions[bot]

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.

dbeatty10 avatar Oct 05 '23 16:10 dbeatty10

Re-opening.

Reprex as reported in #8775:

  1. Create macros/macros.sql file with 2 macros inside
  2. Create macros/macros.yml with documentation for these 2 macros
  3. Run dbt compile
  4. Change something in macros/macros.yml
  5. Run dbt compile again

dbeatty10 avatar Oct 05 '23 19:10 dbeatty10

Implementation hints

https://github.com/dbt-labs/dbt-core/pull/4773 might have some ideas for implementation.

dbeatty10 avatar Oct 05 '23 19:10 dbeatty10

This issue still exists. I can reproduce it the same way OP did.

cegarciar2305 avatar Jun 07 '24 19:06 cegarciar2305

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.

dbeatty10 avatar Jun 12 '24 12:06 dbeatty10

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 avatar Jul 10 '24 15:07 jasmin-hemdani

@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?

dbeatty10 avatar Jul 10 '24 16:07 dbeatty10

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).

cegarciar2305 avatar Jul 23 '24 16:07 cegarciar2305