You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@sqoop.apache.org by evergreen方 <40...@qq.com> on 2014/08/27 09:21:42 UTC

How sqoop trim all the columns when importing table to hive?

‍‍hi everyone,
       I have a so big db2 table which contains many char type columns.[see 1.png]
       I've always been tring  to extract datas to hive via sqoop to fullfill different demands.

       In the past time, I try to manually trim all the char type colums when write Hivesql[see 2.png]

       There are so many colums to trim that I always forget some of them,just like following:

        suppose BANK_TABLE is the target table of hive,and 2323423232323 is an existing  card number in the table.‍
---------------------------------------------------------------------------------------
      if I execute: hive -e "select * from  BANK_TABLE where card_no='2323423232323' " ‍
---------------------------------------------------------------------------------------
       The result is nothing owning to I forget to trim the column: card_no when I write sql to import data to hive.
       So I wonder is there a good way for sqool or for hive to do the 'trim' automatically?

Thank you all!

Yuqing Fang
UnionPay

Re: How sqoop trim all the columns when importing table to hive?

Posted by Abraham Elmahrek <ab...@cloudera.com>.
Hey there,

Sqoop currently doesn't provide any functionality for this... what you're
doing currently makes a lot of sense! You can always add a step before
Sqoop or after Sqoop to sanitize your data?

-Abe


On Wed, Aug 27, 2014 at 12:21 AM, evergreen方 <40...@qq.com> wrote:

> ‍‍hi everyone,
>        I have a so big db2 table which contains many char type
> columns.[see 1.png]
>        I've always been tring  to extract datas to hive via sqoop to
> fullfill different demands.
>
>        In the past time, I try to manually trim all the char type colums
> when write Hivesql[see 2.png]
>
>        There are so many colums to trim that I always forget some of
> them,just like following:
>
>         suppose BANK_TABLE is the target table of hive,and 2323423232323
> is an existing  card number in the table.‍
>
> ---------------------------------------------------------------------------------------
>       if I execute: hive -e "select * from BANK_TABLE where
> card_no='2323423232323' " ‍
>
> ---------------------------------------------------------------------------------------
>        The result is nothing owning to I forget to trim the column:
> card_no when I write sql to import data to hive.
>        So I wonder is there a good way for sqool or for hive to do the
> 'trim' automatically?
>
> Thank you all!
>
> Yuqing Fang
> UnionPay
>
>
>