Skip to content

feat(bindings): tnumber arithmetic operators (+, -, *, /) — 24 registrations#29

Closed
estebanzimanyi wants to merge 1 commit into
feat/tbool-tor-tand-ttext-textfrom
feat/tnumber-arithmetic
Closed

feat(bindings): tnumber arithmetic operators (+, -, *, /) — 24 registrations#29
estebanzimanyi wants to merge 1 commit into
feat/tbool-tor-tand-ttext-textfrom
feat/tnumber-arithmetic

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Adds 24 ScalarFunction registrations for tnumber arithmetic across both base types (tint, tfloat) and all three operand-shape patterns:

Operator Shape Type pair
+, -, *, / value op tnumber INTEGER op tint, DOUBLE op tfloat
+, -, *, / tnumber op value tint op INTEGER, tfloat op DOUBLE
+, -, *, / tnumber op tnumber tint op tint, tfloat op tfloat

Backed by 20 MEOS bindings (add_int_tint, add_tint_int, add_float_tfloat, add_tfloat_float, add_tnumber_tnumber, and the same 5 variants for sub_*, mult_*, div_*).

Implementation

Reuses the templated wrapper helpers from PR #27 (TemporalUnary, TemporalBinaryV, TemporalBinaryV1, TemporalBinaryTT), keeping each ScalarFunction body to one line. Each MEOS function is called via the matching helper template specialisation.

Smoke test

SELECT 1 + tint '1@2000-01-01';                                 -- 2@2000-01-01 00:00:00+00
SELECT tint '[1@2000-01-01, 5@2000-01-05]' + 10;                -- [11@..., 15@...]
SELECT 2.5 * tfloat '1.5@2000-01-01';                            -- 3.75@2000-01-01 00:00:00+00
SELECT tfloat '[1@2000-01-01, 4@2000-01-04]' / 2;               -- [0.5@..., 2@...]
SELECT tint '[1@2000-01-01, 5@2000-01-05]' - tint '[1@2000-01-01, 1@2000-01-05]';
                                                                -- [0@..., 4@...]
SELECT tfloat '[2@2000-01-01, 4@2000-01-04]' * tfloat '[1@2000-01-01, 2@2000-01-04]';
                                                                -- linear-interpolated product

Test plan

Dependencies

Stacked on PR #27 (reuses its TemporalBinaryV / TemporalBinaryV1 / TemporalBinaryTT helpers). Merge order: #27 → this.

Adds 24 ScalarFunction registrations for tnumber arithmetic across
both base types (tint, tfloat) and all three operand-shape patterns
(value op tnumber, tnumber op value, tnumber op tnumber):

  +, -, *, /  for  INTEGER op tint, tint op INTEGER
  +, -, *, /  for  DOUBLE  op tfloat, tfloat op DOUBLE
  +, -, *, /  for  tint op tint, tfloat op tfloat

Backed by 20 MEOS bindings (4 ops × 5 variants):
  add_int_tint / add_tint_int / add_float_tfloat / add_tfloat_float
    / add_tnumber_tnumber
  sub_*  /  mult_*  /  div_*

Implementation reuses the templated wrapper helpers from PR #27
(TemporalUnary, TemporalBinaryV, TemporalBinaryV1, TemporalBinaryTT)
keeping each ScalarFunction body to one line. Each MEOS function is
called via the matching helper template specialisation.

Smoke test:
  SELECT 1 + tint '1@2000-01-01';
    -> 2@2000-01-01 00:00:00+00
  SELECT tint '[1@2000-01-01, 5@2000-01-05]' + 10;
    -> [11@2000-01-01 00:00:00+00, 15@2000-01-05 00:00:00+00]
  SELECT 2.5 * tfloat '1.5@2000-01-01';
    -> 3.75@2000-01-01 00:00:00+00
  SELECT tfloat '[1@2000-01-01, 4@2000-01-04]' / 2;
    -> [0.5@2000-01-01 00:00:00+00, 2@2000-01-04 00:00:00+00]
  SELECT tint '[1@2000-01-01, 5@2000-01-05]' - tint '[1@2000-01-01, 1@2000-01-05]';
    -> [0@2000-01-01 00:00:00+00, 4@2000-01-05 00:00:00+00]

Stacked on PR #27 (reuses its templated helpers).

Full suite passes (747 assertions, 13 test cases).
@estebanzimanyi

Copy link
Copy Markdown
Member Author

Consolidated into #43 (tnumber numeric functions — arithmetic + unary + distance).

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