Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(bindings): fix distance return types; add + shift alias for tstzset/tstzspan+interval#107

Open
estebanzimanyi wants to merge 1 commit intomainMobilityDB/MobilityDuck:mainfrom
fix/span-distance-return-typesMobilityDB/MobilityDuck:fix/span-distance-return-typesCopy head branch name to clipboard
Open

fix(bindings): fix distance return types; add + shift alias for tstzset/tstzspan+interval#107
estebanzimanyi wants to merge 1 commit intomainMobilityDB/MobilityDuck:mainfrom
fix/span-distance-return-typesMobilityDB/MobilityDuck:fix/span-distance-return-typesCopy head branch name to clipboard

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Summary

  • Integer and date span distance operators were registered with INTEGER/BIGINT return types but the C++ executor wrote DOUBLE values → INTERNAL error at runtime. Fixed by using BinaryExecutor<..., int32_t/int64_t> with DatumGetInt32/Int64.
  • tstzspan distance was registered as DOUBLE but callers expect INTERVAL (e.g. 2 days, not 172800.0). Fixed to return interval_t via SecsToInterval.
  • Added + and shift aliases for tstzset/tstzspan + interval (DuckDB cannot define custom infix operators, so + is registered as a named function alias).

Test plan

  • intspan '[1,3]' <-> intspan '[5,7]' returns 2 (INTEGER)
  • datespan '[2000-01-01,2000-01-03]' <-> datespan '[2000-01-10,2000-01-15]' returns correct day count
  • tstzspan '[2000-01-01,2000-01-03]' <-> tstzspan '[2000-01-10,2000-01-15]' returns 7 days INTERVAL

🤖 Generated with Claude Code

…et/tstzspan+interval

Distance operators for integer and date spans were registered with
INTEGER/BIGINT return types but the C++ executor wrote DOUBLE values →
INTERNAL error at runtime.  tstzset/tstzspan distance was registered as
DOUBLE but callers expect INTERVAL (2 days, not 172800.0).

Changes:
- Distance_span_value / Distance_value_span: change int/bigint/date cases
  to BinaryExecutor<..., int32_t/int64_t> using DatumGetInt32/Int64;
  change tstzspan case to BinaryExecutor<..., interval_t> via SecsToInterval.
- Distance_span_span: replace single double-returning executor with a
  type-dispatching switch (int32/int64/double/interval_t per span type);
  uses distance_tstzspan_tstzspan for the tstzspan branch.
- Distance_set_value / Distance_value_set / Distance_set_set: change
  tstzset branch from double to interval_t, converting via SecsToInterval.
- set.cpp / span.cpp: update tstzset distance registrations to INTERVAL;
  add "+"(tstzset, INTERVAL) and "+"(tstzspan, INTERVAL) as shift aliases.
- time_util.hpp: add SecsToInterval helper (seconds → DuckDB interval_t).
- test/sql/parity/009_time_ops.test: activate all 4 assertions (previously
  inside mode skip).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.