Skip to content

Conversation

@theory
Copy link
Collaborator

@theory theory commented Nov 19, 2025

The mappings already work for the HTTP engine, although its inserts were limited to float8, now fixed to use proper numeric formatting.

Add the mappings for the binary engine. Use strings to convert between the Postgres and ClickHouse formats to as to avoid differences in their implementations: ClickHouse stores data as Int32, Int64, or Int128, while Postgres...well, I have no idea what the internals are, but using the numeric_in and numeric_out functions avoid all issues.

Conversion from Decimal values returned from ClickHouse requires converting its internal Int128 into a string. The clickhouse-cpp library doesn't provide this functionality, yet, so implement it here.

Unfortunately, this approach doesn't work with clickhouse-cpp compiled into a dynamic library, presumably because it doesn't also compile and install the absl dynamic library. So make the build static by default on all platforms for now.

Add a test that covers both the HTTP and binary engines.

@theory theory self-assigned this Nov 19, 2025
Base automatically changed from json to main November 20, 2025 19:32
@theory theory force-pushed the decimal branch 2 times, most recently from 2a2f260 to 70cc2cf Compare November 20, 2025 20:05
The mappings already work for the HTTP engine, although its inserts were
limited to `float8`, now fixed to use proper numeric formatting.

Add the mappings for the binary engine. Use strings to convert between
the Postgres and ClickHouse formats to as to avoid differences in their
implementations: ClickHouse stores data as `Int32`, `Int64`, or
`Int128`, while Postgres...well, I have no idea what the internals are,
but using the `numeric_in` and `numeric_out` functions avoid all issues.

Conversion from `Decimal` values returned from ClickHouse requires
converting its internal `Int128` into a string. The clickhouse-cpp
library doesn't provide this functionality, [yet], so implement it here.

Unfortunately, this approach doesn't work with clickhouse-cpp compiled
into a dynamic library, presumably because it doesn't also compile and
install the `absl` dynamic library. So make the build static by default
on all platforms for now.

Add a test that covers both the HTTP and binary engines.

  [yet]: ClickHouse/clickhouse-cpp#451
@theory theory marked this pull request as ready for review November 20, 2025 21:18
@theory theory requested a review from serprex November 20, 2025 21:18
@theory theory requested a review from serprex November 20, 2025 22:10
@theory theory merged commit 1ea5e73 into main Nov 21, 2025
38 checks passed
@theory theory deleted the decimal branch November 21, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants