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.46k stars 1.13k forks source link

Fix casting partial date input for Spark #9480

Open rui-mo opened 5 months ago

rui-mo commented 5 months ago

Bug description

When casting string as date, Spark throws error or returns null (according to ANSI config) for 123, but works for 2020. While in Velox, 123 and 2020 both work. We can follow-up in a separate PR to fix Spark cast.

scala> spark.sql("select cast('123' as date)").show(false)
+-----------------+                                                             
|CAST(123 AS DATE)|
+-----------------+
|null             |
+-----------------+

scala> spark.sql("select cast('2020' as date)").show(false)
+------------------+                                                            
|CAST(2020 AS DATE)|
+------------------+
|2020-01-01        |
+------------------+

System information

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

rui-mo commented 5 months ago

https://github.com/facebookincubator/velox/pull/9357#issuecomment-2048798144