Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!
avatar

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

1,631 Views
Version history
Last update:
‎03-15-2017 07:34 PM
Updated by:
Contributors