Skip to content

Conversation

@margarit-h
Copy link
Contributor

@margarit-h margarit-h commented Dec 20, 2022

  • Fix truncate() function

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

Description

Fixes truncate() returning incorrect results for some input data issue.
Example of a query result after the proposed fix:

opensearchsql> SELECT ddouble.key, ddouble.val, TRUNCATE(ddouble.val, 1) AS `EXPR$2` FROM ddouble;                                                    
fetched rows / total rows = 20/20
+----------------------------+------------------------+------------------------+
| key                        | val                    | EXPR$2                 |
|----------------------------+------------------------+------------------------|
| null                       | null                   | null                   |
| 001: min long              | -9.223372036854776e+18 | -9.223372036854776e+18 |
| 002: min int minus one     | -2147483649.0          | -2147483649.0          |
| 003: min int               | -2147483648.0          | -2147483648.0          |
| 004: min short minus one   | -32769.0               | -32769.0               |
| 005: min short             | -32768.0               | -32768.0               |
| 006: pgtest float8 value 2 | -34.84                 | -34.8                  |
| 007: -two                  | -2.0                   | -2.0                   |
| 008: -1.2                  | -1.2                   | -1.2                   |
| 009: -one                  | -1.0                   | -1.0                   |
| 010: zero                  | 0.0                    | 0.0                    |
| 011: one                   | 1.0                    | 1.0                    |
| 012: 1.3                   | 1.3                    | 1.3                    |
| 013: two                   | 2.0                    | 2.0                    |
| 014: pgtest float8 value 1 | 1004.3                 | 1004.3                 |
| 015: max short             | 32767.0                | 32767.0                |
| 016: max short plus one    | 32768.0                | 32768.0                |
| 017: max int               | 2147483647.0           | 2147483647.0           |
| 018: max int plus one      | 2147483648.0           | 2147483648.0           |
| 019: max long              | 9.223372036854776e+18  | 9.223372036854776e+18  |
+----------------------------+------------------------+------------------------+

Issues Resolved

#1043

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.

* Fix truncate() function

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarit.hakobyan@improving.com>
@margarit-h margarit-h requested a review from a team as a code owner December 20, 2022 01:26
@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2022

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.82%. Comparing base (c923e80) to head (7a5b5a6).
⚠️ Report is 864 commits behind head on main.

❌ Your project status has failed because the head coverage (95.82%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1197      +/-   ##
============================================
- Coverage     98.31%   95.82%   -2.49%     
- Complexity     3521     3535      +14     
============================================
  Files           342      352      +10     
  Lines          8700     9388     +688     
  Branches        554      673     +119     
============================================
+ Hits           8553     8996     +443     
- Misses          142      334     +192     
- Partials          5       58      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.31% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dai-chen dai-chen added the bug Something isn't working label Dec 20, 2022
Signed-off-by: Margarit Hakobyan <margarit.hakobyan@improving.com>
Signed-off-by: Margarit Hakobyan <margarit.hakobyan@improving.com>
Signed-off-by: Margarit Hakobyan <margarit.hakobyan@improving.com>
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!

@penghuo penghuo merged commit 7714819 into opensearch-project:main Jan 3, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 3, 2023
* Fix truncate() function (#188)

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarit.hakobyan@improving.com>
(cherry picked from commit 7714819)
dai-chen pushed a commit that referenced this pull request Jan 3, 2023
* Fix truncate() function (#188)

Signed-off-by: Margarit Hakobyan <margarith@bitquilltech.com>
Signed-off-by: Margarit Hakobyan <margarit.hakobyan@improving.com>
(cherry picked from commit 7714819)

Co-authored-by: Margarit Hakobyan <margarit.hakobyan@improving.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants