Highlights
This release has many correctness fixes across inserts, query parameters, the Rust codec, and the SQLAlchemy and Alembic integration. It also adds new Alembic view and materialized view operations and makes several read and insert paths faster. It ships with clickhouse-connect-core 0.2.4.
Features
- Alembic can create ordinary and materialized views with explicit columns, a definer, and a SQL security mode.
op.modify_clickhouse_view_sql_securitychanges the mode or definer of an existing view. #1260 - Alembic materialized views support refresh schedules through
ClickHouseRefresh, inner engines, comments, andempty=True. New helpers modify refresh schedules and SELECT queries. All create forms now useCreateClickHouseMaterializedViewOp, so policy hooks should inspect itsengineandrefreshfields. #1204
Performance
query_dfis faster for results with many blocks, such as two-levelGROUP BYaggregations. Closes #1203. #1205query_npis faster for mixed-type results with object columns, about 18% on a 1M row, 10 column query. #1193Mapcolumn reads are faster with the C extensions, andquery_npandquery_dfare faster for numericMapcolumns without them. #1207- The Python codec builds
UUIDinsert columns in one pass. #1152
Bug Fixes
Inserts and types
- Python codec
UUIDinserts no longer write wrong values. Wrong-length byte values raiseDataError. A leadingNoneor unsupported value no longer decides the whole block. NaN andpd.NAininsert_dfstore the zero UUID. #1227 - Python codec inserts accept NumPy integer scalars in 128 and 256 bit int columns, NumPy float arrays in
BFloat16columns, and nestedDynamicvalues. #1232 - JSON values accept NumPy scalars and arrays, and row inserts accept NumPy
datetime64scalars inDateTimeandDateTime64columns. On the Rust codec this needsclickhouse-connect-core>=0.2.4. #1234 - Insert methods quote each part of database-qualified table names, and
create_tableandcreate_table_from_arrow_schemaquote column names. #1231 - Enum labels in client-supplied type names decode the same backslash escapes as the server parser. Closes #1191. #1194
Rust codec
query_np,query_dfand their streams return numeric and BoolLowCardinalitycolumns with the same dtypes as the Python codec, includingLowCardinality(Nullable(T)). Before,query_dfcould roundLowCardinality(UInt64)values above2**63. #1263
Raw binary query parameters
- Raw binary
$name$parameters are inserted only at markers outside comments, strings, identifiers and heredocs. A value that would end its own heredoc, or an earlier unclosed one, raisesProgrammingError. #1228, #1235
SQLAlchemy
metadata.create_all()anddrop_all()includeDictionaryobjects, andselect(dictionary)compiles. Dictionary DDL rejects unsupported column clauses withCompileError. #1220- Dictionary reflection handles array literal defaults and attribute options. Closes #1221 and #1222. #1233
limit_by()convertslimitandoffsetwithint(). #1218- On SQLAlchemy 1.4, selecting string literals or
Unicode,UnicodeTextorEnumcolumns no longer raisesTypeError. #1217 - Engine arguments
zk_path,replicaandconfig_sectionare escaped, and invalid setting names raiseValueError. #1224
Alembic
op.create_tablekeeps a positional engine,ClickHouseIndexorClickHouseProjection, assa.Tabledoes. #1224- Literal percent signs are preserved in DDL, operation helpers, autogenerate comparisons and offline output. #1206
- Autogenerate treats
([a, b])the same as[a, b], andalter_columnchecks forexisting_typebefore renaming.
Upgrade notes
A few fixes change behavior that existing code may work around:
- Percent signs: if you doubled
%in Alembic helpers or raw table clauses to work around the old behavior, use single percents now. AClickHouseIndexorClickHouseProjectioncreated from%%metadata on 1.13.0 or earlier is stored with%. Update the metadata to%before you run autogenerate, or it will drop and re-add the index or projection. - Positional
op.create_tableargs: positional indexes and projections used to be dropped without an error. If a later migration adds the same index as a workaround, it now fails on a fresh database. When both a positional and a keyword engine are given, the positional engine wins. - Engine string arguments: pass raw values for
zk_path,replicaandconfig_section. Values you escaped by hand will now be escaped twice.
See the CHANGELOG and the core CHANGELOG for full details.
Installation
pip install --upgrade clickhouse-connectRust codec users should upgrade both packages. Upgrading only the driver keeps an older installed core.
pip install --upgrade "clickhouse-connect[rust]==1.14.0" "clickhouse-connect-core==0.2.4"