The problem I’m having
VIEWS (materialization) are created with 3 part identifiers.
Example of a dbt compiled code sql:
create view "schema_name"."view_name" as
select ......... from "**database_name**"."schema_name"."table_name"
The context of why I’m trying to do this
we would need to skip the “database_name” from the view defintion. as have a process that copies definitions and moves across databases. is it possible?
what we need is without “database_name”,
create view "schema_name"."view_name" as
select ......... from ."schema_name"."table_name"
I have the same problem. Using PostgreSQL-16.
23:06:23 On model.finance.my_first_dbt_model: /* {“app”: “dbt”, “dbt_version”: “1.7.11”, “profile_name”: “finance”, “target_name”: “dev”, “node_id”: “model.finance.my_first_dbt_model”} */
create table “db2”.“finance”.“my_first_dbt_model__dbt_tmp”
I have tried
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if custom_schema_name is none -%}
{{ default_schema }}
{%- else -%}
{{ default_schema }}_{{ custom_schema_name | trim }}
{%- endif -%}
{%- endmacro %}
{% macro sourceold(source_name, table_name, include_database = False) %}
{% do return(builtins.source(source_name, table_name).include(database = include_database)) %}
{% endmacro %}
{% macro ref(model_name) %}
{% do return(builtins.ref(model_name).include(database=false)) %}
{% endmacro %}
{% macro source(source_name, table_name) %}
{% do return(builtins.source(source_name, table_name).include(database=false)) %}
{% endmacro %}
But these do not have an effect.