Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

TRIM on Hive Decimal Datatype

avatar
Expert Contributor

I'm working on a scenario where a good number of queries uses TRIM(DECIMAL VALUE) in Hive 0.11 (Pivotal 1.0). After migration to HDP 2.2 (Hive 0.14), the queries started failing with error "Trim Takes only STRING/CHAR/VARCHAR types. Found Decimal". If I tried to run the same query as TRIM(STRING(DECIMAL VALUE)), it runs fine in Hive 0.14. Due to the volume of queries that should under go this casting change, is it possible to set this Implicit casting at a global level (say SET). Are there any workaround to trim decimal values in Hive 0.14 (which was supported in 0.11).

Thank you!

1 ACCEPTED SOLUTION

avatar

No there is no global way to set casting in Hive. What do you want to achieve by trimming decimal, do you want to use trim to remove trailing zeros? Looks like even Hive 0.11 trim was for removing the leading and trailing space characters. Its just that now they do explicit type check for string/var/varchar before trimming spaces which seem like the right behavior.

View solution in original post

2 REPLIES 2

avatar

No there is no global way to set casting in Hive. What do you want to achieve by trimming decimal, do you want to use trim to remove trailing zeros? Looks like even Hive 0.11 trim was for removing the leading and trailing space characters. Its just that now they do explicit type check for string/var/varchar before trimming spaces which seem like the right behavior.

avatar
Expert Contributor

Thanks Deepesh. I'm working with a customer where they have coded the existing Informatica Workflows (BDE) with TRIM on Decimal value in prod. When we are trying to migrate HDP and run them on Hive 0.14, it started erroring out in lower environment. We stated Hive is working as intended to, but wanted to check if there are any workarounds.

Thanks!