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 #166

Merged
merged 5 commits into from
Nov 16, 2022
Merged

Conversation

margarit-h
Copy link

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

Signed-off-by: Margarit Hakobyan margarith@bitquilltech.com

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.

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

Merging #166 (7890ade) into integ-add-cbrt-to-v2 (662a938) will decrease coverage by 2.55%.
The diff coverage is 100.00%.

@@                    Coverage Diff                     @@
##             integ-add-cbrt-to-v2     #166      +/-   ##
==========================================================
- Coverage                   98.27%   95.71%   -2.56%     
- Complexity                   3351     3355       +4     
==========================================================
  Files                         327      337      +10     
  Lines                        8457     9123     +666     
  Branches                      553      672     +119     
==========================================================
+ Hits                         8311     8732     +421     
- Misses                        142      334     +192     
- Partials                        4       57      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.27% <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%> (ø)
...h/public/components/QueryLanguageSwitch/Switch.tsx 85.71% <0.00%> (ø)
...ublic/components/QueryResults/QueryResultsBody.tsx 68.32% <0.00%> (ø)
...ch/public/components/QueryResults/QueryResults.tsx 61.60% <0.00%> (ø)
workbench/public/components/Main/main.tsx 53.00% <0.00%> (ø)
workbench/public/components/app.tsx 0.00% <0.00%> (ø)
workbench/public/components/Header/Header.tsx 100.00% <0.00%> (ø)
workbench/public/application.tsx 0.00% <0.00%> (ø)
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
* Test cbrt with long value.
*/
@ParameterizedTest(name = "cbrt({0})")
@ValueSource(longs = {1L, 2L})

Choose a reason for hiding this comment

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

we could also test negative longs, and larger-than-2 longs

* Test cbrt with int value.
*/
@ParameterizedTest(name = "cbrt({0})")
@ValueSource(ints = {1, 2})

Choose a reason for hiding this comment

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

negative integers?

* Test cbrt with float value.
*/
@ParameterizedTest(name = "cbrt({0})")
@ValueSource(floats = {1F, 2F})

Choose a reason for hiding this comment

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

negative floats, or floats with more precision?

* Test cbrt with double value.
*/
@ParameterizedTest(name = "cbrt({0})")
@ValueSource(doubles = {1D, 2D})

Choose a reason for hiding this comment

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

larger doubles, doubles with values below the decimal?

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
@margarit-h margarit-h changed the title [WIP:] Add CBRT to the V2 engine Add CBRT to the V2 engine Nov 15, 2022
@margarit-h margarit-h merged commit a2ffe99 into integ-add-cbrt-to-v2 Nov 16, 2022
margarit-h added a commit that referenced this pull request Nov 17, 2022
margarit-h added a commit that referenced this pull request Nov 17, 2022
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
margarit-h added a commit that referenced this pull request Nov 17, 2022
Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
margarit-h added a commit that referenced this pull request Nov 21, 2022
* Add CBRT to the V2 engine (#166)

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>

* Fixes after rebase

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
@margarit-h margarit-h deleted the dev-add-cbrt-to-v2 branch November 30, 2022 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants