fix: raise on empty-array input to set() constructor#11
Merged
nhungoc1508 merged 5 commits intomainfrom Apr 27, 2026
Merged
Conversation
Set_constructor in src/temporal/set_functions.cpp built a Datum array
from a DuckDB list and called set_make_free without checking length.
On an empty input list MEOS returns NULL, which the wrapper wrote
into the result blob, surfacing later as "Null pointer not allowed".
Adds an explicit length == 0 check that raises
InvalidInputException("The input array cannot be empty"), matching
MEOS's own error message for the equivalent path.
The corresponding parity query is rewritten from PG-array-literal
form set('{}'::timestamptz[]) (which DuckDB rejects at the cast
layer) to the DuckDB-native ARRAY[]::TIMESTAMPTZ[] form so it
reaches the constructor wrapper.
5ff5c56 to
04ba378
Compare
This was referenced Apr 25, 2026
Set_constructor in src/temporal/set_functions.cpp built a Datum array
from a DuckDB list and called set_make_free without checking length.
On an empty input list MEOS returns NULL, which the wrapper wrote
into the result blob, surfacing later as "Null pointer not allowed".
Adds an explicit length == 0 check that raises
InvalidInputException("The input array cannot be empty"), matching
MEOS's own error message for the equivalent path.
The corresponding parity query is rewritten from PG-array-literal
form set('{}'::timestamptz[]) (which DuckDB rejects at the cast
layer) to the DuckDB-native ARRAY[]::TIMESTAMPTZ[] form so it
reaches the constructor wrapper.
…DB/MobilityDuck into fix/set-constructor-empty-array Resolved some merge conflicts due to multiple PRs
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.
Summary
Set_constructorinsrc/temporal/set_functions.cppbuilt aDatumarray from a DuckDB list and calledset_make_free(values, length, base_type, true)without first checking thatlength > 0. On an empty input list MEOS returns NULL, which the wrapper happily wrote into the result blob — surfacing later as an opaqueInvalid Input Error: Null pointer not allowedfrom DuckDB instead of a clear "input array cannot be empty" message.Adds an explicit
length == 0check at the top of the per-row lambda that raisesInvalidInputException("The input array cannot be empty"), matching the message MEOS itself uses for the equivalent PG path (MEOS_ERR_INVALID_ARG_VALUEwith that exact string).Parity file
Unwraps the empty-array skip block. The original MobilityDB query
set('{}'::timestamptz[])uses PG-array-literal syntax that DuckDB rejects at the cast layer (it parses'{}'as a string and fails with aConversion Error), so the parity query is rewritten in DuckDB-native formset(ARRAY[]::TIMESTAMPTZ[])with an inline note explaining the syntax-level divergence. Both forms convey the same intent: empty array should error.Test plan
TZ=UTC ./build/release/test/unittest "<proj>/test/*"locally: 748 assertions pass across 13 test cases (up from 747 — the new error assertion lights up), no regressions.Dependencies
Branched off main (post #7 merge). Independent of #8 / #9 / #10 — no rebase or stack required.
🤖 Generated with Claude Code