Inflection functions in the Inflector DuckDB extension
Sample data for the examples
Each browser example starts with these sample tables; sample files are shared across examples on this page. Run this setup first when trying the examples in your own DuckDB session.
-- Fixtures for inflector cookbook / technical-details / functions.json examples.
-- Small, deterministic, idempotent. Backs snippets that read from
-- `api_events` (struct payload), `models` (class names), `mixed_input`
-- (raw case-mixed strings), and `left_records` / `right_records` (dedupe pair).
CREATE OR REPLACE TABLE api_events (
id INTEGER,
payload STRUCT(firstName TEXT, lastName TEXT)
);
INSERT INTO api_events VALUES
(1, {'firstName': 'John', 'lastName': 'Doe'}),
(2, {'firstName': 'Jane', 'lastName': 'Roe'}),
(3, {'firstName': 'Mary', 'lastName': 'Sue'});
CREATE OR REPLACE TABLE models (
class_name TEXT
);
INSERT INTO models VALUES
('UserAccount'),
('Message'),
('Order');
CREATE OR REPLACE TABLE mixed_input (
raw TEXT
);
INSERT INTO mixed_input VALUES
('helloWorld'),
('HelloWorld'),
('hello_world'),
('hello-world');
CREATE OR REPLACE TABLE left_records (
id INTEGER,
name TEXT
);
INSERT INTO left_records VALUES
(1, 'helloWorld'),
(2, 'fooBar');
CREATE OR REPLACE TABLE right_records (
id INTEGER,
name TEXT
);
INSERT INTO right_records VALUES
(10, 'hello_world'),
(20, 'foo_bar');
-- Small files for the file-ingestion examples, in the browser's filesystem.
COPY (SELECT 'Ada' AS firstName, 'Lovelace' AS lastName, '[email protected]' AS emailAddress)
TO 'users.csv' (HEADER true);
COPY (SELECT 'Ada' AS firstName, 'Lovelace' AS lastName)
TO 'data.csv' (HEADER true);
COPY (SELECT 'Ada' AS firstName, 'Lovelace' AS lastName)
TO 'events.json' (FORMAT JSON, ARRAY true);
Function category
Inflection
2 functionsEnglish plural / singular conversion. Handles irregulars (person → people, mouse → mice).
Signature
inflector_to_plural(word: VARCHAR) → VARCHAR
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
word
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Pluralize an English word — handles irregulars (person→people, mouse→mice).
1
Pluralize
SELECT inflector_to_plural('person');
Related functions
Signature
inflector_to_singular(word: VARCHAR) → VARCHAR
Arguments (Positional)
| Argument | Type | Mode | Description |
|---|---|---|---|
Argument
word
|
Type
VARCHAR
|
Mode Positional | Description |
Description
Singularize an English word. The v1.5 source fix 8628623 (extension version 2026100701) adds people → person and children → child, preserving the suffix case and compound prefixes. The DuckDB 2.0 builds in the Query.Farm repository include it; the older community build ac9b69f (DuckDB 1.5) leaves those plurals unchanged.
1
Example 1
SELECT inflector_to_singular('people');
Output
| inflector_to_singular('people') |
|---|
| person |