From 0ff4536b7d4ebcc0e2fe34351cc5269635d877b7 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Fri, 9 Jan 2026 17:15:20 +0100 Subject: [PATCH 1/8] feat: implement UDF materialization --- dbt/adapters/clickhouse/relation.py | 1 + .../macros/materializations/function.sql | 25 +++++++++++++++++++ .../materializations/functions/scalar.sql | 20 +++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 dbt/include/clickhouse/macros/materializations/function.sql create mode 100644 dbt/include/clickhouse/macros/materializations/functions/scalar.sql diff --git a/dbt/adapters/clickhouse/relation.py b/dbt/adapters/clickhouse/relation.py index 099dcd7d..742d0ce5 100644 --- a/dbt/adapters/clickhouse/relation.py +++ b/dbt/adapters/clickhouse/relation.py @@ -33,6 +33,7 @@ class ClickHouseRelationType(StrEnum): External = "external" Ephemeral = "ephemeral" Dictionary = "dictionary" + Function = "function" @dataclass(frozen=True, eq=False, repr=False) diff --git a/dbt/include/clickhouse/macros/materializations/function.sql b/dbt/include/clickhouse/macros/materializations/function.sql new file mode 100644 index 00000000..868c7f30 --- /dev/null +++ b/dbt/include/clickhouse/macros/materializations/function.sql @@ -0,0 +1,25 @@ +{%- materialization function, adapter='clickhouse' -%} + + {%- set existing_relation = load_cached_relation(this) -%} + {%- set target_relation = this.incorporate(type='function') -%} + + {{ run_hooks(pre_hooks, inside_transaction=False) }} + + {% if existing_relation is none %} + {{ log('Creating new function ' ~ target_relation.identifier) }} + {% else %} + {{ log('Function ' ~ target_relation.identifier ~ ' exists, replacing it') }} + {% endif %} + + {# create our new function #} + {% call statement('main') -%} + {{ clickhouse__scalar_function_sql(target_relation) }} + {%- endcall %} + + {% do persist_docs(target_relation, model) %} + + {{ run_hooks(post_hooks, inside_transaction=False) }} + + {{ return({'relations': [target_relation]}) }} + +{%- endmaterialization -%} diff --git a/dbt/include/clickhouse/macros/materializations/functions/scalar.sql b/dbt/include/clickhouse/macros/materializations/functions/scalar.sql new file mode 100644 index 00000000..5a9c5918 --- /dev/null +++ b/dbt/include/clickhouse/macros/materializations/functions/scalar.sql @@ -0,0 +1,20 @@ +{% macro clickhouse__formatted_scalar_function_args_sql() %} + {% set args = [] %} + {% for arg in model.arguments -%} + {%- do args.append(arg.name) -%} + {%- endfor %} + {{ args | join(', ') }} +{% endmacro %} + +{% macro clickhouse__scalar_function_create_replace_signature_sql(target_relation) %} + CREATE OR REPLACE FUNCTION {{ target_relation.include(database=false, schema=false) }} {{ on_cluster_clause(this) }} AS ({{ clickhouse__formatted_scalar_function_args_sql() }}) -> +{% endmacro %} + +{% macro clickhouse__scalar_function_body_sql() %} + {{ model.compiled_code }} +{% endmacro %} + +{% macro clickhouse__scalar_function_sql(target_relation) %} + {{ clickhouse__scalar_function_create_replace_signature_sql(target_relation) }} + {{ clickhouse__scalar_function_body_sql() }}; +{% endmacro %} From 5963bea8ad6b5b01f7b893fe986b2900a09531d4 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Fri, 9 Jan 2026 18:34:04 +0100 Subject: [PATCH 2/8] tests: Add integration tests for UDF --- dev_requirements.txt | 2 +- setup.py | 0 tests/integration/adapter/udf/test_udf.py | 40 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 setup.py create mode 100644 tests/integration/adapter/udf/test_udf.py diff --git a/dev_requirements.txt b/dev_requirements.txt index 51348981..f34fedca 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,4 +1,4 @@ -dbt-core>=1.10.0,<1.11 +dbt-core>=1.11.0 dbt-tests-adapter>=1.10,<2.0 pytest>=7.2.0 pytest-dotenv==0.5.2 diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/adapter/udf/test_udf.py b/tests/integration/adapter/udf/test_udf.py new file mode 100644 index 00000000..6bd3101f --- /dev/null +++ b/tests/integration/adapter/udf/test_udf.py @@ -0,0 +1,40 @@ +""" +test UDF creation support for dbt-clickhouse +""" + +# we'll import helper used by the core test project to write directories + +import pytest + +from dbt.tests.util import run_dbt + +UDF_MODEL = """ +x * 2 +""".strip() + +UDF_SCHEMA_YML = """ +functions: + - name: answer_to_everything + description: Computes the answer to life, universe and everything. + arguments: + - name: x + data_type: Int32 + returns: + data_type: Int32 +""".strip() + + +class TestUDFCreation: + # Original functions fixture: provide files for a dedicated 'functions' dir + @pytest.fixture(scope="class") + def functions(self): + return { + "answer_to_everything.sql": UDF_MODEL, + "answer_to_everything.yml": UDF_SCHEMA_YML, + } + + def test_create(self, project): + run_dbt(["build"]) + + result = project.run_sql("SELECT answer_to_everything(21)", fetch="one") + assert result[0] == 42 From 6632fe1e550f0c703c9c421bb51c59c60af48146 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Fri, 9 Jan 2026 18:36:36 +0100 Subject: [PATCH 3/8] Update CHANGELOG.md --- CHANGELOG.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f92c599d..ff2841f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,7 +124,7 @@ For example: -- test_ttl.sql {{ config(order_by='(ts)', engine='MergeTree()', materialized='table') }} - SELECT now() AS ts, + SELECT now() AS ts, 'Some value that should expire!' AS col_ttl ``` @@ -160,7 +160,7 @@ For example: #### Improvements * It is now possible to configure a TLS client certificate using `client_cert` and `client_cert_key` profile parameters. ([#413](https://github.com/ClickHouse/dbt-clickhouse/pull/413)) * Added Support of insert_overwrite in cluster setup with incremental and distributed_incremental materializations ([#394](https://github.com/ClickHouse/dbt-clickhouse/pull/394)) -* Improve index and projections creation process ([#421](https://github.com/ClickHouse/dbt-clickhouse/pull/421)) +* Improve index and projections creation process ([#421](https://github.com/ClickHouse/dbt-clickhouse/pull/421)) #### Bugs * Reverted breaking changes in MV materialization ([#416](https://github.com/ClickHouse/dbt-clickhouse/pull/416)) @@ -179,7 +179,7 @@ For example: #### New Features * [ClickHouse indexes](https://clickhouse.com/docs/en/optimize/sparse-primary-indexes) are now fully supported for `table` materialization. -The index config should be added to the model config. for instance: +The index config should be added to the model config. for instance: ```python {{ config( materialized='%s', @@ -203,7 +203,7 @@ The index config should be added to the model config. for instance: * Removed support in python 3.8 as it is no longer supported by dbt ([#402](https://github.com/ClickHouse/dbt-clickhouse/pull/402) ### Bug Fixes -* Fix a minor bug related to validating existence of an old hanging mv ([#396]()) +* Fix a minor bug related to validating existence of an old hanging mv ([#396]()) ### Release [1.8.6], 2024-12-05 @@ -243,7 +243,7 @@ The index config should be added to the model config. for instance: ### Release [1.8.2], 2024-08-22 #### New Features * [ClickHouse projections](https://clickhouse.com/docs/en/sql-reference/statements/alter/projection) are now fully supported for `table` materialization, and partly supported for `distributed_table` materialization. -The projection config should be added to the model config ([#342](https://github.com/ClickHouse/dbt-clickhouse/pull/342)), for instance: +The projection config should be added to the model config ([#342](https://github.com/ClickHouse/dbt-clickhouse/pull/342)), for instance: ```python {{ config( materialized='%s', @@ -255,7 +255,7 @@ The projection config should be added to the model config ([#342](https://github ] ) }} ``` - + #### Bug Fixes * Until this release, when writing tests, it was not possible to pass empty seed data. ([#341](https://github.com/ClickHouse/dbt-clickhouse/pull/341)) * When a cluster was used, the adapter left a few `__dbt_backup` tables in the schema. After the fix, these backup tables are now properly dropped. ([#326](https://github.com/ClickHouse/dbt-clickhouse/pull/326)) @@ -271,9 +271,9 @@ The projection config should be added to the model config ([#342](https://github * Enhanced the clickhouse__listagg macro to support single field ordering with optional direction, ensuring compatibility with ClickHouse's sorting limitations. Added validation to prevent the use of multiple order-by fields. ([#318](https://github.com/ClickHouse/dbt-clickhouse/pull/318)) #### Documentation -* Update the docs with the new `insert_overwrite` incremental strategy. ([#331](https://github.com/ClickHouse/dbt-clickhouse/pull/331)) +* Update the docs with the new `insert_overwrite` incremental strategy. ([#331](https://github.com/ClickHouse/dbt-clickhouse/pull/331)) * Add documentation for codec column configuration. ([#317](https://github.com/ClickHouse/dbt-clickhouse/pull/317)) - + ### Release [1.8.1], 2024-07-11 #### Bug Fix @@ -330,7 +330,7 @@ for the PR! ### Release [1.7.4], 2024-03-23 #### Improvement - Adds support for materializing ClickHouse dictionaries. Thanks to [Rory Sawyer](https://github.com/SoryRawyer) for the contribution! -See his excellent [tests](https://github.com/ClickHouse/dbt-clickhouse/blob/main/tests/integration/adapter/dictionary/test_dictionary.py) +See his excellent [tests](https://github.com/ClickHouse/dbt-clickhouse/blob/main/tests/integration/adapter/dictionary/test_dictionary.py) for example usage. ### Release [1.7.3], 2024-03-11 @@ -387,7 +387,7 @@ do not support `CREATE TABLE AS SELECT ... EMPTY`, since the automatic deduplica inserts in Replicated tables on those older versions. Fixes https://github.com/ClickHouse/dbt-clickhouse/issues/216. ### Release [1.6.0], 2023-11-30 -#### Improvements +#### Improvements - Compatible with dbt 1.6.x. Note that dbt new `clone` feature is not supported, as ClickHouse has no native "light weight" clone functionality, and copying tables without actual data transfer is not possible in ClickHouse (barring file manipulation outside ClickHouse itself). @@ -476,7 +476,7 @@ https://github.com/ClickHouse/dbt-clickhouse/issues/167 #### Improvement - Added macros for creating distributed tables. See the `distributed_table.sql` include file. Thanks to -[gladkikhtutu](https://github.com/gladkikhtutu) for the contribution. +[gladkikhtutu](https://github.com/gladkikhtutu) for the contribution. ### Release [1.4.2], 2023-05-14 #### Bug fixes @@ -500,7 +500,7 @@ to non-overlapping data ranges. Closes https://github.com/ClickHouse/dbt-clickh - Adds additional dbt 1.4.0 tests - Adds support for incremental_predicates. This only applies to `delete+insert` incremental strategy. Note that incremental predicates that depend on "non-deterministic" data (such as a subquery using a table that is accepting inserts) could lead to -unexpected results for ReplicatedMergeTree tables depending on the timing of the incremental materialization. +unexpected results for ReplicatedMergeTree tables depending on the timing of the incremental materialization. - Replaces deprecated Exception classes - Setting the `use_lw_deletes` profile value to True will now attempt to enable the `allow_experimental_lightweight_delete` setting for the dbt session (if user has such permissions on the ClickHouse server). See https://github.com/ClickHouse/dbt-clickhouse/issues/133 @@ -513,7 +513,7 @@ setting for the dbt session (if user has such permissions on the ClickHouse serv #### Documentation Update - The documentation has been updated to reflect that dbt-clickhouse does support ephemeral models, and ephemeral model tests do pass. However, due to a [ClickHouse limitation](https://github.com/ClickHouse/ClickHouse/issues/30323), CTEs will not work directly -with INSERT statements so table models will fail if they include ephemeral models in the SELECT. View models and other SQL +with INSERT statements so table models will fail if they include ephemeral models in the SELECT. View models and other SQL statements using ephemeral models should work correctly. #### Bug Fix @@ -537,7 +537,7 @@ slower "legacy" strategy. [tests](https://github.com/ClickHouse/dbt-clickhouse/blob/main/tests/integration/adapter/test_s3.py) for example usage. #### Bug Fixes -- The ON CLUSTER clause has been added to additional DDL statements including incremental models processing. +- The ON CLUSTER clause has been added to additional DDL statements including incremental models processing. Closes https://github.com/ClickHouse/dbt-clickhouse/issues/117 and should close https://github.com/ClickHouse/dbt-clickhouse/issues/95 for Replicated tables that use the `{uuid}` macro in the path to avoid name conflicts. Thanks to [Saurabh Bikram](https://github.com/saurabhbikram) - The `apply` and `revoke` grants macros now correctly work with roles as well as user. Again thanks to [Saurabh Bikram](https://github.com/saurabhbikram) From 077e3fa5f609859ea72482927e61ebc3ddd78a20 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Wed, 14 Jan 2026 23:34:54 +0100 Subject: [PATCH 4/8] fixup! feat: implement UDF materialization --- dbt/adapters/clickhouse/__version__.py | 2 +- .../macros/materializations/function.sql | 25 ------------------- .../materializations/functions/scalar.sql | 5 ---- 3 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 dbt/include/clickhouse/macros/materializations/function.sql diff --git a/dbt/adapters/clickhouse/__version__.py b/dbt/adapters/clickhouse/__version__.py index b9664535..b6c30336 100644 --- a/dbt/adapters/clickhouse/__version__.py +++ b/dbt/adapters/clickhouse/__version__.py @@ -1 +1 @@ -version = '1.10.0' +version = "1.11.0" diff --git a/dbt/include/clickhouse/macros/materializations/function.sql b/dbt/include/clickhouse/macros/materializations/function.sql deleted file mode 100644 index 868c7f30..00000000 --- a/dbt/include/clickhouse/macros/materializations/function.sql +++ /dev/null @@ -1,25 +0,0 @@ -{%- materialization function, adapter='clickhouse' -%} - - {%- set existing_relation = load_cached_relation(this) -%} - {%- set target_relation = this.incorporate(type='function') -%} - - {{ run_hooks(pre_hooks, inside_transaction=False) }} - - {% if existing_relation is none %} - {{ log('Creating new function ' ~ target_relation.identifier) }} - {% else %} - {{ log('Function ' ~ target_relation.identifier ~ ' exists, replacing it') }} - {% endif %} - - {# create our new function #} - {% call statement('main') -%} - {{ clickhouse__scalar_function_sql(target_relation) }} - {%- endcall %} - - {% do persist_docs(target_relation, model) %} - - {{ run_hooks(post_hooks, inside_transaction=False) }} - - {{ return({'relations': [target_relation]}) }} - -{%- endmaterialization -%} diff --git a/dbt/include/clickhouse/macros/materializations/functions/scalar.sql b/dbt/include/clickhouse/macros/materializations/functions/scalar.sql index 5a9c5918..edb9e8f8 100644 --- a/dbt/include/clickhouse/macros/materializations/functions/scalar.sql +++ b/dbt/include/clickhouse/macros/materializations/functions/scalar.sql @@ -13,8 +13,3 @@ {% macro clickhouse__scalar_function_body_sql() %} {{ model.compiled_code }} {% endmacro %} - -{% macro clickhouse__scalar_function_sql(target_relation) %} - {{ clickhouse__scalar_function_create_replace_signature_sql(target_relation) }} - {{ clickhouse__scalar_function_body_sql() }}; -{% endmacro %} From a84c68c66f8aa55fc82e952ef05cb5ce6e2e8632 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Mon, 19 Jan 2026 16:50:17 +0100 Subject: [PATCH 5/8] Linter --- tests/integration/adapter/udf/test_udf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/adapter/udf/test_udf.py b/tests/integration/adapter/udf/test_udf.py index 6bd3101f..e289c5c5 100644 --- a/tests/integration/adapter/udf/test_udf.py +++ b/tests/integration/adapter/udf/test_udf.py @@ -5,7 +5,6 @@ # we'll import helper used by the core test project to write directories import pytest - from dbt.tests.util import run_dbt UDF_MODEL = """ From 271df2793aa95732dad1e76cb5a942ff06657398 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Wed, 11 Mar 2026 23:03:02 +0100 Subject: [PATCH 6/8] Rebase with upstream and PR fixes - Use UDF tests from dbt-adapter - Fire event during SQLQuery (test expectation) - Fix function relation --- dbt/adapters/clickhouse/connections.py | 29 +++++++++++++++++-- dbt/adapters/clickhouse/relation.py | 12 +++++--- setup.py | 0 tests/integration/adapter/udf/test_udf.py | 34 ++++++----------------- 4 files changed, 44 insertions(+), 31 deletions(-) delete mode 100644 setup.py diff --git a/dbt/adapters/clickhouse/connections.py b/dbt/adapters/clickhouse/connections.py index 9fd454c1..b7e7ee3f 100644 --- a/dbt/adapters/clickhouse/connections.py +++ b/dbt/adapters/clickhouse/connections.py @@ -3,10 +3,15 @@ from contextlib import contextmanager from typing import TYPE_CHECKING, Any, Optional, Tuple, Union +from dbt_common.events.contextvars import get_node_info +from dbt_common.events.functions import fire_event +from dbt_common.utils import cast_to_str + import dbt.exceptions from dbt.adapters.clickhouse.dbclient import ChRetryableException, get_db_client from dbt.adapters.clickhouse.logger import logger from dbt.adapters.contracts.connection import AdapterResponse, Connection +from dbt.adapters.events.types import SQLQuery from dbt.adapters.sql import SQLConnectionManager if TYPE_CHECKING: @@ -87,7 +92,14 @@ def execute( client = conn.handle with self.exception_handler(sql): - logger.debug(f'On {conn.name}: {sql}...') + fire_event( + SQLQuery( + conn_name=cast_to_str(conn.name), + node_info=get_node_info(), + sql=sql, + ) + ) + logger.debug(f"On {conn.name}: {sql}...") pre = time.time() if fetch: query_result = client.query(sql) @@ -116,7 +128,20 @@ def add_query( conn = self.get_thread_connection() client = conn.handle with self.exception_handler(sql): - logger.debug(f'On {conn.name}: {sql}...') + if abridge_sql_log: + log_sql = "{}...".format(sql[:512]) + else: + log_sql = sql + + fire_event( + SQLQuery( + conn_name=cast_to_str(conn.name), + node_info=get_node_info(), + sql=log_sql, + ) + ) + + logger.debug(f"On {conn.name}: {sql}...") pre = time.time() client.command(sql) status = self.get_status(client) diff --git a/dbt/adapters/clickhouse/relation.py b/dbt/adapters/clickhouse/relation.py index 742d0ce5..efc1c907 100644 --- a/dbt/adapters/clickhouse/relation.py +++ b/dbt/adapters/clickhouse/relation.py @@ -1,14 +1,16 @@ from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Type -from dbt.adapters.base.relation import BaseRelation, EventTimeFilter, Path, Policy, Self -from dbt.adapters.clickhouse.query import quote_identifier -from dbt.adapters.contracts.relation import HasQuoting, RelationConfig from dbt_common.dataclass_schema import StrEnum from dbt_common.exceptions import DbtRuntimeError from dbt_common.utils import deep_merge -NODE_TYPE_SOURCE = 'source' +from dbt.adapters.base.relation import BaseRelation, EventTimeFilter, Path, Policy, Self +from dbt.adapters.clickhouse.query import quote_identifier +from dbt.adapters.contracts.relation import HasQuoting, RelationConfig + +NODE_TYPE_SOURCE = "source" +NODE_TYPE_FUNCTION = "function" @dataclass @@ -147,6 +149,8 @@ def create_from( if relation_config.resource_type == NODE_TYPE_SOURCE: if schema == relation_config.source_name and relation_config.database: schema = relation_config.database + elif relation_config.resource_type == NODE_TYPE_FUNCTION: + schema = None else: # quoting is only available for non-source nodes cluster = quoting.credentials.cluster or "" diff --git a/setup.py b/setup.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/integration/adapter/udf/test_udf.py b/tests/integration/adapter/udf/test_udf.py index e289c5c5..c5b76768 100644 --- a/tests/integration/adapter/udf/test_udf.py +++ b/tests/integration/adapter/udf/test_udf.py @@ -2,38 +2,22 @@ test UDF creation support for dbt-clickhouse """ -# we'll import helper used by the core test project to write directories - import pytest -from dbt.tests.util import run_dbt -UDF_MODEL = """ -x * 2 -""".strip() +import dbt.tests.adapter.functions.files as files +from dbt.tests.adapter.functions.test_udfs import UDFsBasic -UDF_SCHEMA_YML = """ -functions: - - name: answer_to_everything - description: Computes the answer to life, universe and everything. - arguments: - - name: x - data_type: Int32 - returns: - data_type: Int32 +# we'll import helper used by the core test project to write directories + +MY_UDF_SQL = """ +price * 2 """.strip() -class TestUDFCreation: - # Original functions fixture: provide files for a dedicated 'functions' dir +class TestUDFBasics(UDFsBasic): @pytest.fixture(scope="class") def functions(self): return { - "answer_to_everything.sql": UDF_MODEL, - "answer_to_everything.yml": UDF_SCHEMA_YML, + "price_for_xlarge.sql": MY_UDF_SQL, + "price_for_xlarge.yml": files.MY_UDF_YML, } - - def test_create(self, project): - run_dbt(["build"]) - - result = project.run_sql("SELECT answer_to_everything(21)", fetch="one") - assert result[0] == 42 From 37472f65192a7557475363ab7e6c564ef296b92b Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Wed, 11 Mar 2026 23:09:17 +0100 Subject: [PATCH 7/8] fixup! Rebase with upstream and PR fixes --- dbt/adapters/clickhouse/relation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt/adapters/clickhouse/relation.py b/dbt/adapters/clickhouse/relation.py index efc1c907..3c60dc74 100644 --- a/dbt/adapters/clickhouse/relation.py +++ b/dbt/adapters/clickhouse/relation.py @@ -150,6 +150,7 @@ def create_from( if schema == relation_config.source_name and relation_config.database: schema = relation_config.database elif relation_config.resource_type == NODE_TYPE_FUNCTION: + # ClickHouse functions are global and don't belong to a schema, so we ignore the schema. schema = None else: # quoting is only available for non-source nodes From f71adf74c40b16e299e7bc4edc9b0f75bb484e45 Mon Sep 17 00:00:00 2001 From: Shachi Bista Date: Sat, 14 Mar 2026 20:35:37 +0100 Subject: [PATCH 8/8] Revert formatting changes to CHANGELOG --- CHANGELOG.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff2841f2..f92c599d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,7 +124,7 @@ For example: -- test_ttl.sql {{ config(order_by='(ts)', engine='MergeTree()', materialized='table') }} - SELECT now() AS ts, + SELECT now() AS ts, 'Some value that should expire!' AS col_ttl ``` @@ -160,7 +160,7 @@ For example: #### Improvements * It is now possible to configure a TLS client certificate using `client_cert` and `client_cert_key` profile parameters. ([#413](https://github.com/ClickHouse/dbt-clickhouse/pull/413)) * Added Support of insert_overwrite in cluster setup with incremental and distributed_incremental materializations ([#394](https://github.com/ClickHouse/dbt-clickhouse/pull/394)) -* Improve index and projections creation process ([#421](https://github.com/ClickHouse/dbt-clickhouse/pull/421)) +* Improve index and projections creation process ([#421](https://github.com/ClickHouse/dbt-clickhouse/pull/421)) #### Bugs * Reverted breaking changes in MV materialization ([#416](https://github.com/ClickHouse/dbt-clickhouse/pull/416)) @@ -179,7 +179,7 @@ For example: #### New Features * [ClickHouse indexes](https://clickhouse.com/docs/en/optimize/sparse-primary-indexes) are now fully supported for `table` materialization. -The index config should be added to the model config. for instance: +The index config should be added to the model config. for instance: ```python {{ config( materialized='%s', @@ -203,7 +203,7 @@ The index config should be added to the model config. for instance: * Removed support in python 3.8 as it is no longer supported by dbt ([#402](https://github.com/ClickHouse/dbt-clickhouse/pull/402) ### Bug Fixes -* Fix a minor bug related to validating existence of an old hanging mv ([#396]()) +* Fix a minor bug related to validating existence of an old hanging mv ([#396]()) ### Release [1.8.6], 2024-12-05 @@ -243,7 +243,7 @@ The index config should be added to the model config. for instance: ### Release [1.8.2], 2024-08-22 #### New Features * [ClickHouse projections](https://clickhouse.com/docs/en/sql-reference/statements/alter/projection) are now fully supported for `table` materialization, and partly supported for `distributed_table` materialization. -The projection config should be added to the model config ([#342](https://github.com/ClickHouse/dbt-clickhouse/pull/342)), for instance: +The projection config should be added to the model config ([#342](https://github.com/ClickHouse/dbt-clickhouse/pull/342)), for instance: ```python {{ config( materialized='%s', @@ -255,7 +255,7 @@ The projection config should be added to the model config ([#342](https://github ] ) }} ``` - + #### Bug Fixes * Until this release, when writing tests, it was not possible to pass empty seed data. ([#341](https://github.com/ClickHouse/dbt-clickhouse/pull/341)) * When a cluster was used, the adapter left a few `__dbt_backup` tables in the schema. After the fix, these backup tables are now properly dropped. ([#326](https://github.com/ClickHouse/dbt-clickhouse/pull/326)) @@ -271,9 +271,9 @@ The projection config should be added to the model config ([#342](https://github * Enhanced the clickhouse__listagg macro to support single field ordering with optional direction, ensuring compatibility with ClickHouse's sorting limitations. Added validation to prevent the use of multiple order-by fields. ([#318](https://github.com/ClickHouse/dbt-clickhouse/pull/318)) #### Documentation -* Update the docs with the new `insert_overwrite` incremental strategy. ([#331](https://github.com/ClickHouse/dbt-clickhouse/pull/331)) +* Update the docs with the new `insert_overwrite` incremental strategy. ([#331](https://github.com/ClickHouse/dbt-clickhouse/pull/331)) * Add documentation for codec column configuration. ([#317](https://github.com/ClickHouse/dbt-clickhouse/pull/317)) - + ### Release [1.8.1], 2024-07-11 #### Bug Fix @@ -330,7 +330,7 @@ for the PR! ### Release [1.7.4], 2024-03-23 #### Improvement - Adds support for materializing ClickHouse dictionaries. Thanks to [Rory Sawyer](https://github.com/SoryRawyer) for the contribution! -See his excellent [tests](https://github.com/ClickHouse/dbt-clickhouse/blob/main/tests/integration/adapter/dictionary/test_dictionary.py) +See his excellent [tests](https://github.com/ClickHouse/dbt-clickhouse/blob/main/tests/integration/adapter/dictionary/test_dictionary.py) for example usage. ### Release [1.7.3], 2024-03-11 @@ -387,7 +387,7 @@ do not support `CREATE TABLE AS SELECT ... EMPTY`, since the automatic deduplica inserts in Replicated tables on those older versions. Fixes https://github.com/ClickHouse/dbt-clickhouse/issues/216. ### Release [1.6.0], 2023-11-30 -#### Improvements +#### Improvements - Compatible with dbt 1.6.x. Note that dbt new `clone` feature is not supported, as ClickHouse has no native "light weight" clone functionality, and copying tables without actual data transfer is not possible in ClickHouse (barring file manipulation outside ClickHouse itself). @@ -476,7 +476,7 @@ https://github.com/ClickHouse/dbt-clickhouse/issues/167 #### Improvement - Added macros for creating distributed tables. See the `distributed_table.sql` include file. Thanks to -[gladkikhtutu](https://github.com/gladkikhtutu) for the contribution. +[gladkikhtutu](https://github.com/gladkikhtutu) for the contribution. ### Release [1.4.2], 2023-05-14 #### Bug fixes @@ -500,7 +500,7 @@ to non-overlapping data ranges. Closes https://github.com/ClickHouse/dbt-clickh - Adds additional dbt 1.4.0 tests - Adds support for incremental_predicates. This only applies to `delete+insert` incremental strategy. Note that incremental predicates that depend on "non-deterministic" data (such as a subquery using a table that is accepting inserts) could lead to -unexpected results for ReplicatedMergeTree tables depending on the timing of the incremental materialization. +unexpected results for ReplicatedMergeTree tables depending on the timing of the incremental materialization. - Replaces deprecated Exception classes - Setting the `use_lw_deletes` profile value to True will now attempt to enable the `allow_experimental_lightweight_delete` setting for the dbt session (if user has such permissions on the ClickHouse server). See https://github.com/ClickHouse/dbt-clickhouse/issues/133 @@ -513,7 +513,7 @@ setting for the dbt session (if user has such permissions on the ClickHouse serv #### Documentation Update - The documentation has been updated to reflect that dbt-clickhouse does support ephemeral models, and ephemeral model tests do pass. However, due to a [ClickHouse limitation](https://github.com/ClickHouse/ClickHouse/issues/30323), CTEs will not work directly -with INSERT statements so table models will fail if they include ephemeral models in the SELECT. View models and other SQL +with INSERT statements so table models will fail if they include ephemeral models in the SELECT. View models and other SQL statements using ephemeral models should work correctly. #### Bug Fix @@ -537,7 +537,7 @@ slower "legacy" strategy. [tests](https://github.com/ClickHouse/dbt-clickhouse/blob/main/tests/integration/adapter/test_s3.py) for example usage. #### Bug Fixes -- The ON CLUSTER clause has been added to additional DDL statements including incremental models processing. +- The ON CLUSTER clause has been added to additional DDL statements including incremental models processing. Closes https://github.com/ClickHouse/dbt-clickhouse/issues/117 and should close https://github.com/ClickHouse/dbt-clickhouse/issues/95 for Replicated tables that use the `{uuid}` macro in the path to avoid name conflicts. Thanks to [Saurabh Bikram](https://github.com/saurabhbikram) - The `apply` and `revoke` grants macros now correctly work with roles as well as user. Again thanks to [Saurabh Bikram](https://github.com/saurabhbikram)