<@U088WCP3B4P>, please see if you can help here: ...
# ask-elementary-ai
n
@kapa.ai, please see if you can help here: 'm having a hard time visualizing the results of my tests with
edr report
. I have a profiles.yml like:
Copy code
dbtpoc:
  outputs:
    dev:
      dbname: pipelinedb
      host: localhost
      pass: ...
      port: ...
      schema: dbt_tests
      threads: 4
      type: postgres
      user: ...
  target: dev

elementary:
  outputs:
    default:
      type: postgres
      host: localhost
      user: ...
      password: ...
      port: ...
      dbname: pipelinedb
      schema: dbt_tests_elementary
      threads: 4
The only configurations in my dbt_project.yml are:
Copy code
models:
  elementary:
    +schema: elementary

flags:
  require_explicit_package_overrides_for_builtin_materializations: false
  source_freshness_run_project_hooks: True
Then, if I do
dbt run
followed by
edr report
, I see a nice report with my models built. However, if I follow that up with
dbt test
and run
edr report
again, I get a "No test results" report, also without my models. If I click on "Model performance" on the right menu, I also see an infinite spinning wheel as it tries to fetch models, but nothing is shown. I have checked that 1.
pipelinedb.dbt_tests_elementary.elementary_test_results
has content 2. There are no errors in
edr_target/edr.log
3. The command
dbt run-operation elementary.log_macro_results --args '{"macro_name": "elementary_cli.get_tests"}' --project-dir [folder in the logs]
returns valid content
k
A message from kapa.ai
New message text here
n
@kapa.ai, if I use the schema configuration you suggested, I actually see elementary creating a schema called dbt_tests_dbt_tests_elementary, no?
k
A message from kapa.ai
You're correct—if you set
+schema: dbt_tests_elementary
in your
dbt_project.yml
, and your dbt project's default schema (from your profile) is already
dbt_tests
, then dbt's default behavior is to concatenate the target schema and the custom schema, resulting in a schema like
dbt_tests_dbt_tests_elementary
. This is because dbt's default
generate_schema_name
macro combines the target schema with the custom schema you specify. So, unless you override this macro, you'll get the double prefix. How to avoid this: If you want the schema to be exactly
dbt_tests_elementary
(and not
dbt_tests_dbt_tests_elementary
), you need to override the
generate_schema_name
macro in your project. The Elementary documentation and community discussions confirm this is the standard approach for custom schema naming in dbt and Elementary: > In short, the default dbt
generate_schema_name
macro concatenate[s] the value provided in
schema
configuration key to the target schema, as in:
target_schema_custom_schema
. > > If you want a different behaviour, like configuring a full name for the Elementary schema, you can override the default
generate_schema_name
macro with your logic. > [Can I change the Elementary schema?](https://docs.elementary-data.com/oss/general/faq) The documentation provides an example macro you can use to control the schema name more precisely:
Copy code
jinja {% macro generate_schema_name(custom_schema_name, node) -%}     {%- set default_schema = target.schema -%}     {% set config_meta = node.config.get('meta') %}     {% 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(schema_name) }}         {% endif %}     {%- elif custom_schema_name is none -%}         {{ default_schema }}     {%- else -%}         {{ default_schema }}_{{ custom_schema_name | trim }}     {%- endif -%} {%- endmacro %}
Or, you can adjust it to return only the custom schema name for Elementary models, as shown in several Slack threads:
Copy code
jinja {% macro generate_schema_name(custom_schema_name, node) -%}     {% if node.package_name == 'elementary' and custom_schema_name %}         {{ custom_schema_name | trim }}     {% else %}         {{ target.schema }}_{{ custom_schema_name | trim }}     {% endif %} {%- endmacro %}
This way, Elementary models will be created in the schema you specify, without the double prefix. For more details, see the FAQ and Slack discussions: [Can I change the Elementary schema?](https://docs.elementary-data.com/oss/general/faq) [Slack thread on custom schema logic](https://slack.com/archives/C02CTC89LAX/p1712851926036669)