我正在尝试执行以下蜂巢堆栈命令
选择堆栈(2,'A', 10.1 ,'2015-01-01','B', 20.123 ,'2016-01-01') ;
但是由于十进制精度不一致,它给了我错误,下面是错误消息
Error: org.apache.spark.sql.AnalysisException: cannot resolve 'stack(2, 'A', 10.1BD, '2015-01-01', 'B', 20.123BD, '2016-01-01')' due to data type mismatch: Argument 2 (decimal(3,1)) != Argument 5 (decimal(5,3)); line 1 pos 7;
'Project [unresolvedalias(stack(2, A, 10.1, 2015-01-01, B, 20.123, 2016-01-01), None)]
+- OneRowRelation (state=,code=0)
答案 0 :(得分:1)
以所需的精度和比例明确地广播到double
或decimal
:
hive> select stack(2,'A',cast(10.1 as double), '2015-01-01','B',cast(20.123 as double), '2016-01-01');
OK
A 10.1 2015-01-01
B 20.123 2016-01-01
Time taken: 2.818 seconds, Fetched: 2 row(s)
hive> select stack(2,'A',cast(10.1 as decimal(5,3)), '2015-01-01','B',cast(20.123 as decimal(5,3)), '2016-01-01');
OK
A 10.1 2015-01-01
B 20.123 2016-01-01
Time taken: 0.066 seconds, Fetched: 2 row(s)