This release makes binary-compatible changes to the v0.10 releases. Once installed, any existing use of pg_clickhouse v0.10 will benefit from its improvements on reload. The one exception is clickhouse_raw_query(), which has been dropped in this version and will no longer work. We recommend running this command to drop this function:
ALTER EXTENSION pg_clickhouse UPDATE TO '0.11';🚨 Compatibility
-
Removed
clickhouse_raw_query(), deprecated in v0.10.0. Useclickhouse_query(server, sql)to read rows andCALL clickhouse_perform(server, sql)to run statements that return none; both take a foreign server rather than a connection string (#346). -
Removed the
fetch_sizeserver and table options, deprecated in v0.10.0. It's no longer necessary as both the http and the binary driver stream results by ClickHouse Native protocol Block (#381). -
This release validates the character encoding of text and JSON data fetched from ClickHouse, raising an error for violations of the Postgres database encoding. Add the new
encoding_checkoption to any servers that return invalidly-encoded data to eliminate the errors:ALTER SERVER server_name OPTIONS (ADD encoding_check 'replace');Valid values are
fail,replace,remove, andtruncate. See the CREATE SERVER docs for details (#361)
⬆️ Dependencies
- Dropped support for PostgreSQL 13.
- Updated the vendored pg-clickhouse-c, which now parses unflattened
Nested,SimpleAggregateFunction, and parameterizedJSONtypes (#363).
⚡ Improvements
IMPORT FOREIGN SCHEMAnow preserves type modifiers through nestedArraylayers, soArray(Decimal(12,6))imports asnumeric(12,6)[]. It retains up to six digits ofDateTime64(P)andTime64(P)precision, importsTime,Time64, and geometric types, and mapsFixedString(N)to unconstrainedtextbecause ClickHouse counts bytes while PostgreSQL character limits count characters (#349).IMPORT FOREIGN SCHEMAnow mapsBFloat16torealandIntervaltypes tointerval.IntervalNanosecondtruncates to microseconds.Intervaltypes also map tobiginttransparently (#349, #374).IMPORT FOREIGN SCHEMAnow mapsInt128,Int256,UInt128, andUInt256columns tonumericrather than erroring, andUInt64tonumericrather than erroring above thebigintmaximum. It declares the fewest digits, soUInt64becomesnumeric(20,0)(#355).- A
TupleorMapcolumn read into a PostgreSQL array now fills the array with each record's fields rather than a record literal, so{'k': 'v'}becomes as{{k,v}}rather than{"(k,v)"}.IMPORT FOREIGN SCHEMAdeclares such columnstext[]andtext[][]; thebinarydriver accepts those same types onINSERT, parsing each item as the field it fills. A composite ortextcolumn can still be mapped to a record (#349). IMPORT FOREIGN SCHEMAnow correctly imports aggregate states with literal parameters or multiple arguments. It uses the first argument as the column type and stores the aggregate function name, without parameters, in a column option. BecauseAggregateFunction(count)has no argument type, it imports asbigint(#349, #363).IMPORT FOREIGN SCHEMAnow importsNestedcolumns created withflatten_nested=0astext[][], with one array per nested row. It also imports parameterizedJSONasjsonbby default, which can be mapped manually tojsonortext, and readsSimpleAggregateFunctioncolumns. These types previously caused errors (#363).- Added pushdown for PostgreSQL
sha224(),sha256(),sha384(), andsha512()functions, along with supported constant-algorithm calls to the pgcrypto extension'sdigest()function. Thanks to Siva Girish Ramesh for the PR (#360). - On ClickHouse 26.9+, pushed-down
cardinalitynow maps to arrayFlattenedLength, which counts every element across nested arrays as PostgreSQL does. Earlier ClickHouse versions still uselength, which counts only the outer array (#367). - Added pushdown for multidimensional array indexing in
WHEREclauses (WHERE foo[1][1] = 'abc') (#373)
📚 Documentation
- Expanded the Composite Types section of the documentation to detail the behaviors of Array, Tuple, Map, and Nested data type mappings, all of which have been improved but have caveats.
🐞 Bug Fixes
- Fixed inserting
intervalvalues with HTTP driver. Values are now encoded based on destination's ClickHouse schema (#376). - Fixed
regexp_replace()pushdown passing flags to ClickHouse unmapped, which failed forn/p/t/w. Flags now translate as they do for other regular expression functions (#377). - Fixed pushdown of date and timestamp arithmetic dropping sub-second interval precision, such as
ts + interval '0.5 seconds'(#377). - Fixed an issue where a check for ordered aggregates incorrectly handled custom aggregates that were not part of an extension. It now properly keeps custom aggregate execution local. Thanks to Minh Vu for the PR (#337)!
- Fixed precision loss when pushing down numeric
pow()andpower()expressions; they now execute locally in PostgreSQL. Thanks to Minh Vu for the PR (#339)! IMPORT FOREIGN SCHEMAnow quotes strings in foreign table DDL as PostgreSQL literals rather than ClickHouse literals, so a ClickHouse name, database, or engine no longer doubles backslashes (#350).INSERTwith thebinarydriver now rejects values wider than aFixedString(N)column rather than silently truncating them, matching HTTP driver errors (#349).- Reading a ClickHouse string into a text column validates its bytes against the database encoding, raising an error rather than returning invalid text. Use the new
encoding_checkserver option to remove or replace invalid bytes, or declare the columnbyteato keep raw bytes (#359).
🆚 For more detail compare changes since v0.10.0.