Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add range based dictionary to CHANGELOG + tests #376

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Unreleased
### Improvement
* Added support for [range_hashed](https://clickhouse.com/docs/en/sql-reference/dictionaries#range_hashed) and [complex_key_range_hashed](https://clickhouse.com/docs/en/sql-reference/dictionaries#complex_key_range_hashed) layouts to the dictionary materialization. ([#361](https://github.com/ClickHouse/dbt-clickhouse/pull/361))

### Release [1.8.4], 2024-09-17
### Improvement
* The S3 help macro now support a `role_arn` parameter as an alternative way to provide authentication for S3 based models. Thanks to
Expand Down Expand Up @@ -527,4 +531,4 @@ for Replicated tables that use the `{uuid}` macro in the path to avoid name conf
[0.19.1]: https://github.com/ClickHouse/dbt-clickhouse/compare/v0.19.0.2...v0.19.1
[0.19.0.2]: https://github.com/ClickHouse/dbt-clickhouse/compare/v0.19.0.1...v0.19.0.2
[0.19.0.1]: https://github.com/ClickHouse/dbt-clickhouse/compare/v0.19.0...v0.19.0.1
[0.19.0]: https://github.com/ClickHouse/dbt-clickhouse/compare/eb3020a...v0.19.0
[0.19.0]: https://github.com/ClickHouse/dbt-clickhouse/compare/eb3020a...v0.19.0
42 changes: 42 additions & 0 deletions tests/integration/adapter/dictionary/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os

import pytest

from dbt.tests.util import run_dbt

testing_s3 = os.environ.get('DBT_CH_TEST_INCLUDE_S3', '').lower() in ('1', 'true', 'yes')
Expand Down Expand Up @@ -114,6 +115,33 @@
- name: people
"""

RANGE_DICTIONARY = """
{{ config(
materialized='dictionary',
fields=[
('id', 'UInt8'),
('start', 'UInt8'),
('stop', 'UInt8'),
('value', 'String')
],
primary_key='id',
layout='RANGE_HASHED()',
lifetime='MIN 0 MAX 0',
source_type='clickhouse',
range='min start max stop'
) }}

select
c1 as id,
c2 as start,
c3 as stop,
c4 as value
from values(
(0, 0, 2, 'foo'),
(0, 3, 5, 'bar')
)
"""


class TestQueryDictionary:
@pytest.fixture(scope="class")
Expand Down Expand Up @@ -193,3 +221,17 @@ def test_create(self, project):
"select count(distinct LocationID) from taxi_zone_dictionary", fetch="all"
)
assert results[0][0] == 265


class TestRangeDictionary:
@pytest.fixture(scope="class")
def models(self):
return {"range_dictionary.sql": RANGE_DICTIONARY}

def test_create(self, project):
run_dbt()

results = project.run_sql("select dictGet(range_dictionary, 'value', 0, 1)", fetch="all")
assert results[0][0] == "foo"
results = project.run_sql("select dictGet(range_dictionary, 'value', 0, 5)", fetch="all")
assert results[0][0] == "bar"