Acronym-Aware Case Conversions in the DuckDB Inflector Extension
The Inflector extension for DuckDB now supports configurable acronyms, so case conversions preserve terms like HTML, API, and URL as fully uppercase — configured through a native DuckDB setting.
The Problem
Case conversion libraries typically treat every word the same. Convert html_parser to PascalCase and you get HtmlParser. But in most codebases, the expected result is HTMLParser — because HTML is an acronym, not a regular word.
The same issue appears everywhere: api_url becomes ApiUrl instead of APIURL, json_parser becomes JsonParser instead of JSONParser. If you’re using case conversions to normalize column names across systems, this mismatch matters.
The Inflector extension for DuckDB now handles this.
Configuring Acronyms
Acronyms are configured via a native DuckDB setting called inflector_acronyms. It accepts a list of strings:
INSTALL inflector FROM community;
LOAD inflector;
SET inflector_acronyms = ['HTML', 'API', 'URL', 'JSON'];
Once set, all case conversions that use mixed case will preserve these terms as fully uppercase.
How It Works
PascalCase and camelCase
These are the styles where acronym handling matters most:
SET inflector_acronyms = ['HTML', 'API', 'URL'];
SELECT inflector_to_pascal_case('html_parser');
-- HTMLParser
SELECT inflector_to_pascal_case('parse_html_document');
-- ParseHTMLDocument
SELECT inflector_to_camel_case('parse_html');
-- parseHTML
SELECT inflector_to_camel_case('get_api_url');
-- getAPIURL
Note that the first word in camelCase is always lowercase, even when it’s an acronym — html_parser becomes htmlParser, not HTMLParser. This matches the standard camelCase convention.
Title Case, Train-Case, and Sentence Case
Acronyms are also preserved in these styles:
SELECT inflector_to_title_case('html_parser');
-- HTML Parser
SELECT inflector_to_train_case('html_parser');
-- HTML-Parser
SELECT inflector_to_sentence_case('parse_html_document');
-- Parse HTML document
Styles That Are Unaffected
Styles that produce all-lowercase or all-uppercase output don’t need acronym handling — they already have uniform casing:
SELECT inflector_to_snake_case('HTMLParser');
-- html_parser
SELECT inflector_to_kebab_case('HTMLParser');
-- html-parser
SELECT inflector_to_screamingsnake_case('html_parser');
-- HTML_PARSER
Predicates Respect Acronyms Too
The is_* predicate functions use the same acronym configuration when checking whether a string matches a case style:
SET inflector_acronyms = ['HTML'];
SELECT inflector_is_pascal_case('HTMLParser');
-- true
SELECT inflector_is_pascal_case('HtmlParser');
-- false (with HTML configured as an acronym, this is no longer valid PascalCase)
Struct and Column Name Inflection
The inflect() function works with acronyms for both struct field names and table column names:
SET inflector_acronyms = ['HTML', 'API'];
SELECT inflect('pascal', {'html_parser': 1, 'api_url': 2});
-- {'HTMLParser': 1, 'APIURL': 2}
SELECT * FROM inflect('camel', (SELECT 'x' AS html_parser, 'y' AS api_url));
-- htmlParser | apiURL
Why a DuckDB Setting?
An earlier version of this feature used three SQL functions: inflector_set_acronyms(), inflector_get_acronyms(), and inflector_clear_acronyms(). This worked, but it wasn’t idiomatic DuckDB.
DuckDB settings are the standard way to handle extension configuration. They integrate with SET/RESET, they’re discoverable via duckdb_settings(), and they don’t require wrapping configuration changes in SELECT statements.
The new approach is cleaner:
-- Configure
SET inflector_acronyms = ['HTML', 'API', 'URL'];
-- Clear
RESET inflector_acronyms;
Implementation
The acronym handling is implemented in the Rust layer of the extension using the cruet crate. The DuckDB setting callback converts the LIST(VARCHAR) value to a comma-separated string and passes it to the Rust code, which stores the acronyms in a thread-safe global with a read-write lock.
Single-character tokens are silently ignored — acronyms must be at least 2 characters.
Get It
The Inflector extension is available in the DuckDB Community Extensions:
INSTALL inflector FROM community;
LOAD inflector;
Source code: github.com/Query-farm/inflector