feat(bindings): spanset follow-ups — lowercase aliases, hash, empty-array fix#19
Merged
Conversation
…rray fix
Three independent fixes for spanset, mirroring the corresponding
set-level work:
1. Lowercase splitNspans / splitEachNspans aliases for all five
spanset types (intspanset/bigintspanset/floatspanset/datespanset/
tstzspanset) pointing at the same Spanset_split_n_spans /
Spanset_split_each_n_spans dispatchers as the camelCase forms.
2. spanset_hash / spanset_hash_extended:
- spanset_hash(<spanset>) -> UINTEGER (MEOS uint32 spanset_hash)
- spanset_hash_extended(<spanset>, BIGINT seed) -> UBIGINT
(MEOS uint64 spanset_hash_extended; seed cast to uint64)
Implementation copies the blob into a malloc'd SpanSet, calls MEOS,
frees. Registered in the per-spanset-type loop in
src/temporal/spanset.cpp next to lower / upper / lowerInc / upperInc.
3. Empty-array spanset() constructor: src/temporal/spanset_functions.cpp
Spanset_constructor built a Span array from a DuckDB list and called
the MEOS constructor without checking length. On an empty input list
MEOS returned NULL, surfacing later as "Null pointer not allowed".
Adds a length == 0 check that raises
InvalidInputException("The input array cannot be empty"), matching
the message MEOS itself uses.
Smoke test:
SELECT splitNspans(intspanset '{[1,2),[3,4),[5,6)}', 2);
-> ['[1, 4)', '[5, 6)']
SELECT spanset_hash(intspanset '{[1,2]}');
-> 2065175519 (UINTEGER)
SELECT spanset_hash_extended(tstzspanset '{[2000-01-01,2000-01-02]}', 1);
-> 13017976434127639608 (UBIGINT)
SELECT spanset(ARRAY[]::TSTZSPAN[]);
-> Invalid Input Error: The input array cannot be empty
Full suite passes (747 assertions, 13 test cases).
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
Three independent fixes for spanset, mirroring the corresponding set-level work in PRs #8, #10, and #11:
1. Lowercase
splitNspans/splitEachNspansaliasesAdds the lowercase forms for all five spanset types (intspanset/bigintspanset/floatspanset/datespanset/tstzspanset) pointing at the same
Spanset_split_n_spans/Spanset_split_each_n_spansdispatchers as the existing camelCase registrations. The camelCase forms stay registered for back-compat.2.
spanset_hash/spanset_hash_extendedspanset_hash(<spanset>) -> UINTEGER(MEOSuint32 spanset_hash)spanset_hash_extended(<spanset>, BIGINT seed) -> UBIGINT(MEOSuint64 spanset_hash_extended; seed cast touint64)Implementation mirrors
set_hash/span_hash: copies the blob into a malloc'dSpanSet, calls MEOS, frees. Registered in the per-spanset-type loop insrc/temporal/spanset.cpp.3. Empty-array
spanset()constructorSpanset_constructorinsrc/temporal/spanset_functions.cppbuilt aSpanarray from a DuckDB list and called the MEOS constructor without checking length. On an empty input list MEOS returned NULL, surfacing later asInvalid Input Error: Null pointer not allowed. Adds alength == 0check that raisesInvalidInputException("The input array cannot be empty"), matching the message MEOS itself uses.Smoke test
Test plan
make releasethenTZ=UTC ./build/release/test/unittest "<proj>/test/*"— full suite passes.Activates the corresponding skip blocks in
test/sql/parity/007_spanset.test(open in PR #18) once both land.