Skip to content

Query functions in the Marisa DuckDB extension

Function category

Query

3 functions

Membership tests, autocomplete (predictive prefix), and longest-prefix-match against an existing trie BLOB. All three primitives run in O(|key|) — lookup work is independent of dictionary size.

marisa_common_prefix

Scalar function Query
Signature
marisa_common_prefix( col0: BLOB, col1: VARCHAR, col2: INTEGER ) VARCHAR[]
Arguments (Positional)
Argument col0 Type BLOB Mode Positional Description
Argument col1 Type VARCHAR Mode Positional Description
Argument col2 Type INTEGER Mode Positional Description
Description
1 Find every country-code prefix that matches an input
SELECT marisa_common_prefix(trie, 'USA', 10) AS matches
FROM country_codes_trie;
-- ['U', 'US', 'USA']

marisa_lookup

Scalar function Query
Signature
marisa_lookup(col0: BLOB, col1: VARCHAR) BOOLEAN
Arguments (Positional)
Argument col0 Type BLOB Mode Positional Description
Argument col1 Type VARCHAR Mode Positional Description
Description
1 Spell-check against an English wordlist trie
SELECT marisa_lookup(trie, 'duckling') AS in_dictionary
FROM words_trie;

marisa_predictive

Scalar function Query
Signature
marisa_predictive( col0: BLOB, col1: VARCHAR, col2: INTEGER ) VARCHAR[]
Arguments (Positional)
Argument col0 Type BLOB Mode Positional Description
Argument col1 Type VARCHAR Mode Positional Description
Argument col2 Type INTEGER Mode Positional Description
Description
1 Type-ahead suggestions for a search box
SELECT marisa_predictive(trie, 'duck', 10) AS suggestions
FROM words_trie;