今天在看一些数据的时候发现,一些SparkSQL与Hive之间在进行cast转化时候存在一些差异。
HiveVersion 1.2.1
SparkSQL 1.6.0
总结:
在Hive中, boolean类型的隐式转化,Hive中非boolean非null转化默认为True,
而在SparkSQL中,则根据传入的不同数据类型判断值后返回结果.
Hive
Converts the results of the expression expr to . For example,
cast(‘1’ as BIGINT) will convert the string ‘1’ to its integral representation.
A null is returned if the conversion does not succeed.
If cast(expr as boolean)Hive returns true for a non-empty string
.
hive> select cast('false' as boolean) from default.dule;
OK
true
SparkSQL
在SparkSQL中如果是strin