feat(bindings): tnumber arithmetic operators (+, -, *, /) — 24 registrations#29
Closed
estebanzimanyi wants to merge 1 commit into
Closed
feat(bindings): tnumber arithmetic operators (+, -, *, /) — 24 registrations#29estebanzimanyi wants to merge 1 commit into
estebanzimanyi wants to merge 1 commit into
Conversation
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).
This was referenced Apr 25, 2026
Member
Author
|
Consolidated into #43 (tnumber numeric functions — arithmetic + unary + distance). |
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
Adds 24 ScalarFunction registrations for
tnumberarithmetic across both base types (tint,tfloat) and all three operand-shape patterns:+,-,*,/INTEGER op tint,DOUBLE op tfloat+,-,*,/tint op INTEGER,tfloat op DOUBLE+,-,*,/tint op tint,tfloat op tfloatBacked by 20 MEOS bindings (
add_int_tint,add_tint_int,add_float_tfloat,add_tfloat_float,add_tnumber_tnumber, and the same 5 variants forsub_*,mult_*,div_*).Implementation
Reuses the templated wrapper helpers from PR #27 (
TemporalUnary,TemporalBinaryV,TemporalBinaryV1,TemporalBinaryTT), keeping eachScalarFunctionbody to one line. Each MEOS function is called via the matching helper template specialisation.Smoke test
Test plan
make releasethenTZ=UTC ./build/release/test/unittest "<proj>/test/*"— full suite passes.026_tnumber_mathfuncs.testskip block unwraps into ~6 active assertions covering value-op-tnumber, tnumber-op-value, and tnumber-op-tnumber across all 4 operators.Dependencies
Stacked on PR #27 (reuses its
TemporalBinaryV/TemporalBinaryV1/TemporalBinaryTThelpers). Merge order: #27 → this.