Skip to content

Commit

Permalink
fix round crash (vesoft-inc#5773)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisChu authored Nov 29, 2023
1 parent 4c6a0a7 commit 54d18fb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common/function/FunctionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ FunctionManager::FunctionManager() {
case Value::Type::FLOAT: {
if (args.size() >= 2) {
if (args[1].get().type() == Value::Type::INT) {
auto val = args[0].get().getFloat();
auto val = args[0].get().isInt() ? args[0].get().getInt() : args[0].get().getFloat();
auto decimal = args[1].get().getInt();
auto factor = pow(10.0, decimal);

Expand Down
32 changes: 31 additions & 1 deletion tests/tck/features/expression/FunctionCall.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: Function Call Expression
When executing query:
"""
YIELD sign(38) AS a, sign(-2) AS b, sign(0.421) AS c,
sign(-1.0) AS d, sign(0) AS e, sign(abs(-3)) AS f
sign(-1.0) AS d, sign(0) AS e, sign(abs(-3)) AS f
"""
Then the result should be, in any order:
| a | b | c | d | e | f |
Expand Down Expand Up @@ -185,6 +185,36 @@ Feature: Function Call Expression
| result |
| 0.0 |

Scenario: round int
When executing query:
"""
YIELD round(12345, 2) as result
"""
Then the result should be, in any order:
| result |
| 12345.0 |
When executing query:
"""
YIELD round(12345, 0) as result
"""
Then the result should be, in any order:
| result |
| 12345.0 |
When executing query:
"""
YIELD round(12345, -2) as result
"""
Then the result should be, in any order:
| result |
| 12300.0 |
When executing query:
"""
YIELD round(12345, -5) as result
"""
Then the result should be, in any order:
| result |
| 0.0 |

Scenario: error check
When executing query:
"""
Expand Down

0 comments on commit 54d18fb

Please sign in to comment.