Skip to content

Commit ed20980

Browse files
Merge branch 'main' into joe/574-add-python-314-non-free-threaded-build-support
2 parents e842fb4 + 01761c1 commit ed20980

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The supported method of passing ClickHouse server settings is to prefix such arg
2424
## UNRELEASED
2525

2626
### Bug Fixes
27+
- Fixed DST fallback bug in DateTime and DateTime64 types caused by passing potentially ambiguous times to pd.DateTimeIndex constructor.
2728
- Fixed issue with JSON key dot escaping. Closes [#571](https://github.com/ClickHouse/clickhouse-connect/issues/571)
2829

2930
### Improvements

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ These tests require the `CLICKHOUSE_CONNECT_TEST_TLS` environment variable to be
116116
Additionally, the TLS ClickHouse instance should be running (see [docker-compose.yml](docker-compose.yml)).
117117

118118
```bash
119-
CLICKHOUSE_CONNECT_TEST_TLS=1 pytest tests/tls
119+
CLICKHOUSE_CONNECT_TEST_TLS=1 pytest tests/integration_tests/test_tls.py
120120
```
121121

122122
### Running the integration tests with ClickHouse Cloud

clickhouse_connect/common.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
import sys
33
from dataclasses import dataclass
44
from typing import Any, Sequence, Optional, Dict
5-
from clickhouse_connect import __version__
6-
75

6+
from clickhouse_connect import __version__
87
from clickhouse_connect.driver.exceptions import ProgrammingError
98

109

11-
def version():
10+
def version() -> str:
1211
return __version__.version
1312

1413

@@ -30,7 +29,7 @@ class CommonSetting:
3029
_common_settings: Dict[str, CommonSetting] = {}
3130

3231

33-
def build_client_name(client_name: str):
32+
def build_client_name(client_name: str) -> str:
3433
product_name = get_setting('product_name')
3534
product_name = product_name.strip() + ' ' if product_name else ''
3635
client_name = client_name.strip() + ' ' if client_name else ''
@@ -46,14 +45,14 @@ def build_client_name(client_name: str):
4645
return full_name.encode('ascii', 'ignore').decode()
4746

4847

49-
def get_setting(name: str):
48+
def get_setting(name: str) -> Any:
5049
setting = _common_settings.get(name)
5150
if setting is None:
5251
raise ProgrammingError(f'Unrecognized common setting {name}')
5352
return setting.value if setting.value is not None else setting.default
5453

5554

56-
def set_setting(name: str, value: Any):
55+
def set_setting(name: str, value: Any) -> None:
5756
setting = _common_settings.get(name)
5857
if setting is None:
5958
raise ProgrammingError(f'Unrecognized common setting {name}')
@@ -65,7 +64,7 @@ def set_setting(name: str, value: Any):
6564
setting.value = value
6665

6766

68-
def _init_common(name: str, options: Sequence[Any], default: Any):
67+
def _init_common(name: str, options: Sequence[Any], default: Any) -> None:
6968
_common_settings[name] = CommonSetting(name, options, default)
7069

7170

clickhouse_connect/datatypes/temporal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def _finalize_column(self, column: Sequence, ctx: QueryContext) -> Sequence:
8989
if column.tz is None:
9090
return column.astype(self.pandas_dtype)
9191

92-
naive = column.tz_localize(None).astype(self.pandas_dtype)
93-
return pd.DatetimeIndex(naive, tz=column.tz)
92+
naive = column.tz_convert("UTC").tz_localize(None).astype(self.pandas_dtype)
93+
return naive.tz_localize("UTC").tz_convert(column.tz)
9494

9595
if self.nullable and isinstance(column, list):
9696
return np.array([None if pd.isna(s) else s for s in column]).astype(
@@ -159,8 +159,8 @@ def _finalize_column(self, column: Sequence, ctx: QueryContext) -> Sequence:
159159
result = column.astype(self.pandas_dtype)
160160
return pd.array(result) if self.nullable else result
161161

162-
naive_ns = column.tz_localize(None).astype(self.pandas_dtype)
163-
tz_aware_result = pd.DatetimeIndex(naive_ns, tz=column.tz)
162+
naive_ns = column.tz_convert("UTC").tz_localize(None).astype(self.pandas_dtype)
163+
tz_aware_result = naive_ns.tz_localize("UTC").tz_convert(column.tz)
164164
return (
165165
pd.array(tz_aware_result) if self.nullable else tz_aware_result
166166
)

clickhouse_connect/driver/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async def create_async_client(*,
146146
dsn: Optional[str] = None,
147147
settings: Optional[Dict[str, Any]] = None,
148148
generic_args: Optional[Dict[str, Any]] = None,
149-
executor_threads: Optional[int] = None,
149+
executor_threads: int = 0,
150150
**kwargs) -> AsyncClient:
151151
"""
152152
The preferred method to get an async ClickHouse Connect Client instance.
@@ -168,7 +168,7 @@ async def create_async_client(*,
168168
:param settings: ClickHouse server settings to be used with the session/every request
169169
:param generic_args: Used internally to parse DBAPI connection strings into keyword arguments and ClickHouse settings.
170170
It is not recommended to use this parameter externally
171-
:param: executor_threads 'max_worker' threads used by the client ThreadPoolExecutor. If not set, the default
171+
:param executor_threads: 'max_worker' threads used by the client ThreadPoolExecutor. If not set, the default
172172
of 4 + detected CPU cores will be used
173173
:param kwargs -- Recognized keyword arguments (used by the HTTP client), see below
174174

0 commit comments

Comments
 (0)