Skip to content

Commit acc5b1d

Browse files
authored
Gg/release 0 8 9 (#434)
* Roll back timezone deprecation * Remove unused function aliases
1 parent b6a60a9 commit acc5b1d

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ release (0.9.0), unrecognized arguments/keywords for these methods of creating a
1111
instead of being passed as ClickHouse server settings. This is in conjunction with some refactoring in Client construction.
1212
The supported method of passing ClickHouse server settings is to prefix such arguments/query parameters with`ch_`.
1313

14+
## 0.8.9, 2024-12-02
15+
### Bug Fix
16+
- Roll back some timezone changes that caused incorrect usage of "local time" objects for some ClickHouse queries. Note that
17+
has deprecated "naive" timestamps; however converting everything to timezone aware objects (with the UTC timezone as appropriate)
18+
causes some numpy and possibly Pandas side effects. Eventually naive datetime object support will be deprecated/eliminated,
19+
but it will take some time to ensure no breaking changes. Fixes https://github.com/ClickHouse/clickhouse-connect/issues/433
20+
1421
## 0.8.8, 2024-11-27
1522
### Improvement
1623
- Handle low level HTTP errors as "Stream Complete". This provides better compatibility with the most recent

clickhouse_connect/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = '0.8.8'
1+
version = '0.8.9'

clickhouse_connect/datatypes/temporal.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ def _read_column_binary(self, source: ByteSource, num_rows: int, ctx: QueryConte
7979
return data_conv.read_date32_col(source, num_rows)
8080

8181

82-
from_ts_tz = datetime.fromtimestamp
83-
84-
8582
class DateTimeBase(ClickHouseType, registered=False):
8683
__slots__ = ('tzinfo',)
8784
valid_formats = 'native', 'int'
@@ -192,7 +189,7 @@ def _read_binary_tz(self, column: Sequence, tz_info: tzinfo):
192189
def _read_binary_naive(self, column: Sequence):
193190
new_col = []
194191
app = new_col.append
195-
dt_from = datetime.fromtimestamp
192+
dt_from = datetime.utcfromtimestamp
196193
prec = self.prec
197194
for ticks in column:
198195
seconds = ticks // prec

clickhouse_connect/driver/dataconv.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def read_ipv4_col(source: ByteSource, num_rows: int):
2828

2929
def read_datetime_col(source: ByteSource, num_rows: int, tz_info: Optional[tzinfo]):
3030
src_array = source.read_array('I', num_rows)
31+
if tz_info is None:
32+
fts = datetime.utcfromtimestamp
33+
return [fts(ts) for ts in src_array]
3134
fts = datetime.fromtimestamp
3235
return [fts(ts, tz_info) for ts in src_array]
3336

clickhouse_connect/tools/datagen.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from clickhouse_connect.datatypes.temporal import Date, Date32, DateTime, DateTime64
1919
from clickhouse_connect.driver.common import array_sizes
2020

21-
dt_from_ts = datetime.fromtimestamp
21+
dt_from_ts = datetime.utcfromtimestamp
22+
dt_from_ts_tz = datetime.fromtimestamp
2223
epoch_date = date(1970, 1, 1)
2324
date32_start_date = date(1925, 1, 1)
2425

@@ -137,7 +138,7 @@ def random_datetime():
137138

138139

139140
def random_datetime_tz(timezone: tzinfo):
140-
return dt_from_ts(int(random() * 2 ** 32), timezone).replace(microsecond=0)
141+
return dt_from_ts_tz(int(random() * 2 ** 32), timezone).replace(microsecond=0)
141142

142143

143144
def random_ascii_str(max_len: int = 200, min_len: int = 0):
@@ -171,7 +172,7 @@ def random_datetime64_tz(prec: int, timezone: tzinfo):
171172
u_sec = int(random() * 1000) * 1000
172173
else:
173174
u_sec = int(random() * 1000000)
174-
return dt_from_ts(int(random() * 4294967296), timezone).replace(microsecond=u_sec)
175+
return dt_from_ts_tz(int(random() * 4294967296), timezone).replace(microsecond=u_sec)
175176

176177

177178
def random_ipv6():

0 commit comments

Comments
 (0)