Running `dbt run -s elementary` somehow resulted ...
# community-support
y
Running
dbt run -s elementary
somehow resulted in creating elementary-related tables in the actual schema rather than a new schema suffixed by
_elementary
. I am using Snowflake and elementary version 0.16.1. I am sharing my configurations: profiles.yml:
Copy code
deployment:
  outputs:
    staging:
      account: ...
      authenticator: externalbrowser
      client_session_keep_alive: false
      database: STAGING
      role: ...
      schema: JAFFLE_SHOP_STAGE
      threads: 8
      type: snowflake
      user: ...
      warehouse: ...
  target: staging
elementary:
  outputs:
    default:
      account: ...
      authenticator: externalbrowser
      client_session_keep_alive: false
      database: STAGING
      role: ...
      schema: JAFFLE_SHOP_STAGE_ELEMENTARY
      threads: 8
      type: snowflake
      user: ...
      warehouse: ...
dbt_project.yml:
Copy code
analysis-paths:
- analyses
clean-targets:
- target
- dbt_packages
# config-version: 2
flags:
  require_explicit_package_overrides_for_builtin_materializations: false
  source_freshness_run_project_hooks: true
macro-paths:
- macros
model-paths:
- models
models:
  +post-hook:
  - '{{ custom_post_hook.hook(this) }}'
  elementary:
    +schema: elementary
  jaffle_shop:
    marts:
      +materialized: table
    staging:
      +materialized: view
  sql_header: ALTER SESSION SET QUERY_TAG = 'jaffle_shop_3.0.0';
name: jaffle_shop
on-run-end:
- '{{ my_custom_hook.hook2() }}'
profile: deployment
require-dbt-version: '>=1.5.0'
seed-paths:
- seeds
seeds:
  jaffle_shop:
    +schema: jaffle_shop_raw
snapshot-paths:
- snapshots
target-path: target
test-paths:
- data-tests
vars:
  dbt_date:time_zone: UTC
version: 3.0.0
Solved the issue. It was because dbt's testing project
jaffle-shop
handling schema naming, that is causing the problem in my case.
🙌 1
I tried to use
jaffle-shop
for testing the orchestrator and it requires more testing and caused more problem than the orchestrator itself.
n
Happy to hear! So are you able to run everything on the
jaffle-shop
now or is it still causing issues?
y
After solving schema naming problem, it automatically handled also the previous error I encountered.
✅ 1
t
@Noya Offer Im also expernicing the same issue!
@Yunus Emre Gündüz How did you solve it?
y
In my case, it was related to
jaffle-shop
project itself. The project itself customizes
generate_schema_name.sql
macro. Here, it only adds
_elementary
suffix for production models. I added other targets and it resolved.
t
@Yunus Emre Gündüz This is my generate_schema_name.sql macro:
Copy code
{% macro generate_schema_name(custom_schema_name, node) -%}

{%- set default_schema = target.schema -%}
{{ log(target.schema) }}
{% set config_meta = node.config.get("meta") %}
{% if target.name in ["prod","production", "staging", "test"] %}
    {% if config_meta and config_meta is mapping %}
       {% set schema_name = config_meta.get("schema_name") %}
    {% if schema_name and schema_name is string %}
       {{ return("{}_{}".format(default_schema, schema_name)) }}
    {% endif %}
    {%- elif custom_schema_name is none -%} {{ default_schema }}
    {%- else -%} {{ custom_schema_name | trim }}
    {%- endif -%}
    {%- else -%}
    {% if config_meta and config_meta is mapping %}
    {% set schema_name = config_meta.get("schema_name") %}
    {% if schema_name and schema_name is string %}
    {{ return("{}_{}".format(default_schema, schema_name)) }}
    {% endif %}
{%- else -%} {{ default_schema | trim }}
{%- endif -%}
{%- endif -%}
{%- endmacro %}
Can you try helpo me?