Skip to content

Commit 1547a06

Browse files
Re-enable ClickHouse in CLI tests (#2095)
* Re-enable ClickHouse in CLI tests Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Fix prettier formatting for warehouse-type array Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Add clickhouse to Seed e2e dbt project step Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Fix get_elementary_database_and_schema to use actual elementary schema Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Revert "Fix get_elementary_database_and_schema to use actual elementary schema" This reverts commit 1fc1952. * Fix ClickHouse column alias handling in populate_test_alerts macro Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Use .get() for all field accesses in populate_test_alerts to handle ClickHouse column names Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Revert "Use .get() for all field accesses in populate_test_alerts to handle ClickHouse column names" This reverts commit 5a7efb8. * Revert "Fix ClickHouse column alias handling in populate_test_alerts macro" This reverts commit a3bef9c. * Add debug logging to identify Undefined field in populate_test_alerts Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Update debug logging to use 'is defined' checks for accurate Undefined detection Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Add more detailed debug logging to find nested Undefined values Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Fix ClickHouse column alias handling with .get() fallbacks ClickHouse returns columns with table prefix (e.g., 'failed_tests.database_name' instead of 'database_name'). Use .get() with fallbacks to handle both naming conventions for the affected fields: - database_name - schema_name - tags - test_params - severity - status - result_rows Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Fix ClickHouse column name ambiguity with explicit SQL aliases ClickHouse returns columns with table prefix when column names are ambiguous across joined tables. The affected columns (database_name, schema_name, tags, test_params, severity, status, result_rows) exist in both failed_tests and tests tables. Fix: Add explicit 'as column_name' aliases in the SQL query to force ClickHouse to use the alias name instead of the qualified column name. This is cleaner than using .get() fallbacks in the macro. Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> * Remove DBT_EDR_DEBUG env var (debugging complete) Co-Authored-By: Itamar Hartstein <haritamar@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Itamar Hartstein <haritamar@gmail.com>
1 parent 2ea3ce0 commit 1547a06

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

.github/workflows/test-all-warehouses.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ jobs:
3333
matrix:
3434
dbt-version: ${{ inputs.dbt-version && fromJSON(format('["{0}"]', inputs.dbt-version)) || fromJSON('[null]') }}
3535
warehouse-type:
36-
[postgres, snowflake, bigquery, redshift, databricks_catalog, athena]
36+
[
37+
postgres,
38+
snowflake,
39+
bigquery,
40+
redshift,
41+
databricks_catalog,
42+
athena,
43+
clickhouse,
44+
]
3745
uses: ./.github/workflows/test-warehouse.yml
3846
with:
3947
warehouse-type: ${{ matrix.warehouse-type }}

.github/workflows/test-warehouse.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
- databricks_catalog
1515
- spark
1616
- athena
17+
- clickhouse
1718
elementary-ref:
1819
type: string
1920
required: false
@@ -103,10 +104,10 @@ jobs:
103104
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
104105
run: docker compose up -d postgres
105106

106-
# - name: Start Clickhouse
107-
# if: inputs.warehouse-type == 'clickhouse'
108-
# working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
109-
# run: docker compose up -d clickhouse
107+
- name: Start Clickhouse
108+
if: inputs.warehouse-type == 'clickhouse'
109+
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
110+
run: docker compose up -d clickhouse
110111

111112
- name: Setup Python
112113
uses: actions/setup-python@v5
@@ -161,7 +162,7 @@ jobs:
161162
162163
- name: Seed e2e dbt project
163164
working-directory: ${{ env.E2E_DBT_PROJECT_DIR }}
164-
if: inputs.warehouse-type == 'postgres' || inputs.generate-data
165+
if: inputs.warehouse-type == 'postgres' || inputs.warehouse-type == 'clickhouse' || inputs.generate-data
165166
run: |
166167
python generate_data.py
167168
dbt seed -f --target "${{ inputs.warehouse-type }}"

elementary/monitor/dbt_project/macros/alerts/population/test_alerts.sql

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{% set test_alerts = [] %}
55
{% set raw_test_alerts_agate = run_query(elementary_cli.populate_test_alerts_query(days_back)) %}
66
{% set raw_test_alerts = elementary.agate_to_dicts(raw_test_alerts_agate) %}
7+
78
{% for raw_test_alert in raw_test_alerts %}
89
{% set test_type = raw_test_alert.alert_type %}
910
{% set status = raw_test_alert.status | lower %}
@@ -138,25 +139,26 @@
138139
failed_tests.test_execution_id,
139140
failed_tests.test_unique_id,
140141
failed_tests.model_unique_id,
141-
failed_tests.database_name,
142+
{# Explicit aliases for columns that exist in both failed_tests and tests tables to avoid ClickHouse column name ambiguity #}
143+
failed_tests.database_name as database_name,
142144
failed_tests.detected_at,
143145
{{ elementary.edr_current_timestamp() }} as created_at,
144-
failed_tests.schema_name,
146+
failed_tests.schema_name as schema_name,
145147
failed_tests.table_name,
146148
failed_tests.column_name,
147149
failed_tests.test_type as alert_type,
148150
failed_tests.sub_type,
149151
failed_tests.test_results_description as alert_description,
150152
failed_tests.owners,
151-
failed_tests.tags,
153+
failed_tests.tags as tags,
152154
failed_tests.test_results_query as alert_results_query,
153155
failed_tests.other,
154156
failed_tests.test_name,
155157
failed_tests.test_short_name,
156-
failed_tests.test_params,
157-
failed_tests.severity,
158-
failed_tests.status,
159-
failed_tests.result_rows,
158+
failed_tests.test_params as test_params,
159+
failed_tests.severity as severity,
160+
failed_tests.status as status,
161+
failed_tests.result_rows as result_rows,
160162
tests.meta as test_meta,
161163
tests.description as test_description,
162164
artifacts_meta.meta as model_meta,

0 commit comments

Comments
 (0)