Add pushdown support for uuidv7 and uuid_extract functions - #449
Add pushdown support for uuidv7 and uuid_extract functions#449darshil929 wants to merge 1 commit into
Conversation
Signed-off-by: darshil929 <darshilt.work29@gmail.com>
Review — and comparison with #173Thanks for this! I ran the full diff and verified the behaviour on a workspace. This PR (its rebased CI copy is #456) and #173 implement the same feature independently. Overall this is the more correct of the two implementations; my notes and one suggested change below. What's right here
One correctness fix to make: PG 17The gating and the comments assume these functions are "Postgres 18+ only", but that's not accurate:
So gating everything at
Net: this PR's variant-checked Minor
|
| RETURNS smallint | ||
| LANGUAGE C | ||
| IMMUTABLE PARALLEL SAFE STRICT | ||
| AS 'MODULE_PATHNAME', $function$pg_lake_internal_dummy_function$function$; |
There was a problem hiding this comment.
should move into 3.4--3.5.sql now, 3.4 has been released
|
Thanks for the detailed review and the comparison, really appreciate the time spent on it. Good catch on the PG 17 gating, I had wrongly assumed the extract functions were new in 18 along with uuidv7. The version argument approach looks like the right way to handle it. Let me know if anything is needed from my side. |
Description
Adds pushdown support for the PostgreSQL 18 UUID functions
uuidv7(),uuid_extract_timestamp()anduuid_extract_version().The zero-arg
uuidv7()is shipped directly since DuckDB's implementation matches PostgreSQL. The two extract functions cannot be shipped as-is because DuckDB's semantics diverge:uuid_extract_timestamperrors in DuckDB for anything that is not v7, while PostgreSQL returns the embedded timestamp for v1 UUIDs and NULL for other versions.uuid_extract_versionin DuckDB returns the raw version nibble without the RFC 9562 variant check, so for example a nil UUID yields 0 where PostgreSQL returns NULL.Following the existing
acosh_pg/initcap_pgpattern, queries are rewritten touuid_extract_timestamp_pg/uuid_extract_version_pgwrappers implemented in duckdb_pglake with the PostgreSQL semantics ported from the PG 18 sources, including the v1 Gregorian timestamp arithmetic and the variant check.uuidv7(interval)has no DuckDB equivalent and stays unshipped, evaluated by PostgreSQL as before. The shippable entries are gated to PG 18+ so the eager catalog lookup keeps working on PG 16/17.Tests cover the rewrite in the remote query, result parity between an iceberg table and an identical heap table for v1/v4/v7/nil/max UUIDs, v7 generation via pushed-down
uuidv7(), and the interval variant staying local. They skip on PostgreSQL < 18.closes: #149