Skip to content

[BUG] Serialization failure - some math function return NaN instead of NULL #1280

@Yury-Fridlyand

Description

@Yury-Fridlyand

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions