Skip to content

feat(bindings): ever/always equality and inequality (eq, ne) — named functions#34

Closed
estebanzimanyi wants to merge 1 commit intofeat/temporal-posopsfrom
feat/temporal-everalways-eq-ne
Closed

feat(bindings): ever/always equality and inequality (eq, ne) — named functions#34
estebanzimanyi wants to merge 1 commit intofeat/temporal-posopsfrom
feat/temporal-everalways-eq-ne

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

Summary

Adds 36 ScalarFunction registrations covering the temporal-comparison ever/always surface for tbool / tint / tfloat:

Function Variants
ever_eq, always_eq, ever_ne, always_ne value op temporal, temporal op value, temporal op temporal × {bool/tbool, int/tint, double/tfloat}

DuckDB's parser does not accept ? or # as operator-name characters, so the upstream MobilityDB operators ?=, ?<>, #=, #<> are unreachable from SQL — these named functions provide equivalent behaviour.

Implementation

  • 28 wrapper functions (4 named functions × 7 type-pair shapes) generated via a DEFINE_EA_OP macro that calls the matching MEOS function.
  • 3 small templated helpers (EverAlwaysValTemp, EverAlwaysTempVal, EverAlwaysTempTemp).
  • MEOS returns int (1=true, 0=false, -1=null/error), mapped to bool via r > 0.

Out of scope (follow-up)

  • ttext_text / text_ttext variants (would need PG-text encoding plumbing)
  • Ordering ops (ever_lt, always_lt, etc.) — same shape; can extend the DEFINE_EA_OP macro

Smoke test

SELECT ever_eq(1, tint '[1@01-01, 2@01-02]');                  -- true
SELECT always_eq(tint '[1@01-01, 1@01-02]', 1);                -- true
SELECT ever_ne(tint '[1@01-01, 2@01-02]', 1);                  -- true
SELECT always_ne(tint '[1@01-01, 2@01-02]', 5);                -- true
SELECT ever_eq(tbool '[t@01-01, f@01-02]', true);              -- true
SELECT ever_eq(tfloat '[1.5@01-01, 2.5@01-02]', 2.0::DOUBLE);  -- true

Test plan

Dependencies

Stacked on PR #33 (temporal time-position predicates). Merge order: #27#29#30#31#32#33 → this.

…functions

Adds 36 ScalarFunction registrations covering the temporal-comparison
ever/always surface for tbool / tint / tfloat:

  ever_eq, always_eq, ever_ne, always_ne
    × value op temporal, temporal op value, temporal op temporal
    × {bool/tbool, int/tint, double/tfloat}

DuckDB's parser does not accept `?` or `#` as operator-name
characters, so the upstream MobilityDB operators `?=`, `?<>`, `#=`,
`#<>` are unreachable from SQL — these named functions provide
equivalent behaviour.

Backed by 28 wrapper functions (4 named functions × 7 type-pair
shapes) generated via a DEFINE_EA_OP macro that calls the matching
MEOS function (ever_eq_*, always_eq_*, ever_ne_*, always_ne_*).
Three small templated helpers added (EverAlwaysValTemp,
EverAlwaysTempVal, EverAlwaysTempTemp) — MEOS returns int (1/0/-1),
mapped to bool via `r > 0`.

ttext_text / text_ttext variants are intentionally NOT included
(would need PG-text encoding plumbing, separate follow-up).

Smoke test:
  SELECT ever_eq(1, tint '[1@01-01, 2@01-02]');                    -- true
  SELECT always_eq(tint '[1@01-01, 1@01-02]', 1);                  -- true
  SELECT ever_ne(tint '[1@01-01, 2@01-02]', 1);                    -- true
  SELECT always_ne(tint '[1@01-01, 2@01-02]', 5);                  -- true
  SELECT ever_eq(tbool '[t@01-01, f@01-02]', true);                -- true
  SELECT ever_eq(tfloat '[1.5@01-01, 2.5@01-02]', 2.0::DOUBLE);    -- true

Stacked on PR #33 (temporal time-position predicates).

Full suite passes (747 assertions, 13 test cases).
@estebanzimanyi
Copy link
Copy Markdown
Member Author

Consolidated into #41 (ever/always comparison predicates — eq/ne/ord combined).

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