You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Aaron Tokhy <to...@amazon.com> on 2015/11/21 03:28:44 UTC

Behavior of typed/untyped NULL in various UDFs

Hello,

I've encountered a strange error when using NULL in a number of ways.  I 
would expect to_date(NULL) to just return NULL.  However, when the NULL 
is cast to a timestamp, this works fine.  Should this case be handled by 
the to_date UDF?  What about other UDFs that may need to handle NULL 
literals with the VOID type?


hive> select to_date(NULL);
FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments 
'TOK_NULL': TO_DATE() only takes STRING/TIMESTAMP/DATEWRITABLE types, 
got VOID

hive> select to_date(cast(NULL as timestamp));
OK
NULL
Time taken: 0.288 seconds, Fetched: 1 row(s)


This appears to be thrown in this method:
https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFDate.java#L64


Thanks,
Aaron Tokhy