Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CBRT to the V2 engine #1081

Merged
merged 2 commits into from
Nov 21, 2022

Conversation

margarit-h
Copy link
Contributor

@margarit-h margarit-h commented Nov 16, 2022

Description

Adds CBRT() math function to the V2 engine.

Usage: CBRT(number) calculates the cube root of a number
Argument type: INTEGER/LONG/FLOAT/DOUBLE
Return type: DOUBLE

(Non-negative) INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE
(Negative) INTEGER/LONG/FLOAT/DOUBLE -> DOUBLE

Example::

opensearchsql> SELECT CBRT(8), CBRT(9.261), CBRT(-27);
fetched rows / total rows = 1/1
+-----------+---------------+-------------+
| CBRT(8)   | CBRT(9.261)   | CBRT(-27)   |
|-----------+---------------+-------------|
| 2.0       | 2.1           | -3.0        |
+-----------+---------------+-------------+

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2022

Codecov Report

Merging #1081 (08bef27) into 2.x (81c9285) will decrease coverage by 2.53%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##                2.x    #1081      +/-   ##
============================================
- Coverage     98.27%   95.74%   -2.54%     
- Complexity     3434     3438       +4     
============================================
  Files           343      353      +10     
  Lines          8540     9206     +666     
  Branches        544      663     +119     
============================================
+ Hits           8393     8814     +421     
- Misses          142      334     +192     
- Partials          5       58      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.28% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...c/main/java/org/opensearch/sql/expression/DSL.java 100.00% <100.00%> (ø)
...h/sql/expression/function/BuiltinFunctionName.java 100.00% <100.00%> (ø)
...ssion/operator/arthmetic/MathematicalFunction.java 100.00% <100.00%> (ø)
workbench/public/components/SQLPage/SQLPage.tsx 100.00% <0.00%> (ø)
workbench/public/components/Main/main.tsx 53.00% <0.00%> (ø)
workbench/public/components/Header/Header.tsx 100.00% <0.00%> (ø)
workbench/public/utils/PanelWrapper.tsx 100.00% <0.00%> (ø)
workbench/public/components/app.tsx 0.00% <0.00%> (ø)
workbench/public/application.tsx 0.00% <0.00%> (ø)
workbench/public/components/PPLPage/PPLPage.tsx 56.52% <0.00%> (ø)
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

MaxKsyunz
MaxKsyunz previously approved these changes Nov 17, 2022
acarbonetto
acarbonetto previously approved these changes Nov 17, 2022
dai-chen
dai-chen previously approved these changes Nov 17, 2022
Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Please double check if floating point precision problem may occur in assertion in UT.

@dai-chen dai-chen added the enhancement New feature or request label Nov 17, 2022
@dai-chen
Copy link
Collaborator

Btw, we may want to add it to PPL grammar and doc too?

@margarit-h
Copy link
Contributor Author

@dai-chen I am working on a separate PR for adding CBRT() to the PPL.

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
docs/user/dql/functions.rst Show resolved Hide resolved
@dai-chen dai-chen merged commit d4d289c into opensearch-project:2.x Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants