Skip to content

Fix numeric rounding and comparisons in ClickHouse - #480

Draft
serprex wants to merge 1 commit into
mainfrom
rounding-zeroes
Draft

serprex wants to merge 1 commit into
mainfrom
rounding-zeroes

Conversation

@serprex

@serprex serprex commented Nov 21, 2026

Copy link
Copy Markdown
Member

ClickHouse keeps input's decimal places when rounding. Match Postgres when fetching rounded results, including with sum, min, and max.

Only push down round and trunc for constant scales between -19 & 32767.

ClickHouse reads fractional constants as Float64, so equal numeric values can fail to match. Cast fractional numeric constants to Decimal when they fit. Use bare literals on the left of / and % to avoid errors when a Decimal would have too few decimal places

ClickHouse keeps input's decimal places when rounding. Match Postgres
when fetching rounded results, including with sum, min, and max.

Only push down round and trunc for constant scales between -19 & 32767.

ClickHouse reads fractional constants as Float64, so equal numeric
values can fail to match. Cast fractional numeric constants to
Decimal when they fit. Use bare literals on the left of / and %
to avoid errors when a Decimal would have too few decimal places
@theory theory assigned serprex and serxa and unassigned serxa Nov 24, 2026
@theory theory added the data types Improve data type support label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data types Improve data type support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants