feat(bindings): scalar value -> span casts (date, timestamptz, int, bigint, double)#16
Merged
Merged
Conversation
…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).
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
Registers cast functions so DuckDB recognises:
INTEGERINTSPANBIGINTBIGINTSPANDOUBLEFLOATSPANDATEDATESPANTIMESTAMP_TZTSTZSPANThe cast entry point
Value_to_span_castwas previously declared insrc/include/temporal/span_functions.hppbut never defined; defines it to delegate toValue_to_span_core(same path the existingspan(value)scalar function uses).Also fixes a pre-existing fall-through bug in
Value_to_span_core: theT_INT4case was missingbreak;and silently fell through to theT_INT8branch, which would read the INT32 source vector as INT64 and trip DuckDB's internalExpected vector of type INT64, but found vector of type INT32assertion. The bug only surfaced once anything actually exercised the INT4 branch via this entry point, which the newINTEGER -> INTSPANcast does.Smoke test
Test plan
make releasethenTZ=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.