Skip to content

Commit

Permalink
Merge pull request ClickHouse#376 from rjoelnorgren/range-dictionary-…
Browse files Browse the repository at this point in the history
…tests-changelog

Add range based dictionary to CHANGELOG + tests
  • Loading branch information
BentsiLeviav authored Nov 3, 2024
2 parents 0198fc8 + 86f8843 commit 065f3a7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
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"

0 comments on commit 065f3a7

Please sign in to comment.