Skip to content

fix: raise on empty-array input to set() constructor#11

Merged
nhungoc1508 merged 5 commits intomainfrom
fix/set-constructor-empty-array
Apr 27, 2026
Merged

fix: raise on empty-array input to set() constructor#11
nhungoc1508 merged 5 commits intomainfrom
fix/set-constructor-empty-array

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Summary

Set_constructor in src/temporal/set_functions.cpp built a Datum array from a DuckDB list and called set_make_free(values, length, base_type, true) without first checking that length > 0. On an empty input list MEOS returns NULL, which the wrapper happily wrote into the result blob — surfacing later as an opaque Invalid Input Error: Null pointer not allowed from DuckDB instead of a clear "input array cannot be empty" message.

Adds an explicit length == 0 check at the top of the per-row lambda that raises InvalidInputException("The input array cannot be empty"), matching the message MEOS itself uses for the equivalent PG path (MEOS_ERR_INVALID_ARG_VALUE with 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 a Conversion Error), so the parity query is rewritten in DuckDB-native form set(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.
  • CI validates on linux_amd64, linux_arm64, macos, wasm.

Dependencies

Branched off main (post #7 merge). Independent of #8 / #9 / #10 — no rebase or stack required.

🤖 Generated with Claude Code

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.
nhungoc1508 and others added 4 commits April 27, 2026 10:25
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
@nhungoc1508 nhungoc1508 merged commit 22ffeba into main Apr 27, 2026
17 checks passed
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