Skip to content

Commit

Permalink
Release 0 6 14 (#246)
Browse files Browse the repository at this point in the history
* Fix FixedString padding of empty string

* Remove bad 3.7 import

* Update changelog
  • Loading branch information
genzgd authored Sep 22, 2023
1 parent eb7091a commit 4061d21
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ In any case, this should not affect the basic usage of Superset with ClickHouse.
your Superset installation, the ClickHouse datasource will be available with either the enhanced connection dialog
or a standard SqlAlchemy DSN in the form of `clickhousedb://{username}:{password}@{host}:{port}`.

## 0.6.14, TBD
### Bug Fixes
- Fixed insert error when inserting a zero length string into a FixedString column. Closes https://github.com/ClickHouse/clickhouse-connect/issues/244
- Removed unnecessary validate_entrypoints import from top level package __init__ that was breaking Python 3.7. Note that Python 3.7 is EOL
and will no longer be supported as of January 1, 2024.

## 0.6.13, 2023-09-20
### Bug Fix
- Fixed an issue with the automatic retry of "connection reset errors". This should prevent exceptions when the
Expand All @@ -32,7 +38,7 @@ to [Ashton Hudson](https://github.com/CaptainCuddleCube) for the report and the
### Bug fixes
- Inserts using Pandas 2.1 would fail due to a removed method in the Pandas library. There is now a workaround/fix for
this. Closes https://github.com/ClickHouse/clickhouse-connect/issues/234
- Inserts into a FixedString column that were not the expected size could cause corrupt insert blocksd and mysterious errors
- Inserts into a FixedString column that were not the expected size could cause corrupt insert blocks and mysterious errors
from the ClickHouse server. Validation has been added so that more meaningful error messages are generated if a fixed string
value is an invalid size. A reminder that strings which are "too short" for a FixedString column will be padded with 0 bytes, while
strings that are "too long" will generate an exception during the insert.
Expand Down
6 changes: 1 addition & 5 deletions clickhouse_connect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from clickhouse_connect.driver import create_client
from clickhouse_connect.entry_points import validate_entrypoints


driver_name = 'clickhousedb'


def get_client(**kwargs):
return create_client(**kwargs)


def check_ep():
assert validate_entrypoints() == 0
2 changes: 1 addition & 1 deletion clickhouse_connect/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.6.13'
version = '0.6.14'
6 changes: 2 additions & 4 deletions clickhouse_connect/datatypes/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def _write_column_binary(self, column: Union[Sequence, MutableSequence], dest: b
if len(b) > sz:
raise DataError(f'UTF-8 encoded FixedString value {b.hex(" ")} exceeds column size {sz}')
ext(b)
if len(b) < sz:
ext(empty[:-len(b)])
ext(empty[:sz - len(b)])
else:
for x in column:
try:
Expand All @@ -112,8 +111,7 @@ def _write_column_binary(self, column: Union[Sequence, MutableSequence], dest: b
if len(b) > sz:
raise DataError(f'UTF-8 encoded FixedString value {b.hex(" ")} exceeds column size {sz}')
ext(b)
if len(b) < sz:
ext(empty[:-len(b)])
ext(empty[:sz - len(b)])
elif self.nullable:
for b in column:
if not b:
Expand Down
3 changes: 2 additions & 1 deletion examples/write_perf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python -u

# pylint: disable=import-error
import time
import random
import clickhouse_driver # pylint: disable=import-error
import clickhouse_driver

import clickhouse_connect
from clickhouse_connect.tools.testing import TableContext
Expand Down
10 changes: 10 additions & 0 deletions tests/integration_tests/test_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,13 @@ def test_decimal_rounding(test_client: Client, table_context: Callable):
def test_empty_maps(test_client: Client):
result = test_client.query("select Cast(([],[]), 'Map(String, Map(String, String))')")
assert result.first_row[0] == {}


def test_fixed_str_padding(test_client: Client, table_context: Callable):
table = 'test_fixed_str_padding'
with table_context(table, 'key Int32, value FixedString(3)'):
test_client.insert(table, [[1, 'abc']])
test_client.insert(table, [[2, 'a']])
test_client.insert(table, [[3, '']])
result = test_client.query(f'select * from {table} ORDER BY key')
assert result.result_columns[1] == [b'abc', b'a\x00\x00', b'\x00\x00\x00']

0 comments on commit 4061d21

Please sign in to comment.