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

Casting JSON to decimal produces incorrect results #11674

Open
zhli1142015 opened this issue Nov 27, 2024 · 2 comments
Open

Casting JSON to decimal produces incorrect results #11674

zhli1142015 opened this issue Nov 27, 2024 · 2 comments
Labels
bug Something isn't working triage Newly created issue that needs attention.

Comments

@zhli1142015
Copy link
Contributor

Bug description

  testCast<JsonNativeType, int64_t>(
      JSON(),
      DECIMAL(10, 2),
      {"1234567.89"_sv},
      {123456789});
/var/git/velox/velox/vector/tests/utils/VectorTestBase.cpp:151: Failure
Value of: expected->equalValueAt(actual.get(), i, i)
  Actual: false
Expected: true
at 0: expected 1234567.89, but got 12345.67
Google Test trace:
/var/git/velox/./velox/functions/prestosql/tests/CastBaseTest.h:217: Flat encoding
/var/git/velox/./velox/functions/prestosql/tests/CastBaseTest.h:212: Cast from JSON to DECIMAL(10, 2)

It seems casting JSON to decimal is not supported. Should we disable the toType for decimal, similar to how it's handled for date types?
https://github.com/facebookincubator/velox/blob/main/velox/functions/prestosql/types/JsonType.cpp#L1201

System information

Velox System Info v0.0.2
Commit: e80bf12
CMake Version: 3.28.3
System: Linux-5.15.167.4-microsoft-standard-WSL2
Arch: x86_64
C++ Compiler: /usr/bin/c++
C++ Compiler Version: 11.4.0
C Compiler: /usr/bin/cc
C Compiler Version: 11.4.0
CMake Prefix Path: /usr/local;/usr;/;/usr/local/lib/python3.10/dist-packages/cmake/data;/usr/local;/usr/X11R6;/usr/pkg;/opt

Relevant logs

No response

@zhli1142015 zhli1142015 added bug Something isn't working triage Newly created issue that needs attention. labels Nov 27, 2024
@zhli1142015
Copy link
Contributor Author

cc @Yuhta and @mbasmanova , thanks

@mbasmanova
Copy link
Contributor

CC: @kgpai @karteekmurthys @kagamiori

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Newly created issue that needs attention.
Projects
None yet
Development

No branches or pull requests

2 participants