i create an hive temp table that use case when, like this:
case when xxx then coalesce(t1.Cuur_Db_Qty, 0) else (coalesce(t1.Cuur_Db_Qty, 0) + coalesce(t3.Curr_Term_Db_Occur_Qty, 0)) end
which face an error like this:
AnalysisException: Incompatible return types 'DECIMAL(38,15)' and 'DECIMAL(38,14)' of exprs 'coalesce(t1.Cuur_Db_Qty, 0)' and '(coalesce(t1.Cuur_Db_Qty, 0) + coalesce(t3.Curr_Term_Db_Occur_Qty, 0))'.
my impala version is 3.3,and i execute in impala 2.8 that is no this error,who can ask the question
Created 08-23-2020 02:19 PM
You need to cast one of the branches of the else to be a compatible type with the other one.
The problem is that both decimal types have the max precision (38) and different scale and neither can be converted automatically to the other without potentially losing precision.
A lot of the decimal behaviour such as result types of expressions was changed in CDH6 (and upstream Apache Impala 3.0). https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/impala_decimal.html has a lot of related information.