Support Questions

Find answers, ask questions, and share your expertise

an error is reported when impala executes a case

New Contributor

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


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). has a lot of related information.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.