Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

PROBLEM:

Hive queries were getting stuck/hang on both mr and tez engines while selecting from a table containing few csv files.

While the query was working fine for few csv files, for others it just hangs. Nothing in the logs also.

I was using Hive 1.2.1 on HDP 2.5.3.0

After some investigation, I found out that those files have some empty values '' in the fields where an rpad function was getting used.

You can easily reproduce the issue by firing:

select rpad('',1,''); 

You will see that the query just hangs.

The reason is it goes to an infinite loop.

More details here: HIVE-15792

RESOLUTION:

nvl will not work in this case.

That is

select nvl('','D'); --will return ''

I resolved using a query like this:

SELECT rpad(CASE WHEN LENGTH(nvl(COLUMN_NAME,null)) > 0 THEN COLUMN_NAME ELSE null END, 1, ''); 

In this case the query will return null for both null and empty string values occurring in COLUMN_NAME.

Hope this helps.

Thanks,

Rajdeep

384 Views
Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
1 of 1
Last update:
‎03-15-2017 07:34 PM
Updated by:
 
Contributors
Top Kudoed Authors