Skip to content

Commit 2e72a00

Browse files
authored
Release 1 7 0 (#220)
* Initial dependency updates for 1.7.x * Initial dependency updates for 1.7.x
1 parent e6e74e4 commit 2e72a00

File tree

5 files changed

+50
-42
lines changed

5 files changed

+50
-42
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### Release [1.7.0], 2023-12-07
2+
#### Improvements
3+
- Minimal compatibility with dbt 1.7.x. The date_spine macro and additional automated tests have not been implemented,
4+
but are planned for a future patch release.
5+
- DBT 1.7 introduces a (complex) optimization mechanism for retrieving a dbt catalog which is overkill for ClickHouse
6+
(which has no separate schema/database level), so this release includes some internal catalog changes to simplify that process.
7+
18
### Release [1.6.2], 2023-12-06
29
#### Bug Fix
310
- The dbt `on_schema_change` configuration value for incremental models was effectively being ignored. This has been fixed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = '1.6.2'
1+
version = '1.7.0'

dbt/adapters/clickhouse/impl.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import csv
22
import io
3-
from concurrent.futures import Future
43
from dataclasses import dataclass
5-
from typing import Any, Callable, Dict, List, Optional, Set, Union
4+
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
65

76
import agate
87
from dbt.adapters.base import AdapterConfig, available
9-
from dbt.adapters.base.impl import BaseAdapter, ConstraintSupport, catch_as_completed
8+
from dbt.adapters.base.impl import BaseAdapter, ConstraintSupport
109
from dbt.adapters.base.relation import BaseRelation, InformationSchema
10+
from dbt.adapters.capability import Capability, CapabilityDict, CapabilitySupport, Support
1111
from dbt.adapters.sql import SQLAdapter
1212
from dbt.contracts.graph.manifest import Manifest
1313
from dbt.contracts.graph.nodes import ConstraintType, ModelLevelConstraint
14-
from dbt.contracts.relation import RelationType
14+
from dbt.contracts.relation import Path, RelationType
1515
from dbt.events.functions import warn_or_error
1616
from dbt.events.types import ConstraintNotSupported
1717
from dbt.exceptions import DbtInternalError, DbtRuntimeError, NotImplementedError
18-
from dbt.utils import executor, filter_null_values
18+
from dbt.utils import filter_null_values
1919

20+
import dbt
2021
from dbt.adapters.clickhouse.cache import ClickHouseRelationsCache
2122
from dbt.adapters.clickhouse.column import ClickHouseColumn
2223
from dbt.adapters.clickhouse.connections import ClickHouseConnectionManager
@@ -56,6 +57,13 @@ class ClickHouseAdapter(SQLAdapter):
5657
ConstraintType.foreign_key: ConstraintSupport.NOT_SUPPORTED,
5758
}
5859

60+
_capabilities: CapabilityDict = CapabilityDict(
61+
{
62+
Capability.SchemaMetadataByRelations: CapabilitySupport(support=Support.Unsupported),
63+
Capability.TableLastModifiedMetadata: CapabilitySupport(support=Support.Unsupported),
64+
}
65+
)
66+
5967
def __init__(self, config):
6068
BaseAdapter.__init__(self, config)
6169
self.cache = ClickHouseRelationsCache()
@@ -295,37 +303,29 @@ def get_ch_database(self, schema: str):
295303
except DbtRuntimeError:
296304
return None
297305

298-
def get_catalog(self, manifest):
299-
schema_map = self._get_catalog_schemas(manifest)
300-
301-
with executor(self.config) as tpe:
302-
futures: List[Future[agate.Table]] = []
303-
for info, schemas in schema_map.items():
304-
for schema in schemas:
305-
futures.append(
306-
tpe.submit_connected(
307-
self,
308-
schema,
309-
self._get_one_catalog,
310-
info,
311-
[schema],
312-
manifest,
313-
)
314-
)
315-
catalogs, exceptions = catch_as_completed(futures)
316-
return catalogs, exceptions
317-
318-
def _get_one_catalog(
319-
self,
320-
information_schema: InformationSchema,
321-
schemas: Set[str],
322-
manifest: Manifest,
323-
) -> agate.Table:
324-
if len(schemas) != 1:
325-
raise DbtRuntimeError(
326-
f"Expected only one schema in clickhouse _get_one_catalog, found ' f'{schemas}'"
327-
)
328-
return super()._get_one_catalog(information_schema, schemas, manifest)
306+
def get_catalog(self, manifest) -> Tuple[agate.Table, List[Exception]]:
307+
relations = self._get_catalog_relations(manifest)
308+
schemas = set(relation.schema for relation in relations)
309+
if schemas:
310+
catalog = self._get_one_catalog(InformationSchema(Path()), schemas, manifest)
311+
else:
312+
catalog = dbt.clients.agate_helper.empty_table()
313+
return catalog, []
314+
315+
def get_filtered_catalog(
316+
self, manifest: Manifest, relations: Optional[Set[BaseRelation]] = None
317+
):
318+
catalog, exceptions = self.get_catalog(manifest)
319+
if relations and catalog:
320+
relation_map = {(r.schema, r.identifier) for r in relations}
321+
322+
def in_map(row: agate.Row):
323+
s = _expect_row_value("table_schema", row)
324+
i = _expect_row_value("table_name", row)
325+
return (s, i) in relation_map
326+
327+
catalog = catalog.where(in_map)
328+
return catalog, exceptions
329329

330330
def get_rows_different_sql(
331331
self,

dev_requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
dbt-core~=1.6.9
2-
clickhouse-connect>=0.6.21
1+
dbt-core~=1.7.3
2+
clickhouse-connect>=0.6.22
33
clickhouse-driver>=0.2.6
44
pytest>=7.2.0
55
pytest-dotenv==0.5.2
6-
dbt-tests-adapter~=1.6.9
6+
dbt-tests-adapter~=1.7.3
77
black==23.11.0
88
isort==5.10.1
99
mypy==0.991

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _dbt_clickhouse_version():
2525
package_version = _dbt_clickhouse_version()
2626
description = '''The Clickhouse plugin for dbt (data build tool)'''
2727

28-
dbt_version = '1.6.0'
28+
dbt_version = '1.7.0'
2929
dbt_minor = '.'.join(dbt_version.split('.')[0:2])
3030

3131
if not package_version.startswith(dbt_minor):
@@ -55,7 +55,7 @@ def _dbt_clickhouse_version():
5555
},
5656
install_requires=[
5757
f'dbt-core~={dbt_version}',
58-
'clickhouse-connect>=0.6.21',
58+
'clickhouse-connect>=0.6.22',
5959
'clickhouse-driver>=0.2.6',
6060
],
6161
python_requires=">=3.8",
@@ -70,5 +70,6 @@ def _dbt_clickhouse_version():
7070
'Programming Language :: Python :: 3.9',
7171
'Programming Language :: Python :: 3.10',
7272
'Programming Language :: Python :: 3.11',
73+
'Programming Language :: Python :: 3.12',
7374
],
7475
)

0 commit comments

Comments
 (0)