Skip to content

fix: return only the schema for ClickHouse in get_elementary_database_and_schema - #2426

Merged
EladBarkay merged 1 commit into
masterfrom
fix-clickhouse-elementary-database-and-schema
Dec 1, 2026
Merged

EladBarkay merged 1 commit into
masterfrom
fix-clickhouse-elementary-database-and-schema

Conversation

@EladBarkay

@EladBarkay EladBarkay commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On ClickHouse, get_elementary_database_and_schema returns <schema>.<schema>: elementary.target_database() returns target.schema on ClickHouse, and the macro joins it with target.schema again. The Slack alert then shows SELECT test_results_query FROM <schema>.<schema>.elementary_test_results ..., a three-part name that isn't valid ClickHouse SQL.

Fix

Dispatch the macro per adapter, like test_conn and get_test_results. The default keeps today's logic; clickhouse__get_elementary_database_and_schema returns only target.schema, the ClickHouse database that holds the Elementary tables.

The returned string is only used in that Slack message (slack.py) and passed through alert objects, so nothing else changes.

Related: elementary-data/dbt-data-reliability#1107 (stops the package from inventing a ClickHouse database equal to the schema).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved schema selection for ClickHouse; other adapters retain the existing database-and-schema behavior.

…_and_schema

ClickHouse has no database level, and target_database() returns the
schema on ClickHouse, so this returned '<schema>.<schema>'. The Slack
alert's test results query then read
<schema>.<schema>.elementary_test_results, which ClickHouse rejects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The macro now delegates database and schema selection to adapter dispatch. The default implementation preserves the previous behavior. The ClickHouse implementation returns only the target schema.

Changes: Database and schema selection

Layer / File(s) Summary
Dispatch and schema selection
elementary/monitor/dbt_project/macros/get_elementary_database_and_schema.sql
The entry-point macro delegates to adapter dispatch. The default implementation preserves the existing database and schema rule. The ClickHouse implementation returns only target.schema.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: haritamar

Merge Risk: Minimal · up to 21277

This change fixes the invalid three-part relation name in ClickHouse Slack alert queries by returning only the schema. Other adapters keep their current behavior. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: ClickHouse's get_elementary_database_and_schema now returns only the schema. The raw summary confirms a new clickhouse__ dispatch that returns only target.schema, and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: ClickHouse's get_elementary_database_and_schema now returns only the schema. The raw summary confirms a new clickhouse__ dispatch that returns only target.schema, and the objectives describe the same fix for the <schema>.<schema> relation name in Slack alerts. The title is specific and accurate, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: fe92b1f0-4b4d-4e54-ae3f-55015a7ef1b7
Commits

Reviewing files that changed from the base of the PR and between 88293a2 and 21277bb.

Files selected for processing: 1

  • elementary/monitor/dbt_project/macros/get_elementary_database_and_schema.sql

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

👋 @EladBarkay
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@jonlevine7

jonlevine7 commented Nov 30, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@EladBarkay
EladBarkay marked this pull request as ready for review November 30, 2026 18:24
@EladBarkay
EladBarkay merged commit bd1df89 into master Dec 1, 2026
53 of 56 checks passed
@EladBarkay
EladBarkay deleted the fix-clickhouse-elementary-database-and-schema branch December 1, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants