[SEMANTIC-90] [Bug] Metric definition issue with custom schema macro
See original GitHub issueIs this a new bug in dbt_metrics?
- I believe this is a new bug in dbt_metrics
- I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
When attempting to run a metric (in Mode), I get the following error message:
net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:
Schema 'DATABASE.TARGET_SCHEMA_CUSTOM_SCHEMA' does not exist or not authorized.
Which makes sense because the models are actually materialized in CUSTOM_SCHEMA
Expected Behavior
The metric reference should take into account the fact that the model schema rules have been customized using a custom get_custom_schema.sql macro.
Steps To Reproduce
Use the following custom schema macro:
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if target.name == 'prod' -%}
{%- if custom_schema_name is not none -%}
{{ custom_schema_name }}
{%- else -%}
{{ default_schema }}
{%- endif -%}
{%- else -%}
{%- if custom_schema_name is not none -%}
{{ default_schema }}_{{ custom_schema_name }}
{%- else -%}
{{ default_schema }}
{%- endif -%}
{%- endif -%}
{%- endmacro %}
Then define a metric and attempt to visualize it in Mode Analytics.
Relevant log output
No response
Environment
- dbt-adapter & version: dbt-snowflake v1.3.0
- dbt_metrics version: 1.3.0
Which database adapter are you using with dbt?
snowflake
Additional Context
Community slack: https://getdbt.slack.com/archives/C046L0VTVR6/p1668870928882369?thread_ts=1668868370.759179&cid=C046L0VTVR6
Issue Analytics
- State:
- Created 10 months ago
- Comments:6
Top Results From Across the Web
[Bug] generate_schema_name macro removes ability to use ...
I have searched the existing issues Current Behavior I was using the ... macro removes ability to use custom schema #4409.
Read more >Custom schemas - dbt Developer Hub
What is a custom schema? ... Under the hood, dbt uses a macro called generate_schema_name to determine the name of the schema that...
Read more >Macro for custom schema names doesn't apply in a dbt package
When I try to run my dbt project, it imports the dbt package but doesn't apply the macro that is supposed to remove...
Read more >Invalid Schema Error - Google Analytics Custom Reports
The Google Analytics error reads “Invalid schema. There was an error retrieving the requested dimensions/metrics.” Invalid Schema Error in ...
Read more >[DBT] Override Default Schema with Custom ... - Towards AI
By default, dbt uses generate_schema_name a macro to generate the schema. ... will build objects into if the custom schema is not defined...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hey @raphaelvarieras it appears that this is a bug with the Semantic Layer - unfortunately we’re in a code freeze for this week due to the holidays but our engineers will begin scoping it out this week. As soon as I have more tactical information I’ll be sure to let you know!
Sure thing - is this what you wanted to see?