question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[SEMANTIC-90] [Bug] Metric definition issue with custom schema macro

See original GitHub issue

Is 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:closed
  • Created 10 months ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
callum-mcdatacommented, Nov 21, 2022

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!

1reaction
raphaelvarierascommented, Nov 21, 2022

Sure thing - is this what you wanted to see?

Screenshot 2022-11-21 at 12 41 12 PM
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found