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] generate_schema_name doesn't work anymore after updating to 1.9.1 #11347

Open
2 tasks done
elycenok-wowcorp opened this issue Mar 3, 2025 · 3 comments
Open
2 tasks done
Labels
awaiting_response bug Something isn't working

Comments

@elycenok-wowcorp
Copy link

elycenok-wowcorp commented Mar 3, 2025

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

after updating the core dbt 1.6.5 -> 1.9.1 doesn't react to the macro ... generate_schema_name
https://hub.getdbt.com/calogica/dbt_expectations/latest/

didn't experiment more but can try to reproduce on a vanilla installation

we've tried

  1. moving the macro to the dbt/macro
  2. renaming macro to generate_schema_name
  3. updating dbt expectations to 0.10.4
  4. Removing the package dbt_date

Expected Behavior

should pick up the macro and react to that

Steps To Reproduce

Didn't get to that for now. Only a problem after migrating to 1.9.1 didn't change anything else
I guess it can be reproduced by create a brand new project, adding the macro and finding out that nothing really changes.
Can spend time on that later if required.

Relevant log output

no reaction to macro while before there was a clear schema customisation

Environment

- OS: Windows
- Python: 3.10.11
- dbt: 1.9.1

Which database adapter are you using with dbt?

No response

Additional Context

No response

@elycenok-wowcorp elycenok-wowcorp added bug Something isn't working triage labels Mar 3, 2025
@elycenok-wowcorp elycenok-wowcorp changed the title [Bug] <title> generate_schema_name doesn't work anymore after updating to 1.9.1 [Bug] generate_schema_name doesn't work anymore after updating to 1.9.1 Mar 3, 2025
@dbeatty10
Copy link
Contributor

Thanks for reaching out @elycenok-wowcorp !

I wasn't able to reproduce this, so could you try to reproduce this with a vanilla dbt project? If you're able to reproduce this, could you share your database adapter name and version as well?

More detail

Using a custom generate_schema_name worked for me with both dbt-duckdb and dbt-postgres when using dbt-core 1.9.1:

$ dbt build --no-partial-parse --profile duckdb    
23:49:21  Running with dbt=1.9.1
23:49:22  Registered adapter: duckdb=1.9.1
23:49:22  Found 1 model, 425 macros
23:49:22  
23:49:22  Concurrency: 1 threads (target='dev')
23:49:22  
23:49:22  1 of 1 START sql view model dev_123.my_model ................................... [RUN]
23:49:22  1 of 1 OK created sql view model dev_123.my_model .............................. [OK in 0.03s]
23:49:22  
23:49:22  Finished running 1 view model in 0 hours 0 minutes and 0.12 seconds (0.12s).
23:49:22  
23:49:22  Completed successfully
23:49:22  
23:49:22  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

$ dbt build --no-partial-parse --profile postgres    
23:50:01  Running with dbt=1.9.1
23:50:01  Registered adapter: postgres=1.9.0
23:50:02  Found 1 model, 432 macros
23:50:02  
23:50:02  Concurrency: 5 threads (target='postgres')
23:50:02  
23:50:02  1 of 1 START sql view model dbt_dbeatty_123.my_model ........................... [RUN]
23:50:02  1 of 1 OK created sql view model dbt_dbeatty_123.my_model ...................... [CREATE VIEW in 0.08s]
23:50:02  
23:50:02  Finished running 1 view model in 0 hours 0 minutes and 0.34 seconds (0.34s).
23:50:02  
23:50:02  Completed successfully
23:50:02  
23:50:02  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

Here's the custom macro that I used:

macros/generate_schema_name.sql

{% macro generate_schema_name(custom_schema_name, node) -%}

    {%- set default_schema = target.schema -%}
    {%- if custom_schema_name is none -%}

        {{ default_schema }}_123

    {%- else -%}

        {{ default_schema }}_{{ custom_schema_name | trim }}_456

    {%- endif -%}

{%- endmacro %}

@elycenok-wowcorp
Copy link
Author

elycenok-wowcorp commented Mar 4, 2025

thanks for the response @dbeatty10 ! sounds good, we are just working this around, but I might spend some time on it during the weekend (BigQuery adapter)

$ dbt compile
23:22:13  Running with dbt=1.9.1
23:22:14  Registered adapter: bigquery=1.9.1

....

@dbeatty10
Copy link
Contributor

@elycenok-wowcorp I tried it out with dbt-bigquery, and that worked for me as well:

$ dbt build --no-partial-parse --profile bigquery
00:57:10  Running with dbt=1.9.1
00:57:11  Registered adapter: bigquery=1.9.1
00:57:11  Found 1 model, 490 macros
00:57:11  
00:57:11  Concurrency: 10 threads (target='blue')
00:57:11  
00:58:28  1 of 1 START sql view model dbt_dbeatty_123.my_model ........................... [RUN]
00:58:29  1 of 1 OK created sql view model dbt_dbeatty_123.my_model ...................... [CREATE VIEW (0 processed) in 1.54s]
00:58:29  
00:58:29  Finished running 1 view model in 0 hours 1 minutes and 17.90 seconds (77.90s).
00:58:29  
00:58:29  Completed successfully
00:58:29  
00:58:29  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

So just let us know if you're able to figure out a simplified project where a customized generate_schema_name is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting_response bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants