Skip to content

feat(bindings): spanset follow-ups — lowercase aliases, hash, empty-array fix#19

Merged
nhungoc1508 merged 1 commit into
mainfrom
feat/spanset-followups
Apr 27, 2026
Merged

feat(bindings): spanset follow-ups — lowercase aliases, hash, empty-array fix#19
nhungoc1508 merged 1 commit into
mainfrom
feat/spanset-followups

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Three independent fixes for spanset, mirroring the corresponding set-level work in PRs #8, #10, and #11:

1. Lowercase splitNspans / splitEachNspans aliases

Adds 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_spans dispatchers as the existing camelCase registrations. The camelCase forms stay registered for back-compat.

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 mirrors set_hash / span_hash: copies the blob into a malloc'd SpanSet, calls MEOS, frees. Registered in the per-spanset-type loop in src/temporal/spanset.cpp.

3. Empty-array spanset() constructor

Spanset_constructor in src/temporal/spanset_functions.cpp 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 Invalid Input Error: 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

Test plan

  • make release then TZ=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.

…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).
@nhungoc1508 nhungoc1508 merged commit c70d900 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