Skip to content

feat(bindings): tnumber unary functions (abs, derivative, degrees, radians)#30

Closed
estebanzimanyi wants to merge 1 commit into
feat/tnumber-arithmeticfrom
feat/tnumber-unary
Closed

feat(bindings): tnumber unary functions (abs, derivative, degrees, radians)#30
estebanzimanyi wants to merge 1 commit into
feat/tnumber-arithmeticfrom
feat/tnumber-unary

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

Summary

Adds 6 ScalarFunction registrations for unary tnumber functions:

SQL MEOS
abs(tint) -> tint tnumber_abs
abs(tfloat) -> tfloat tnumber_abs
derivative(tfloat) -> tfloat temporal_derivative
degrees(tfloat) -> tfloat tfloat_degrees(t, false)
degrees(tfloat, BOOL) -> tfloat tfloat_degrees(t, normalize)
radians(tfloat) -> tfloat tfloat_radians

Temporal_derivative was already declared and implemented in src/temporal/temporal_functions.cpp but was never registered; this PR registers it without duplicating the body.

Implementation reuses the templated wrapper helpers from PR #27 (TemporalUnary / TemporalBinaryV<bool>).

Smoke test

SELECT abs(tint '[-1@2000-01-01, 2@2000-01-02]');
-- [1@2000-01-01 00:00:00+00, 2@2000-01-02 00:00:00+00]

SELECT derivative(tfloat '[1@2000-01-01, 4@2000-01-04]');
-- Interp=Step;[1.157e-05@..., 1.157e-05@...]

SELECT degrees(tfloat '[0@2000-01-01, 3.14159@2000-01-02]');
-- [0@..., 179.9998479605043@...]

SELECT radians(tfloat '[0@2000-01-01, 180@2000-01-02]');
-- linear-radians value sequence

Test plan

Dependencies

Stacked on PR #29 (tnumber arithmetic). Merge order: #27#29 → this.

…dians)

Adds 6 ScalarFunction registrations for unary tnumber functions:

  abs(tint)               -> tint    (MEOS: tnumber_abs)
  abs(tfloat)             -> tfloat  (MEOS: tnumber_abs)
  derivative(tfloat)      -> tfloat  (MEOS: temporal_derivative)
  degrees(tfloat)         -> tfloat  (MEOS: tfloat_degrees, normalize=false)
  degrees(tfloat, BOOL)   -> tfloat  (MEOS: tfloat_degrees, normalize=arg)
  radians(tfloat)         -> tfloat  (MEOS: tfloat_radians)

Implementation reuses the templated wrapper helpers from PR #27.
Temporal_derivative was already declared and implemented in
src/temporal/temporal_functions.cpp (Math functions block) but was
never registered; this PR registers it without duplicating the body.

Smoke test:
  SELECT abs(tint '[-1@2000-01-01, 2@2000-01-02]');
    -> [1@2000-01-01 00:00:00+00, 2@2000-01-02 00:00:00+00]
  SELECT derivative(tfloat '[1@2000-01-01, 4@2000-01-04]');
    -> Interp=Step;[1.157e-05@..., 1.157e-05@...]
  SELECT degrees(tfloat '[0@2000-01-01, 3.14159@2000-01-02]');
    -> [0@..., 179.9998479605043@...]
  SELECT radians(tfloat '[0@2000-01-01, 180@2000-01-02]');
    -> linear-radians value sequence

Stacked on PR #29 (tnumber arithmetic).

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