Pass space into Hive Config thru BSUB command

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Pass space into Hive Config thru BSUB command

Post by eli.nawas_AUS »

Hi
I need to invoke Hive from Datastage, but I am having problem with passing in spaces in Hive parameters

At the operating i can pass in parameters with space in them, like this:
I have this simple Hive script. It just prints out the parameters passed in:

Code: Select all

 ==> cat param1.hql
!echo ============================================= ;
set PARAM1 ;
set PARAM2 ;
set PARAM3 ;
!echo ============================================= ;
And the Hive call and its output :

Code: Select all

 ==> hive -S -hiveconf PARAM1="A B C"  -hiveconf PARAM2="DEFG"   -f param1.hql
=============================================
PARAM1=A B C
PARAM2=DEFG
PARAM3 is undefined
=============================================
Note that PARAM1 has the correct spaces passed in.

Now I need to do the same thing in Datastage.

In our environment, We have to execute sudo then bsub, then hive, like this: (NOTE: NO space in parameters yet to proves that it works)

Code: Select all

sudo -u tedwload -i  "  bsub -I   /opt/ibm/biginsights/hive/bin/hive   "-hiveconf  PARAM1=ABC"     "-hiveconf  PARAM2=DEFG"  -f /data/dev/Scripts/T21.hql   " > /tmp/T21.log   2>/tmp/T21.err
This works, as it prints these 2 lines out:

Code: Select all

PARAM1=ABC	
PARAM2=DEFG
But now, I want to pass spaces into PARAM1.
I tried so many combinations, but it just loses all spaces. These are what I tried:

(I just include the PARAM1 part, the rest of the command are identical as above)

Code: Select all

"-hiveconf  PARAM1='ABC' "                          <--   it prints:  'A
"-hiveconf  PARAM1=\'A B C\'  "                     <--  it prints:  'A
"-hiveconf  PARAM1="A B C" "                       <--  it prints:  "A
"-hiveconf  PARAM1=\"A B C\"  "                    <--  it prints:  "A
Could you suggest a solution?

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Maybe (just a guess) escape the space characters themselves?

Code: Select all

A\ B\ C
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Jaydev
Participant
Posts: 13
Joined: Thu Nov 01, 2012 6:28 am
Location: Hyderabad
Contact:

Re: Pass space into Hive Config thru BSUB command

Post by Jaydev »

Instead of space give %20 like

PARAM1='A%20B%20C'
Regards,
Jay
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Post by eli.nawas_AUS »

Hi Ray
I tried that also. Didn't work either. This is what it passes into Hive:

Code: Select all

PARAM1=A\
PARAM2=DEFG
Thanks
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Re: Pass space into Hive Config thru BSUB command

Post by eli.nawas_AUS »

Hi Jay

I just tried that.

" -hiveconf PARAM1="A%20B%20C" "

It passed in this:

PARAM1=A%20B%20C
PARAM2=DEFG

Same for this: " -hiveconf PARAM1='A%20B%20C' "

Your suggestion is similar to my backup solution:

Everybody agrees to some non-space token (such as *, or %20 as u suggested), then inside their Hive scripts they have to use regexp to convert them back to spaces for their queries. (This is assuming that those token are not part of the data itself.)

But this extra step is not ideal. I prefer to have a simple solution to pass in spaces as is.


Thanks
Post Reply