Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Comment on lines -1 to -4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • clickhouse-connect and clickhouse-driver are already defined in setup.py
  • dbt-core updated to 1.10 so test can run against it.

pytest>=7.2.0
pytest-dotenv==0.5.2
pytest-timeout==2.4.0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/adapter/concurrency/test_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this test "broke" after testing with 1.10 :D

54 changes: 54 additions & 0 deletions tests/integration/adapter/sample_mode/test_sample_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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


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
Comment thread
koletzilla marked this conversation as resolved.
Resolved

@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,
)