From 213456e3897d6344e3b6029910289fcc6f7e2806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Mu=C3=B1oz?= Date: Fri, 3 Oct 2025 17:52:40 +0200 Subject: [PATCH 1/7] Start testing with dbt-core 1.10. Fix concurrency test. --- dev_requirements.txt | 3 --- setup.py | 4 ++-- tests/integration/adapter/concurrency/test_concurrency.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/dev_requirements.txt b/dev_requirements.txt index c2ae0f42..88302da8 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,7 +1,4 @@ -dbt-core>=1.9.0,<1.10 dbt-tests-adapter>=1.10,<2.0 -clickhouse-connect>=0.7.6 -clickhouse-driver>=0.2.7 pytest>=7.2.0 pytest-dotenv==0.5.2 pytest-timeout==2.4.0 diff --git a/setup.py b/setup.py index 899dc5c8..9ef4fa09 100644 --- a/setup.py +++ b/setup.py @@ -55,8 +55,8 @@ def _dbt_clickhouse_version(): install_requires=[ f'dbt-core>={dbt_minor_version}', 'dbt-adapters>=1.16,<1.17', # This version should be dbt-adapters>=1.16,<2.0, but keeping it fixed for now to avoid unexpected issues. We need to frequently update it. - 'clickhouse-connect>=0.6.22', - 'clickhouse-driver>=0.2.6', + 'clickhouse-connect>==0.10.0', + 'clickhouse-driver>=0.2.10', 'setuptools>=0.69', ], python_requires=">=3.9", diff --git a/tests/integration/adapter/concurrency/test_concurrency.py b/tests/integration/adapter/concurrency/test_concurrency.py index 09597a77..b9118784 100644 --- a/tests/integration/adapter/concurrency/test_concurrency.py +++ b/tests/integration/adapter/concurrency/test_concurrency.py @@ -30,4 +30,4 @@ def _validate_results(self, project, results, output): check_relations_equal(project.adapter, ["seed", "table_b"]) check_table_does_not_exist(project.adapter, "invalid") check_table_does_not_exist(project.adapter, "skip") - assert "PASS=5 WARN=0 ERROR=1 SKIP=1 TOTAL=7" in output + assert "PASS=5 WARN=0 ERROR=1 SKIP=1 NO-OP=0 TOTAL=7" in output From c16a91d362803c00825132a3d3c08701134097ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Mu=C3=B1oz?= Date: Fri, 21 Nov 2025 12:42:12 +0100 Subject: [PATCH 2/7] fix dep definition --- dev_requirements.txt | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dev_requirements.txt b/dev_requirements.txt index 88302da8..00723360 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,3 +1,4 @@ +dbt-core>=1.10.0,<1.11 dbt-tests-adapter>=1.10,<2.0 pytest>=7.2.0 pytest-dotenv==0.5.2 diff --git a/setup.py b/setup.py index 9ef4fa09..85d6c880 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ def _dbt_clickhouse_version(): install_requires=[ f'dbt-core>={dbt_minor_version}', 'dbt-adapters>=1.16,<1.17', # This version should be dbt-adapters>=1.16,<2.0, but keeping it fixed for now to avoid unexpected issues. We need to frequently update it. - 'clickhouse-connect>==0.10.0', + 'clickhouse-connect>=0.10.0', 'clickhouse-driver>=0.2.10', 'setuptools>=0.69', ], From 6777f4236bb002706ba3277bd38ce6805ad28117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Mu=C3=B1oz?= Date: Fri, 21 Nov 2025 16:39:15 +0100 Subject: [PATCH 3/7] Validate --sample compatibility --- .../adapter/sample_mode/test_sample_mode.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/integration/adapter/sample_mode/test_sample_mode.py diff --git a/tests/integration/adapter/sample_mode/test_sample_mode.py b/tests/integration/adapter/sample_mode/test_sample_mode.py new file mode 100644 index 00000000..fa503ed6 --- /dev/null +++ b/tests/integration/adapter/sample_mode/test_sample_mode.py @@ -0,0 +1,24 @@ +import pytest +from dbt.tests.adapter.sample_mode.test_sample_mode import ( + BaseSampleModeTest, +) + +# input_model_sql overrided as the `-0` part at the end of `TIMESTAMP '2025-01-01 01:25:00-0'` is not compatible with CH +input_model_sql = """ +{{ config(materialized='table', event_time='event_time') }} +select 1 as id, TIMESTAMP '2025-01-01 01:25:00' as event_time +UNION ALL +select 2 as id, TIMESTAMP '2025-01-02 13:47:00' as event_time +UNION ALL +select 3 as id, TIMESTAMP '2025-01-03 01:32:00' as event_time +""" + + +class TestPostgresSampleMode(BaseSampleModeTest): + @pytest.fixture(scope="class") + def input_model_sql(self) -> str: + """ + This is the SQL that defines the input model to be sampled, including any {{ config(..) }}. + event_time is a required configuration of this input + """ + return input_model_sql From d33567514764ec23744655438dd539b66779bd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Mu=C3=B1oz?= Date: Fri, 21 Nov 2025 17:23:54 +0100 Subject: [PATCH 4/7] Rename test --- tests/integration/adapter/sample_mode/test_sample_mode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/adapter/sample_mode/test_sample_mode.py b/tests/integration/adapter/sample_mode/test_sample_mode.py index fa503ed6..246f6d3c 100644 --- a/tests/integration/adapter/sample_mode/test_sample_mode.py +++ b/tests/integration/adapter/sample_mode/test_sample_mode.py @@ -14,7 +14,7 @@ """ -class TestPostgresSampleMode(BaseSampleModeTest): +class TestSampleMode(BaseSampleModeTest): @pytest.fixture(scope="class") def input_model_sql(self) -> str: """ From 8e57188f2f256a6b69ffd5927756d09542a3cf1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Mu=C3=B1oz?= Date: Fri, 21 Nov 2025 17:39:16 +0100 Subject: [PATCH 5/7] Add one more test for sample mode --- .../adapter/sample_mode/test_sample_mode.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/integration/adapter/sample_mode/test_sample_mode.py b/tests/integration/adapter/sample_mode/test_sample_mode.py index 246f6d3c..3dd948ef 100644 --- a/tests/integration/adapter/sample_mode/test_sample_mode.py +++ b/tests/integration/adapter/sample_mode/test_sample_mode.py @@ -1,7 +1,11 @@ +import os +from unittest import mock + import pytest from dbt.tests.adapter.sample_mode.test_sample_mode import ( BaseSampleModeTest, ) +from dbt.tests.util import run_dbt # input_model_sql overrided as the `-0` part at the end of `TIMESTAMP '2025-01-01 01:25:00-0'` is not compatible with CH input_model_sql = """ @@ -22,3 +26,29 @@ def input_model_sql(self) -> str: event_time is a required configuration of this input """ return input_model_sql + + +class TestMoreSampleModeOptions(BaseSampleModeTest): + @pytest.fixture(scope="class") + def input_model_sql(self) -> str: + """ + This is the SQL that defines the input model to be sampled, including any {{ config(..) }}. + event_time is a required configuration of this input + """ + return input_model_sql + + @mock.patch.dict(os.environ, {"DBT_EXPERIMENTAL_SAMPLE_MODE": "True"}) + def test_sample_mode(self, project) -> None: + _ = run_dbt(["run"]) + self.assert_row_count( + project=project, + relation_name="model_that_samples_input_sql", + expected_row_count=3, + ) + + _ = run_dbt(["run", "--sample", "{'start': '2025-01-02', 'end': '2025-01-03'}"]) + self.assert_row_count( + project=project, + relation_name="model_that_samples_input_sql", + expected_row_count=1, + ) From e9bb4b20cb94180dabf4b337872ff936d535ad63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Mu=C3=B1oz?= Date: Tue, 25 Nov 2025 13:54:45 +0100 Subject: [PATCH 6/7] Add current changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e36a7cd..587fb484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### Release [1.9.7], 2025-XX-XX + +#### Improvements +* Change tests to use dbt-core 1.10 to start validating new functionality ([#570](https://github.com/ClickHouse/dbt-clickhouse/pull/570)). +* Validate that the new `--sample` flag ([docs](https://docs.getdbt.com/docs/build/sample-flag)) works. Add tests to cover the implementation ([#570](https://github.com/ClickHouse/dbt-clickhouse/pull/570)). + + ### Release [1.9.6], 2025-11-03 #### Bugs From 14ead1a2cae8c66d2426efbdfd92e741f392bd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Mu=C3=B1oz?= Date: Wed, 26 Nov 2025 13:07:20 +0100 Subject: [PATCH 7/7] remove duplicated code in TestSampleMode --- .../adapter/sample_mode/test_sample_mode.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/integration/adapter/sample_mode/test_sample_mode.py b/tests/integration/adapter/sample_mode/test_sample_mode.py index 3dd948ef..6eadd77d 100644 --- a/tests/integration/adapter/sample_mode/test_sample_mode.py +++ b/tests/integration/adapter/sample_mode/test_sample_mode.py @@ -27,18 +27,8 @@ def input_model_sql(self) -> str: """ return input_model_sql - -class TestMoreSampleModeOptions(BaseSampleModeTest): - @pytest.fixture(scope="class") - def input_model_sql(self) -> str: - """ - This is the SQL that defines the input model to be sampled, including any {{ config(..) }}. - event_time is a required configuration of this input - """ - return input_model_sql - @mock.patch.dict(os.environ, {"DBT_EXPERIMENTAL_SAMPLE_MODE": "True"}) - def test_sample_mode(self, project) -> None: + def test_sample_mode_with_range(self, project) -> None: _ = run_dbt(["run"]) self.assert_row_count( project=project,