Deepyaman Datta
09/07/2023, 5:54 AMSELECT sign(CAST(0 AS INTEGER))
or
SELECT sign(CAST(0 AS BIGINT))
works, but
SELECT sign(CAST(0 AS TINYINT))
and
SELECT sign(CAST(0 AS SMALLINT))
error out?
More specifically, using PyFlink (Python 3.10.12, PyFlink 1.17.1): st_env.sql_query("SELECT sign(CAST(0 AS TINYINT))").to_pandas()
Error below:Deepyaman Datta
09/07/2023, 5:56 AMMartijn Visser
09/07/2023, 7:31 AMAssignment conversion not possible from type "float" to type "byte"Jane Chan
09/07/2023, 7:58 AMTINYINT is Byte, and for SMALLINT is ShortDeepyaman Datta
09/07/2023, 1:21 PMSIGN with numeric types, do I need to always manually upcast to INTEGER or larger first?Jane Chan
09/08/2023, 7:08 AMIs this expected behavior, then?Under the hood, the
SIGN function calls java.lang.Math#signum, java.lang.Integer#signum or java.lang.Long#signum, according to input type, respectively.
While for input type byte or short, it'll be first cast to int and then passed to java.lang.Integer#signum. While the result type int cannot be safely cast back to byte or short, the exception is thrown.
do I need to always manually upcast to INTEGER or larger first?I believe so.
Deepyaman Datta
09/11/2023, 3:25 AM