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

fix round crash #5773

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
yixinglu marked this conversation as resolved.
Show resolved Hide resolved
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
Loading