Skip to content

fix: position predicates between span and value/span return BOOLEAN#14

Merged
nhungoc1508 merged 1 commit intomainfrom
fix/span-position-predicates
Apr 27, 2026
Merged

fix: position predicates between span and value/span return BOOLEAN#14
nhungoc1508 merged 1 commit intomainfrom
fix/span-position-predicates

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Summary

The 119 ScalarFunction registrations for position operators (<<, >>, &<, &>, -|-, <<#, #>>, &<#, #&>) and their span_left / span_right / span_overleft / span_overright / span_adjacent name forms in src/temporal/span.cpp declared a SpanType return (e.g. INTSPAN, TSTZSPAN). The implementations in SpanFunctions::Left_span_value / Right_span_value / Overleft_span_value / Overright_span_value / Adjacent_span_value and their value-span / span-span variants already return bool from the underlying MEOS call (left_span_value etc.) — only the registrations were wrong. DuckDB enforces declared return types on the result vector, so these were unusable from SQL.

Replaces the return-type slot with LogicalType::BOOLEAN across all five categories (left, right, overleft, overright, adjacent) and all three variants (span_value, value_span, span_span).

Smoke test

SELECT intspan '[3,5)' << 5;          -- true
SELECT 5 << intspan '[3,5)';          -- false
SELECT floatspan '[3.5,5.5]' &< 5.5;  -- true

Test plan

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

The position-predicates skip block in test/sql/parity/003_span.test (open in a separate PR) becomes activatable once both this fix and that parity port land.

The 119 ScalarFunction registrations for position operators (<<, >>,
&<, &>, -|-, <<#, #>>, &<#, #&>) and their span_left / span_right /
span_overleft / span_overright / span_adjacent name forms in
src/temporal/span.cpp declared a SpanType return (e.g. INTSPAN,
TSTZSPAN). The SpanFunctions::Left_span_value / Right_span_value /
Overleft_span_value / Overright_span_value / Adjacent_span_value
implementations and their value-span / span-span variants already
return bool from the underlying MEOS call (left_span_value etc.) —
only the registrations were wrong. DuckDB enforces declared return
types on the result vector, so these were unusable from SQL.

Replaces the return-type slot with LogicalType::BOOLEAN across all
five categories (left, right, overleft, overright, adjacent) and all
variants (span_value, value_span, span_span). Smoke test:

  SELECT intspan '[3,5)' << 5;          -- now returns boolean true
  SELECT 5 << intspan '[3,5)';          -- false
  SELECT floatspan '[3.5,5.5]' &< 5.5;  -- true

The position-predicates skip block in test/sql/parity/003_span.test
(open in a separate PR) becomes activatable once both this fix and
that parity port land.
@nhungoc1508 nhungoc1508 merged commit 8528357 into main Apr 27, 2026
17 checks passed
estebanzimanyi added a commit that referenced this pull request Apr 28, 2026
Five more parity files added in one commit. All five are
wholesale-skip manifests because the underlying surfaces are unbound
in MobilityDuck. The files stand as a tracked gap inventory for what
still needs to land on the temporal layer.

- 028_tbool_boolops.test
    tbool boolean operators (& AND, | OR, ~ NOT) for value/tbool,
    tbool/value, tbool/tbool combinations. MEOS symbols:
    tand_*, tor_*, tnot_tbool.

- 029_ttext_textfuncs.test
    ttext text functions and concatenation: lower / upper / initcap
    on ttext, || for value/ttext, ttext/value, ttext/ttext. MEOS
    symbols: ttext_lower, ttext_upper, ttext_initcap, *_concat.
    DuckDB suggests `lower(textset)` when given ttext — the existing
    text functions are set-only.

- 030_temporal_compops.test
    Ever-/always- temporal comparison operators (?=, ?<>, ?<, ?<=,
    ?>, ?>= and #=, #<>, #<, #<=, #>, #>=). DuckDB's parser does
    not accept ? or # as operator-name characters at all, so every
    query fails before reaching MEOS. Either add equivalent
    alphabetic functions (ever_eq, always_eq, ...) or extend the
    DuckDB parser.

- 034_temporal_posops.test
    Position operators between temporal types and tbox / tstzspan /
    value (<<#, #>>, &<#, #&>, <<, >>, &<, &>, -|-) for any temporal
    type. Same root-cause shape as the position-predicate fix landed
    for spans (PR #14), one layer up. MEOS symbols: left_tnumber_*,
    right_tnumber_*, overleft_tnumber_*, overright_tnumber_*,
    before_tnumber_*, after_tnumber_*, overbefore_tnumber_*,
    overafter_tnumber_*, adjacent_tnumber_*.

- 040_temporal_aggfuncs.test
    Same architectural gap as PR #21 — tcount, tand, tor, tmin,
    tmax, tsum, extent for temporal types, all needing the
    AggregateFunction infrastructure that MobilityDuck doesn't have
    anywhere yet.

Suite: 747 assertions across 18 test cases (5 new files, 0 new
active assertions).
nhungoc1508 pushed a commit that referenced this pull request May 4, 2026
Five more parity files added in one commit. All five are
wholesale-skip manifests because the underlying surfaces are unbound
in MobilityDuck. The files stand as a tracked gap inventory for what
still needs to land on the temporal layer.

- 028_tbool_boolops.test
    tbool boolean operators (& AND, | OR, ~ NOT) for value/tbool,
    tbool/value, tbool/tbool combinations. MEOS symbols:
    tand_*, tor_*, tnot_tbool.

- 029_ttext_textfuncs.test
    ttext text functions and concatenation: lower / upper / initcap
    on ttext, || for value/ttext, ttext/value, ttext/ttext. MEOS
    symbols: ttext_lower, ttext_upper, ttext_initcap, *_concat.
    DuckDB suggests `lower(textset)` when given ttext — the existing
    text functions are set-only.

- 030_temporal_compops.test
    Ever-/always- temporal comparison operators (?=, ?<>, ?<, ?<=,
    ?>, ?>= and #=, #<>, #<, #<=, #>, #>=). DuckDB's parser does
    not accept ? or # as operator-name characters at all, so every
    query fails before reaching MEOS. Either add equivalent
    alphabetic functions (ever_eq, always_eq, ...) or extend the
    DuckDB parser.

- 034_temporal_posops.test
    Position operators between temporal types and tbox / tstzspan /
    value (<<#, #>>, &<#, #&>, <<, >>, &<, &>, -|-) for any temporal
    type. Same root-cause shape as the position-predicate fix landed
    for spans (PR #14), one layer up. MEOS symbols: left_tnumber_*,
    right_tnumber_*, overleft_tnumber_*, overright_tnumber_*,
    before_tnumber_*, after_tnumber_*, overbefore_tnumber_*,
    overafter_tnumber_*, adjacent_tnumber_*.

- 040_temporal_aggfuncs.test
    Same architectural gap as PR #21 — tcount, tand, tor, tmin,
    tmax, tsum, extent for temporal types, all needing the
    AggregateFunction infrastructure that MobilityDuck doesn't have
    anywhere yet.

Suite: 747 assertions across 18 test cases (5 new files, 0 new
active assertions).
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