Skip to content

feat(bindings): scalar value -> span casts (date, timestamptz, int, bigint, double)#16

Merged
nhungoc1508 merged 1 commit into
mainfrom
feat/value-to-span-casts
Apr 27, 2026
Merged

feat(bindings): scalar value -> span casts (date, timestamptz, int, bigint, double)#16
nhungoc1508 merged 1 commit into
mainfrom
feat/value-to-span-casts

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Registers cast functions so DuckDB recognises:

From To
INTEGER INTSPAN
BIGINT BIGINTSPAN
DOUBLE FLOATSPAN
DATE DATESPAN
TIMESTAMP_TZ TSTZSPAN

The cast entry point Value_to_span_cast was previously declared in src/include/temporal/span_functions.hpp but never defined; defines it to delegate to Value_to_span_core (same path the existing span(value) scalar function uses).

Also fixes a pre-existing fall-through bug in Value_to_span_core: the T_INT4 case was missing break; and silently fell through to the T_INT8 branch, which would read the INT32 source vector as INT64 and trip DuckDB's internal Expected vector of type INT64, but found vector of type INT32 assertion. The bug only surfaced once anything actually exercised the INT4 branch via this entry point, which the new INTEGER -> INTSPAN cast does.

Smoke test

SELECT 5::intspan;                          -- [5, 6)
SELECT 5::BIGINT::bigintspan;               -- [5, 6)
SELECT 1.5::DOUBLE::floatspan;              -- [1.5, 1.5]
SELECT date '2000-01-01'::datespan;         -- [2000-01-01, 2000-01-02)
SELECT timestamptz '2000-01-01'::tstzspan;  -- [2000-01-01 00:00:00+00, ...]

Test plan

  • make release then TZ=UTC ./build/release/test/unittest "<proj>/test/*" — full suite passes.

Activates the date / timestamptz cast skip block in test/sql/parity/003_span.test (open in PR #13) once both land.

…igint, double)

Registers cast functions so DuckDB recognises:
  - INTEGER       -> INTSPAN
  - BIGINT        -> BIGINTSPAN
  - DOUBLE        -> FLOATSPAN
  - DATE          -> DATESPAN
  - TIMESTAMP_TZ  -> TSTZSPAN

The cast entry point Value_to_span_cast was previously declared in
src/include/temporal/span_functions.hpp but never defined; defines it
to delegate to Value_to_span_core (same path the existing scalar
"span(value)" function uses).

Also fixes a pre-existing fall-through bug in Value_to_span_core: the
T_INT4 case was missing a `break;` and silently fell through to the
T_INT8 branch, which would read the INT32 source vector as INT64 and
trip the DuckDB internal "Expected vector of type INT64, but found
vector of type INT32" assertion. The bug only surfaced once anything
actually exercised the INT4 branch via this entry point, which the new
INTEGER -> INTSPAN cast does.

Smoke test:
  SELECT 5::intspan;                              -- [5, 6)
  SELECT 5::BIGINT::bigintspan;                   -- [5, 6)
  SELECT 1.5::DOUBLE::floatspan;                  -- [1.5, 1.5]
  SELECT date '2000-01-01'::datespan;             -- [2000-01-01, 2000-01-02)
  SELECT timestamptz '2000-01-01'::tstzspan;      -- [2000-01-01 ..., 2000-01-01 ...]

Full suite passes (747 assertions, 13 test cases).
@nhungoc1508 nhungoc1508 merged commit 9686457 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