You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by prabhu k <pr...@gmail.com> on 2012/08/09 15:57:51 UTC

load data inot hive using shell script

Hi Users,

I m trying to load data into hive table using shell script. unable to load
data into hive table.

*sample.sh*
export HADOOP_HOME=/usr/local/hadoop
bin/hive
load data local inpath '/usr/local/hadoop_dir/hadoop/input/sample.txt'
overwrite into table sample;
exit;

Please suggest and help me.

Thanks,
Prabhu

Re: load data inot hive using shell script

Posted by prabhu k <pr...@gmail.com>.
Thanks Jan, it's working fine.

On Thu, Aug 9, 2012 at 7:32 PM, Jan DolinĂ¡r <do...@gmail.com> wrote:

> I'd suggest you to read a bit about shell scripts... To make this work you
> have to pass the queries to the hive via -e option. The way you wrote it,
> interactive cli would be run and the queries would be attempted to be
> executed by shell when cli ends. The correct skript in your case shouild
> look like this:
>
>  export HADOOP_HOME=/usr/local/hadoop
> bin/hive -e "load data local inpath
> '/usr/local/hadoop_dir/hadoop/input/sample.txt' overwrite into table
> sample;"
>
> Note that 'exit' is not even necessary, hive will exit when it reaches end
> of the last statement supplied.
>
> Best regards,
> Jan
>
>
> On Thu, Aug 9, 2012 at 3:57 PM, prabhu k <pr...@gmail.com> wrote:
>
>> Hi Users,
>>
>> I m trying to load data into hive table using shell script. unable to
>> load data into hive table.
>>
>> *sample.sh*
>> export HADOOP_HOME=/usr/local/hadoop
>> bin/hive
>> load data local inpath '/usr/local/hadoop_dir/hadoop/input/sample.txt'
>> overwrite into table sample;
>> exit;
>>
>> Please suggest and help me.
>>
>> Thanks,
>> Prabhu
>>
>
>

Re: load data inot hive using shell script

Posted by Jan DolinĂ¡r <do...@gmail.com>.
I'd suggest you to read a bit about shell scripts... To make this work you
have to pass the queries to the hive via -e option. The way you wrote it,
interactive cli would be run and the queries would be attempted to be
executed by shell when cli ends. The correct skript in your case shouild
look like this:

export HADOOP_HOME=/usr/local/hadoop
bin/hive -e "load data local inpath
'/usr/local/hadoop_dir/hadoop/input/sample.txt' overwrite into table
sample;"

Note that 'exit' is not even necessary, hive will exit when it reaches end
of the last statement supplied.

Best regards,
Jan


On Thu, Aug 9, 2012 at 3:57 PM, prabhu k <pr...@gmail.com> wrote:

> Hi Users,
>
> I m trying to load data into hive table using shell script. unable to load
> data into hive table.
>
> *sample.sh*
> export HADOOP_HOME=/usr/local/hadoop
> bin/hive
> load data local inpath '/usr/local/hadoop_dir/hadoop/input/sample.txt'
> overwrite into table sample;
> exit;
>
> Please suggest and help me.
>
> Thanks,
> Prabhu
>