fix: populate database_name from schema for ClickHouse (CORE-559)#976
fix: populate database_name from schema for ClickHouse (CORE-559)#976devin-ai-integration[bot] wants to merge 2 commits intomasterfrom
Conversation
ClickHouse does not have a separate database/schema concept — the dbt-clickhouse adapter sets node.database to None, causing NULL database_name in dbt artifact models. Add get_node_database() dispatched macro that falls back to schema for ClickHouse only (mirroring ClickHouse's information_schema behavior). Update all 7 call sites in artifact upload macros. Co-Authored-By: unknown <>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
👋 @devin-ai-integration[bot] |
📝 WalkthroughWalkthroughAdded an adapter-dispatched macro Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
macros/utils/graph/get_relevant_databases.sql (1)
2-2: Pre-existing issue:target.databasemay also beNoneon ClickHouse.As noted in the PR checklist, Line 2 still reads
target.databasedirectly. On ClickHouse, this could beNone, resulting inNoneappearing in the returned database list. While this PR focuses on node-level extraction, consider a follow-up to apply similar fallback logic here (e.g.,target.database or target.schema).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@macros/utils/graph/get_relevant_databases.sql` at line 2, The list assignment for database_names uses target.database directly which can be None on ClickHouse; update the macro in get_relevant_databases.sql to fallback to target.schema when target.database is falsy (e.g., set database_names to [target.database or target.schema]) so the returned list never contains None; ensure you update any references that expect database_names to remain a list of strings and keep the same variable name database_names for compatibility.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@macros/utils/graph/get_relevant_databases.sql`:
- Line 2: The list assignment for database_names uses target.database directly
which can be None on ClickHouse; update the macro in get_relevant_databases.sql
to fallback to target.schema when target.database is falsy (e.g., set
database_names to [target.database or target.schema]) so the returned list never
contains None; ensure you update any references that expect database_names to
remain a list of strings and keep the same variable name database_names for
compatibility.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 777f2573-b8b7-4b98-8d09-88abc9a812ae
📒 Files selected for processing (8)
macros/edr/dbt_artifacts/upload_dbt_columns.sqlmacros/edr/dbt_artifacts/upload_dbt_models.sqlmacros/edr/dbt_artifacts/upload_dbt_seeds.sqlmacros/edr/dbt_artifacts/upload_dbt_sources.sqlmacros/edr/dbt_artifacts/upload_dbt_tests.sqlmacros/utils/graph/get_model_database_and_schema_from_test_node.sqlmacros/utils/graph/get_node_database.sqlmacros/utils/graph/get_relevant_databases.sql
Co-Authored-By: unknown <>
fix: populate database_name from schema for ClickHouse (CORE-559)
Summary
ClickHouse does not have a separate database/schema concept — the dbt-clickhouse adapter sets
node.databasetoNone. This causesdatabase_nameto be NULL in all dbt artifact models (models, sources, seeds, tests, columns), which breaks the Cloud product.ClickHouse's own
information_schemaassigns the same value to both the database and schema columns. This PR mirrors that behavior by introducing a dispatchedget_node_database()macro:default__get_node_database: returnsnode.get("database")(unchanged behavior for all other warehouses)clickhouse__get_node_database: returnsnode.get("database") or node.get("schema")(falls back to schema when database is None)All 7 call sites that extract a database name from a node dict are updated to use this macro. This follows the same dispatch pattern already used by
clickhouse__get_package_database_and_schema.Updates since last revision
get_relevant_databases.sqlline 2:target.databaseis alsoNoneon ClickHouse, so the initial database list now usestarget.database or target.schemato avoid aNoneentry. Note this is a directorfallback (not routed through the dispatch macro) sincetargetis not a node dict.Review & Testing Checklist for Human
database_namefeeds intoget_artifact_metadata_hash— ClickHouse users will see hash changes after deploy, triggering re-upload of all artifacts on next run. Verify this is acceptable.target.database or target.schemaconsistency: Line 2 ofget_relevant_databases.sqluses a genericorfallback rather than the ClickHouse-specific dispatch pattern. This is becausetargetis not a node dict, but confirm this approach is acceptable given the preference for explicit ClickHouse-only logic.node.get("database")or.get("database")usages in artifact-related macros that may have been missed.database_nameis populated (not NULL) indbt_models,dbt_sources,dbt_seeds,dbt_tests, anddbt_columnstables.Notes
minio/mcimage).Summary by CodeRabbit