Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Macro added twice during partial parsing #4233

Open
1 task done
crystalro0 opened this issue Nov 8, 2021 · 17 comments
Open
1 task done

[Bug] Macro added twice during partial parsing #4233

crystalro0 opened this issue Nov 8, 2021 · 17 comments
Labels
bug Something isn't working Medium Severity bug with minor impact that does not have resolution timeframe requirement partial_parsing

Comments

@crystalro0
Copy link

crystalro0 commented Nov 8, 2021

Is there an existing issue for this?

  • 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

@saraleon1
Copy link

+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

@github-actions
Copy link
Contributor

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 github-actions bot added the stale Issues that have gone stale label Sep 11, 2022
@github-actions
Copy link
Contributor

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.

@dbeatty10
Copy link
Contributor

This was automatically closed as "stale" on Sep 17, 2022. Based on the report in #8775, it was not resolved by #4771.

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
@dbeatty10
Copy link
Contributor

dbeatty10 commented Oct 5, 2023

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 dbeatty10 reopened this Oct 5, 2023
@dbeatty10 dbeatty10 added the Medium Severity bug with minor impact that does not have resolution timeframe requirement label Oct 5, 2023
@dbeatty10
Copy link
Contributor

Implementation hints

#4773 might have some ideas for implementation.

@cegarciar2305
Copy link

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

@dbeatty10
Copy link
Contributor

dbeatty10 commented Jun 12, 2024

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.

@jasmin-hemdani
Copy link

jasmin-hemdani commented Jul 10, 2024

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.

@dbeatty10
Copy link
Contributor

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

@cegarciar2305
Copy link

cegarciar2305 commented Jul 23, 2024

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

@sgalban-WTW
Copy link

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.

I have the same issue... any idea?

@dbeatty10
Copy link
Contributor

@sgalban-WTW Does it resolve the error for you if you use the --no-partial-parse flag?

dbt compile --no-partial-parse

If not, does it resolve if you delete your manifest.json file?

There's a couple ways to do that:

  1. dbt clean
  2. rm target/manifest.json (or whatever the path to your manifest file is)

@sgalban-WTW
Copy link

HI! It still not working with this flag.

I have just deleted the dbt-adapters from my venv and it might be work

@dbeatty10
Copy link
Contributor

@sgalban-WTW I wouldn't expect that deleting dbt-adapters from your virtual environment would affect this one way or the other.

Did you try deleting your target directory and trying again? It is safe to delete your target directory because dbt will just recalculate what it needs from scratch.

@wusanny
Copy link

wusanny commented Nov 20, 2024

Hi Team, adding on here on behalf of a dbt Cloud customer as the issue is still around. Customer reported seeing the error happen a few times, albeit randomly. The error seems to only pop up when editing the macros.yml file.

The current workaround is to:

  • Run dbt parse --no-partial-parse
  • Or delete the target/ folder and then refresh Cloud IDE

I was able to reproduce it under certain conditions (similar to the comment here):

  • Have multiple macros in macros.sql
  • Edit/add macros with similar names in macros.yml

It is rather elusive though, sometimes reproducible a few times in a row with the same steps, other times, nothing happens.

For me, the error always clears by deleting the target/ folder.

The issue has been around since 2021 and it is not always reproducible - is there anything that we can help with / provide in order to help the troubleshoot?

@dbeatty10
Copy link
Contributor

Hey @wusanny !

My understanding is that deleting the target folder is a reliable way to clear the error.

I don't know of anything else that you can help with or provide.

Here's the way I've reproduced this error previously: #4233 (comment)

And here's some potential implementation hints: #4233 (comment)

@dbeatty10 dbeatty10 removed the triage label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Medium Severity bug with minor impact that does not have resolution timeframe requirement partial_parsing
Projects
None yet
Development

No branches or pull requests

8 participants