Skip to content

Don't push down functions by default#245

Merged
theory merged 2 commits into
mainfrom
default-unshippable
May 11, 2026
Merged

Don't push down functions by default#245
theory merged 2 commits into
mainfrom
default-unshippable

Conversation

@serprex
Copy link
Copy Markdown
Member

@serprex serprex commented May 9, 2026

Explicitly add functions which were falling through correctly by default

Include mapping mod/pow/power/bit_count/reverse/bit_and/bit_or/bit_xor

length(text) in PG is actually lengthUTF8 in CH

asin/acos/atanh/acosh not pushed down for now since they need range checks: on PG out-of-range is error, whereas on CH out-of-range returns NaN

@serprex serprex requested a review from theory May 9, 2026 18:28
@serprex serprex force-pushed the default-unshippable branch 15 times, most recently from 6726175 to 677d1ab Compare May 10, 2026 02:59
@serprex serprex marked this pull request as ready for review May 10, 2026 03:02
@serprex serprex force-pushed the default-unshippable branch 3 times, most recently from d8d091f to 6360d56 Compare May 10, 2026 03:27
Copy link
Copy Markdown
Collaborator

@theory theory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better than before. Good to have this cleaned up to avoid the legacy of the fork from postgres_fdw.

Seems like we could use a few more tests though, yes?

Comment thread src/custom_types.c
Comment thread src/custom_types.c
Comment thread doc/pg_clickhouse.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread test/expected/functions.out
Comment thread doc/pg_clickhouse.md
Comment thread doc/pg_clickhouse.md
Comment thread doc/pg_clickhouse.md
@theory theory added pushdown Improvements to query pushdown functions Improve function pushdown labels May 10, 2026
@serprex serprex force-pushed the default-unshippable branch from 6360d56 to 5ed2a0a Compare May 10, 2026 17:50
@serprex
Copy link
Copy Markdown
Member Author

serprex commented May 10, 2026

heavily expanded test suite. also fixed deparsing bytea, as ch doesn't support pg bytea syntax for strings

@serprex serprex requested a review from theory May 10, 2026 17:54
@serprex serprex force-pushed the default-unshippable branch from 5ed2a0a to 813a604 Compare May 10, 2026 18:00
Copy link
Copy Markdown
Collaborator

@theory theory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I can add the missing VERBOSEs and merge.

Comment thread test/expected/aggregates.out Outdated
Comment thread test/expected/window_functions.out
Make builtin function pushdown opt-in: Postgres builtins now ship to
ClickHouse only when explicitly mapped, so name or signature differences
cannot silently alter results.

Add explicit mappings for `mod`, `pow`/`power`, `bit_count(bytea)`, and
`reverse(text)` (→ `reverseUTF8`) to retain previously working
pushdowns.

Fix `editDistance`, `length(text)` and `strpos(text, text)` pushdown to
map to `lengthUTF8` and `positionUTF8` rather than ClickHouse's
byte-counting `length` and `position`, matching Postgres character
semantics.

Stop pushing down `asin`, `acos`, `atanh`, and `acosh`: Postgres raises
an error on out-of-range input where ClickHouse returns `NaN`.
Evaluating locally preserves Postgres semantics.

Add comprehensive tests for all of these behaviors.

Signed-off-by: David E. Wheeler <david.wheeler@clickhouse.com>
@theory theory force-pushed the default-unshippable branch from 813a604 to 6a0cb8e Compare May 11, 2026 19:19
@theory theory merged commit 6a0cb8e into main May 11, 2026
36 checks passed
@theory theory deleted the default-unshippable branch May 11, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Improve function pushdown pushdown Improvements to query pushdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants