-
Notifications
You must be signed in to change notification settings - Fork 190
[BUG] Serialization failure - some math function return NaN instead of NULL #1280
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What is the bug?
Some math functions return ±NaN instead of NULL. NaN is not serializable by GSON lib.
For example, LN uses Math.log which returns -NaN for negative values.
sql/core/src/main/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunction.java
Line 220 in 9d4a841
| v -> new ExprDoubleValue(Math.log(v.doubleValue()))), |
How can one reproduce the bug?
opensearchsql> select LN(-12.34567);
{'reason': 'Invalid SQL query', 'details': 'NaN is not a valid double value as per JSON specification. To override this behavior, use GsonBuilder.serializeSpecialFloatingPointValues() method.', 'type': 'IllegalArgumentException'}
What is the expected behavior?
mysql> select LN(-12.34567);
+---------------+
| LN(-12.34567) |
+---------------+
| NULL |
+---------------+
What is your host/environment?
main @ 9d4a841
Do you have any additional context?
Fix all math functions or patch serializer callee in protocol module to replace all ±NaN by NULLs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working