{"record":{"id":"0a6dd53c164b32a5","repo":"dbt-labs/dbt-core","slug":"relations-should-always-come-with-a-defined-schema","errorCode":null,"errorMessage":"Relations should always come with a defined schema. Missing schema for {relation.identifier}","messagePattern":"Relations should always come with a defined schema\\. Missing schema for (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-loader/src/dbt_macro_assets/dbt-clickhouse/macros/adapters.sql","lineNumber":121,"sourceCode":"      {% endif %}\n        join system.databases as db on t.database = db.name\n        left join mv_sources on mv_sources.target_fqn = concat(t.database, '.', t.name)\n      where schema = '{{ schema_relation.schema }}'\n      group by name, schema, type, db_engine\n\n  {% endcall %}\n  {{ return(load_result('list_relations_without_caching').table) }}\n{% endmacro %}\n\n{% macro clickhouse__get_columns_in_relation(relation) -%}\n  {% call statement('get_columns', fetch_result=True) %}\n    select name, type from system.columns where table = '{{ relation.identifier }}'\n    {% if relation.schema %}\n      {% if not relation.is_temporary %}\n        and database = '{{ relation.schema }}'\n      {% endif %}\n    {% else %}\n      {% do exceptions.warn(\"Relations should always come with a defined schema. Missing schema for \" ~ relation.identifier) %}\n    {% endif %}\n    order by position\n  {% endcall %}\n  {{ return(sql_convert_columns_in_relation(load_result('get_columns').table)) }}\n{% endmacro %}\n\n{% macro clickhouse__drop_relation(relation, obj_type='table') -%}\n  {% call statement('drop_relation', auto_begin=False) -%}\n    drop {{ obj_type }} if exists {{ relation }} {{ on_cluster_clause(relation, True)}}\n  {%- endcall %}\n{% endmacro %}\n\n{% macro clickhouse__rename_relation(from_relation, to_relation, obj_type='table') -%}\n  {% call statement('drop_relation') %}\n    drop {{ obj_type }} if exists {{ to_relation }} {{ on_cluster_clause(to_relation)}}\n  {% endcall %}\n  {% call statement('rename_relation') %}\n    rename {{ obj_type }} {{ from_relation }} to {{ to_relation }} {{ on_cluster_clause(from_relation)}}","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-loader/src/dbt_macro_assets/dbt-clickhouse/macros/adapters.sql#L103-L139","documentation":"Warning emitted by the dbt-clickhouse get_columns_in_relation macro path: a relation being introspected has an identifier but no schema, which should never happen for properly resolved ClickHouse relations. The relation identifier is interpolated; the fault is a relation object built without a schema component.","triggerScenarios":"Thrown at crates/dbt-loader/src/dbt_macro_assets/dbt-clickhouse/macros/adapters.sql:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the target/profile defines a schema so generated relations always carry one","Check custom schema macros that may strip the schema from relation objects","Verify the relation was created via the adapter's relation factory rather than ad-hoc"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}