Skip to content
DuckDB community extension

trino_parity

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

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 · SQL
INSTALL trino_parity FROM community;
LOAD trino_parity FROM community;

Try it in a temporary SQL session with trino_parity already loaded. Queries run in this tab; examples using files or services need their own setup.

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

Trino's upper()/lower() are simple per-code-point mappings

SQL
-- 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

Provided by brikk. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

trino_parity provides native trino_<name>(...) 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.

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
brikk/duckdb-trino-parity-extension
License
MIT
Maintainers
apatrida
Written in
C++
Build source
0d6f9a1b2ca5
Build definition
Community descriptor