facebookincubator / velox

A C++ vectorized database acceleration library aimed to optimizing query engines and data processing systems.
https://velox-lib.io/
Apache License 2.0
3.2k stars 1.06k forks source link

Casting integer to binary type produces inconsistent result with Spark #9820

Closed rui-mo closed 1 week ago

rui-mo commented 2 weeks ago

Bug description

When casting 18 as binary, Spark expects [00 00 00 12], but Velox gives [31 38] as it uses the same logic with casting as varchar.

https://github.com/facebookincubator/velox/blob/54db95234190a14723cb9792ae48a77823368029/velox/type/Conversions.h#L447-L454 Presto throws for casting int types as varbinary.

presto:test> select cast(18 as varbinary); Query 20240515_132148_00006_z5sg3 failed: line 1:8: Cannot cast integer to varbinary select cast(18 as varbinary)

System information

Velox System Info v0.0.2 Commit: b29d93374d8e75a595c85550428eb008a371d456 CMake Version: 3.16.3 System: Linux-5.4.0-173-generic Arch: x86_64 C++ Compiler: /usr/bin/c++ C++ Compiler Version: 11.1.0 C Compiler: /usr/bin/cc C Compiler Version: 11.1.0 CMake Prefix Path: /usr/local;/usr;/;/usr;/usr/local;/usr/X11R6;/usr/pkg;/opt

Relevant logs

No response