Query functions in the Marisa DuckDB extension
Function category
Query
3 functionsMembership 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.
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
BLOB
|
Mode Positional | Description |
Argument
col1
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
col2
|
Type
INTEGER
|
Mode Positional | Description |
Description
Returns VARCHAR[] — every string in the trie that is a prefix of the search string, capped at max_results. The inverse of marisa_predictive: useful for routing tables, IP / CIDR label lookups, and longest-prefix-match style queries ("which rules match this input?").
SELECT marisa_common_prefix(trie, 'USA', 10) AS matches
FROM country_codes_trie;
-- ['U', 'US', 'USA']
Related functions
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
BLOB
|
Mode Positional | Description |
Argument
col1
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Returns BOOLEAN — true iff the search string is in the trie. The fastest membership test in this extension; an exact, allocation-free yes/no against the BLOB. Use it for spell-check, dictionary membership, or anywhere a hash set would otherwise live.
SELECT marisa_lookup(trie, 'duckling') AS in_dictionary
FROM words_trie;
Related functions
- marisa_predictive() — Returns `VARCHAR[]` — every string in the trie that **starts with** the given prefix, capped at `max_results`
- marisa_common_prefix() — Returns `VARCHAR[]` — every string in the trie that is **a prefix of** the search string, capped at `max_results`
- marisa_trie() — Aggregate that builds a MARISA trie from a column of strings
Signature
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
col0
|
Type
BLOB
|
Mode Positional | Description |
Argument
col1
|
Type
VARCHAR
|
Mode Positional | Description |
Argument
col2
|
Type
INTEGER
|
Mode Positional | Description |
Description
Returns VARCHAR[] — every string in the trie that starts with the given prefix, capped at max_results. The autocomplete primitive: feed it the user's partial input, get back the candidate completions. The cap is a hard cutoff so a short prefix on a million-entry dictionary doesn't return everything.
SELECT marisa_predictive(trie, 'duck', 10) AS suggestions
FROM words_trie;