Skip to content
Advertisement

Impala incompatible return types in case when statement

I am running an Impala query and try to use a case when statement:

It complains

This however works fine:

As the error message indicates, PRTCTN_ALLCTD_VL is of type decimal(38,10). Any advice is appreciated

Advertisement

Answer

This is a curious problem, one that I would not expect. A case expression returns a single type so all the conditions have to converted to the same time within the expression.

You can fix the problem with explicit type casts. I’m not sure what the type should be, so I’ll guess:

I suspect this is happening because 38 is the maximum precision. The multiplications are probably changing the precision/scale and because the value already has the maximum precision, there is a problem. I would not expect this to generally happen with decimals.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement