Skip to content

Add missing built-in function wrappers (printf, iif, concat, unixepoch, percentile family, ...) - #1495

Open
fnc12 wants to merge 5 commits into
devfrom
feature/missing-core-functions
Open

Add missing built-in function wrappers (printf, iif, concat, unixepoch, percentile family, ...)#1495
fnc12 wants to merge 5 commits into
devfrom
feature/missing-core-functions

Conversation

@fnc12

@fnc12 fnc12 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Adds wrappers for built-in SQLite functions that were missing from core_functions.h:

  • Scalar: printf (3.8.3), iif (3.32), sign (3.35), format, unixepoch (3.38), unhex (3.41), octet_length, timediff (3.43), concat, concat_ws (3.44), if_ (3.48), unistr, unistr_quote (3.50)
  • Aggregate: string_agg (3.44), median, percentile, percentile_cont, percentile_disc (3.51)

Each wrapper is gated by the SQLITE_VERSION_NUMBER it appeared in. The percentile family is gated by SQLITE_ENABLE_PERCENTILE (following the math-functions precedent — the amalgamation only compiles it in with that define). iif/if_ compute the result type as the common type of the branch arguments, overridable via a template argument like coalesce.

Runtime tests + statement serializer tests for every function; verified locally against SQLite 3.31.1, 3.51.0 (with percentile) and the system SQLite. The recent-version CI job is bumped from 3.50.4 to 3.51.0 with SQLITE_ENABLE_PERCENTILE. Completed iif() and scalar math functions entries are removed from TODO.md.

🤖 Generated with Claude Code

fnc12 and others added 3 commits August 8, 2026 20:26
New scalar functions: printf, iif, if_, sign, format, unixepoch, unhex,
octet_length, timediff, concat, concat_ws, unistr, unistr_quote.
New aggregate functions: string_agg, median, percentile, percentile_cont,
percentile_disc.

Each wrapper is gated by the SQLite version it appeared in; the percentile
family is gated by SQLITE_ENABLE_PERCENTILE following the math functions
precedent, since the amalgamation compiles it in only with that define.
The recent-version CI job is bumped to SQLite 3.51.0 with
SQLITE_ENABLE_PERCENTILE so the percentile family is exercised at runtime.
Removes the completed iif() and scalar math functions entries from TODO.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NopQNBFjcTmkQ9dzkakpeb
…to the percentile family

Tests compare the whole result vector against an expected vector with a
single REQUIRE per section instead of size/front assertion chains.
median/percentile/percentile_cont/percentile_disc accept the result type
as a template argument (defaulting to std::unique_ptr<double>).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NopQNBFjcTmkQ9dzkakpeb
printf/format, iif, sign, unixepoch, unhex, octet_length, timediff,
concat_ws, string_agg, unistr and the percentile family, with the
corresponding SQL shown in comments, sqlite.org-style.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NopQNBFjcTmkQ9dzkakpeb
@fnc12
fnc12 requested a review from trueqbit August 8, 2026 17:15
Comment thread dev/core_functions.h Outdated
Enable the functions via SFINAE only when a common type of the branch
arguments can be determined or the return type is explicitly specified,
and select the return type with if constexpr in the body.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NopQNBFjcTmkQ9dzkakpeb
@fnc12
fnc12 requested a review from trueqbit August 10, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants