--- warning: DO NOT CHANGE THIS MANUALLY, THIS IS GENERATED BY https://github.com/duckdb/community-extensions repository, check README there title: trino_parity excerpt: | DuckDB Community Extensions Native Trino-compatible scalar functions (trino_*) for the cases where DuckDB's built-ins diverge from Trino on Unicode and byte-level inputs — Trino's simple per-code-point case mapping, code-point reverse, Java-whitespace trim, NFC normalize, and raw-bytes xxhash64/sha512/hmac_sha256 extension: name: trino_parity description: Native Trino-compatible scalar functions (trino_*) for the cases where DuckDB's built-ins diverge from Trino on Unicode and byte-level inputs — Trino's simple per-code-point case mapping, code-point reverse, Java-whitespace trim, NFC normalize, and raw-bytes xxhash64/sha512/hmac_sha256 version: 0.5.2 language: C++ build: cmake license: MIT maintainers: - apatrida repo: github: brikk/duckdb-trino-parity-extension ref: 0d6f9a1b2ca5a93f4ff813c2fdab9ef0b5a9c4ed variegata: dbdb85c502f82ddecab0779df092a6d1817f0b5a docs: hello_world: | INSTALL trino_parity FROM community; LOAD trino_parity; -- Trino's upper()/lower() are simple per-code-point mappings -- (Character.toUpperCase(int)), so German sharp-S is unchanged — -- DuckDB's built-in upper() gives 'STRAẞE' (U+1E9E): SELECT trino_upper('straße'); -- 'STRAßE' -- Unicode 16 data includes case pairs absent from older ICU snapshots: SELECT trino_lower(chr(11311)) = chr(11359) AS glagolitic_unicode16; -- true -- Java whitespace trim: tab / LF / CR / FF / VT are stripped -- (DuckDB's built-in trim() only strips spaces): SELECT trino_trim(E'\tx\n'); -- 'x' -- Code-point reverse (DuckDB's built-in reverse is grapheme-aware): SELECT trino_reverse('a😀b'); -- 'b😀a' -- The catalog of functions this extension provides: SELECT trino_name, arg_count, category FROM trino_meta(); -- 10 rows -- Discover descriptions, argument names, runnable examples and categories: SELECT function_name, parameters, description, examples, categories FROM duckdb_functions() WHERE starts_with(function_name, 'trino_'); -- 10 scalars + trino_meta extended_description: | `trino_parity` provides native `trino_(...)` scalar functions for the specific cases where DuckDB's built-ins diverge from Trino's documented behaviour on Unicode and byte-level inputs. Version 0.5.2 targets DuckDB 2.0.0 and adds SQL catalog documentation for all ten scalars and the `trino_meta()` table macro in `duckdb_functions()`: implementation-grounded descriptions, meaningful scalar argument names (including HMAC's `data, key` order), runnable examples and short categories. Function behavior, signatures and the ten-row, three-column `trino_meta()` result are unchanged. The legacy v1.5.6 source remains preserved in the descriptor's `variegata` pin; this update selects new source only for 2.0. The extension vendors ICU 76.1 / Unicode 16.0, fixing newer case mappings and NFC normalization data missing from the previous Unicode 13 snapshot. The compatibility target is Trino 483 on JDK 25. Matching version labels alone does not guarantee parity with other Trino/JDK combinations. It is designed to be loaded server-side by anything that pushes Trino-shaped predicates down to DuckDB. If a Trino connector naively pushes `WHERE lower(name) = 'apple'` down to DuckDB, the filter runs with different Unicode semantics in each engine, and rows visible to Trino can silently disappear from the result. This extension supplies **only the functions where that actually happens** — where DuckDB's built-in genuinely diverges and a native C++ reimplementation is required to match Trino. For the large majority of Trino functions DuckDB's built-in is already equivalent (or a trivial rename / operator / one-line rewrite), so a caller emits those directly against DuckDB — no extension needed. ### Concrete divergences fixed | Function | DuckDB built-in | Trino spec | `trino_*` result | |---|---|---|---| | `upper('ß')` (U+00DF) | `'ẞ'` (U+1E9E, utf8proc special case) | `'ß'` unchanged (simple per-code-point mapping) | matches Trino | | `reverse('cafe'+U+0301)` | grapheme-aware | code-point-only | matches Trino | | `trim` (tab/LF/CR/FF/VT) | not stripped | Java `Character.isWhitespace` strips them | matches Trino | | `xxhash64(varbinary)` | no direct built-in | XXH64, big-endian bytes | matches Trino | ### Function inventory `trino_meta()` catalogs the ten native functions the extension provides: - **String (ICU):** `trino_lower/1`, `trino_upper/1`, `trino_reverse/1`, `trino_trim/1`, `trino_ltrim/1`, `trino_rtrim/1`, `trino_normalize/1` — simple per-code-point case mapping (Trino's `Character.toUpperCase(int)` model — no `SpecialCasing` expansions or final-sigma rule), code-point reverse, and `Character.isWhitespace` trim, via statically-linked ICU 76.1 vendored into the binary (so Unicode behaviour is independent of the host DuckDB build). - **Hash (vendored):** `trino_xxhash64/1`, `trino_sha512/1`, `trino_hmac_sha256/2` — over raw `VARBINARY`, self-contained (no dependency on the `crypto` / `hashfuncs` community extensions). Empty HMAC keys are rejected with `Empty key`, matching Trino; empty messages and nonempty binary keys remain supported. The ten-function catalog and three-column `trino_meta()` schema are unchanged. Validation against pinned OpenJDK 25 covers all 1,112,064 valid Unicode scalar values and 99,825 NFC conformance column checks, with zero mismatches. See the [Unicode 16 validation report](https://github.com/brikk/duckdb-trino-parity-extension/blob/main/docs/REPORT-unicode16-validation.md) for provenance, commands, and the limits of that validation. These checks also pass on final DuckDB 2.0.0; see the [2.0 readiness report](https://github.com/brikk/duckdb-trino-parity-extension/blob/main/docs/REPORT-duckdb-2-readiness.md). Aligned Trino functions (e.g. `length`, `abs`, `year`, `substring`, `regexp_extract`) are intentionally NOT shipped — a caller emits them as bare DuckDB SQL. The full per-function Trino↔DuckDB mapping and the empirical audits that justify each decision are in the repository's `docs/`. Source and full divergence catalog: https://github.com/brikk/duckdb-trino-parity-extension extension_star_count: 1 extension_star_count_pretty: 1 extension_download_count: 843 extension_download_count_pretty: 843 image: '/images/community_extensions/social_preview/preview_community_extension_trino_parity.png' layout: community_extension_doc --- ### Compatibility Matrix This table covers all DuckDB releases that have not reached [end-of-life](https://duckdb.org/release_calendar), including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 | | :--- | :---: | :---: | :---: | :---: | :---: | | Linux AMD64 | ❌ | ❌ | ✅ | ✅ | ✅ | | Linux ARM64 | ❌ | ❌ | ✅ | ✅ | ✅ | | macOS AMD64 | ❌ | ❌ | ✅ | ✅ | ✅ | | macOS ARM64 | ❌ | ❌ | ✅ | ✅ | ✅ | | Windows AMD64 | ❌ | ❌ | ✅ | ✅ | ✅ | | Windows ARM64 | ❌ | ❌ | ❌ | ❌ | ❌ | | WebAssembly | ❌ | ❌ | ✅ | ✅ | ✅ | ### Installing and Loading ```sql INSTALL {{ page.extension.name }} FROM community; LOAD {{ page.extension.name }}; ``` {% if page.docs.hello_world %} ### Example ```sql {{ page.docs.hello_world }}``` {% endif %} {% if page.docs.extended_description %} ### About {{ page.extension.name }} {{ page.docs.extended_description }} {% endif %} ### Added Functions
| function_name | function_type | description | comment | examples | |-------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|------------------------------------------------| | trino_hmac_sha256 | scalar | Computes HMAC-SHA256 over raw data bytes with the supplied raw key bytes and returns a 32-byte BLOB, accepting empty data but rejecting an empty key with 'Empty key' as Trino does. | NULL | [trino_hmac_sha256('abc'::BLOB, 'key'::BLOB)] | | trino_lower | scalar | Converts each Unicode code point to its simple lowercase mapping using ICU 76.1 (Unicode 16), matching Trino 483 on JDK 25 without contextual rules or multi-code-point expansion. | NULL | [trino_lower('İSTANBUL')] | | trino_ltrim | scalar | Removes leading Java Character.isWhitespace code points, leaving trailing whitespace and non-breaking spaces (U+00A0, U+2007, U+202F) intact as Trino does. | NULL | [trino_ltrim(chr(9) \|\| 'hello')] | | trino_meta | table_macro | Lists the ten native Trino-parity scalar functions as trino_name, arg_count and category, excluding passthrough functions and this table macro. | NULL | [SELECT * FROM trino_meta()] | | trino_normalize | scalar | Normalizes a string to NFC using ICU 76.1 (Unicode 16), matching Trino's default normalization form with no form-selector overload. | NULL | [trino_normalize('cafe' \|\| chr(769))] | | trino_reverse | scalar | Reverses the Unicode code-point sequence, not grapheme clusters, preserving the UTF-8 bytes within each code point as Trino does. | NULL | [trino_reverse('cafe' \|\| chr(769))] | | trino_rtrim | scalar | Removes trailing Java Character.isWhitespace code points, leaving leading whitespace and non-breaking spaces (U+00A0, U+2007, U+202F) intact as Trino does. | NULL | [trino_rtrim('hello' \|\| chr(10))] | | trino_sha512 | scalar | Computes SHA-512 over raw bytes and returns the 64-byte digest as a BLOB, matching Trino's varbinary output. | NULL | [trino_sha512('abc'::BLOB)] | | trino_trim | scalar | Removes leading and trailing Java Character.isWhitespace code points, leaving non-breaking spaces (U+00A0, U+2007, U+202F) intact as Trino does. | NULL | [trino_trim(chr(9) \|\| 'hello' \|\| chr(10))] | | trino_upper | scalar | Converts each Unicode code point to its simple uppercase mapping using ICU 76.1 (Unicode 16), matching Trino 483 on JDK 25 without contextual rules or multi-code-point expansion (ß stays ß). | NULL | [trino_upper('straße')] | | trino_xxhash64 | scalar | Computes xxHash64 over raw bytes with seed 0 and returns the hash as an eight-byte big-endian BLOB, matching Trino's varbinary output. | NULL | [trino_xxhash64('abc'::BLOB)] | ### Overloaded Functions
This extension does not add any function overloads. ### Added Types
This extension does not add any types. ### Added Settings
| name | description | input_type | scope | aliases | typed_value | |----------------|---------------------------------------------------------|------------|--------|---------|-------------| | temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |