{"record":{"id":"4e4684cbdc634130","repo":"dbt-labs/dbt-core","slug":"in-relation-relation-render-the-following-col","errorCode":null,"errorMessage":"In relation {relation.render()}: The following columns are specified in the schema but are not present in the database: {missing | join(\", \")}","messagePattern":"In relation (.+?): The following columns are specified in the schema but are not present in the database: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/dbt-loader/src/dbt_macro_assets/dbt-adapters/macros/adapters/persist_docs.sql","lineNumber":51,"sourceCode":"{% macro validate_doc_columns(relation, column_dict, existing_column_names, case_insensitive=false) %}\n  {% set existing_lower = existing_column_names | map(\"lower\") | list %}\n  {% set missing = [] %}\n  {% set filtered = {} %}\n  {% for col_name in column_dict %}\n    {% set is_quoted = column_dict[col_name]['quote'] %}\n    {% if case_insensitive or not is_quoted %}\n      {% set present = col_name | lower in existing_lower %}\n    {% else %}\n      {% set present = col_name in existing_column_names %}\n    {% endif %}\n    {% if present %}\n      {% do filtered.update({col_name: column_dict[col_name]}) %}\n    {% else %}\n      {% do missing.append(col_name) %}\n    {% endif %}\n  {% endfor %}\n  {% if missing | length > 0 %}\n    {{ exceptions.warn(\"In relation \" ~ relation.render() ~ \": The following columns are specified in the schema but are not present in the database: \" ~ missing | join(\", \")) }}\n  {% endif %}\n  {{ return(filtered) }}\n{% endmacro %}\n\n-- funcsign: (relation, model, optional[bool], optional[bool]) -> string\n{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n  {% if for_relation and config.persist_relation_docs() and model.description %}\n    {% do run_query(alter_relation_comment(relation, model.description)) %}\n  {% endif %}\n\n  {% if for_columns and config.persist_column_docs() and model.columns %}\n    {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n    {% set filtered_columns = validate_doc_columns(relation, model.columns, existing_columns) %}\n    {% set alter_comment_sql = alter_column_comment(relation, filtered_columns) %}\n    {% if alter_comment_sql and alter_comment_sql | trim | length > 0 %}\n      {% do run_query(alter_comment_sql) %}\n    {% endif %}\n  {% endif %}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-loader/src/dbt_macro_assets/dbt-adapters/macros/adapters/persist_docs.sql#L33-L69","documentation":"During persist_docs, dbt compares the columns declared in the model's schema (YAML/docs config) against the columns actually present in the materialized relation. Columns declared in the schema but missing from the database are collected into `missing` and reported via this warning so users know their docs/config reference columns that don't exist.","triggerScenarios":"Calling default__persist_docs (or get_columns_specified_in but not in the database) where iterating the model's column specs finds a name that has no entry in the database relation's column list, appending it to `missing`.","commonSituations":"YAML docs blocks list a column that was renamed or dropped in the model SQL; case-sensitivity mismatch between the schema file and the database; persist_docs enabled on an external/view relation whose columns drifted from the declared schema.","solutions":["Update the model's YAML docs/columns block so it only lists columns that exist in the built relation.","Rebuild/run the model so the relation matches the declared schema, then re-run `dbt docs generate` or persist_docs.","Check for case-sensitivity or quoting mismatches between the schema column names and the database column names."],"exampleFix":"// before (schema.yml)\ncolumns:\n  - name: old_col\n// after\ncolumns:\n  - name: new_col","handlingStrategy":"validation","validationCode":"# Compare declared docs columns against the relation before persisting docs\n# dbt: run `dbt compile && dbt run-operation get_columns_specified_in --args ...`\n# or in Python after a run:\n# relation_columns = {c.name for c in adapter.get_columns(relation)}\n# yaml_columns = set(model['columns'].keys())\n# assert yaml_columns <= relation_columns, f\"missing: {yaml_columns - relation_columns}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate the YAML docs block from the actual relation columns whenever the model SQL changes.","Use dbt-codegen to produce the schema.yml instead of hand-writing column lists.","Watch for case mismatches between YAML names and database column names."],"tags":["dbt","schema","docs","warning"],"backgroundTag":"schema-validation-failed","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"}