Add missing built-in function wrappers (printf, iif, concat, unixepoch, percentile family, ...) - #1495
Open
fnc12 wants to merge 5 commits into
Open
Add missing built-in function wrappers (printf, iif, concat, unixepoch, percentile family, ...)#1495fnc12 wants to merge 5 commits into
fnc12 wants to merge 5 commits into
Conversation
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
trueqbit
approved these changes
Aug 10, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds wrappers for built-in SQLite functions that were missing from
core_functions.h: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)string_agg(3.44),median,percentile,percentile_cont,percentile_disc(3.51)Each wrapper is gated by the
SQLITE_VERSION_NUMBERit appeared in. The percentile family is gated bySQLITE_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 likecoalesce.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. Completediif()and scalar math functions entries are removed from TODO.md.🤖 Generated with Claude Code