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 diff --git a/dev_requirements.txt b/dev_requirements.txt index c2ae0f42..00723360 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,7 +1,5 @@ -dbt-core>=1.9.0,<1.10 +dbt-core>=1.10.0,<1.11 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..85d6c880 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 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..6eadd77d --- /dev/null +++ b/tests/integration/adapter/sample_mode/test_sample_mode.py @@ -0,0 +1,44 @@ +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 = """ +{{ 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 TestSampleMode(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_with_range(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, + )