You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@sqoop.apache.org by dyuti a <ha...@gmail.com> on 2012/12/13 18:50:21 UTC

Using cast in sqoop export

Hi All,
Am trying to cast the datatype while doing an export from hive to mysql (
string from hive to Int in mysql).Is it possible with any of the options?

//Tried
sqoop export --connect jdbc:mysql://localhost:3306/mydatabase --username
gact -P --query "SELECT cast(firstname AS int),cast(lastname AS int) from
test3" --table test3 --export-dir /user/hive/warehouse/test;

//But got below errors:
12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Error parsing arguments for
export:
12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: --query
12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: SELECT
cast(firstname) AS int,cast(lastname) AS int from test
12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: --table
12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: test3
12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument:
--export-dir
12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument:
/user/hive/warehouse/test

from the above error i found like it is not possible to use --query in
export.

is there any other way to achieve this? i know it is simple by having the
exact datatype and do a normal export to mysql table but i badly wanna to
check with this...........

Thanks for your help!

Regards,
dti

Re: Using cast in sqoop export

Posted by Jarek Jarcec Cecho <ja...@apache.org>.
Hi sir,
Sqoop is not reading data types from HIVE during export job. All data types are inferred from your MySQL table. Thus you should not need to do any explicit casting. Would you mind sharing more details about your use case?

Jarcec

On Thu, Dec 13, 2012 at 11:20:21PM +0530, dyuti a wrote:
> Hi All,
> Am trying to cast the datatype while doing an export from hive to mysql (
> string from hive to Int in mysql).Is it possible with any of the options?
> 
> //Tried
> sqoop export --connect jdbc:mysql://localhost:3306/mydatabase --username
> gact -P --query "SELECT cast(firstname AS int),cast(lastname AS int) from
> test3" --table test3 --export-dir /user/hive/warehouse/test;
> 
> //But got below errors:
> 12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Error parsing arguments for
> export:
> 12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: --query
> 12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: SELECT
> cast(firstname) AS int,cast(lastname) AS int from test
> 12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: --table
> 12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument: test3
> 12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument:
> --export-dir
> 12/12/13 10:36:24 ERROR tool.BaseSqoopTool: Unrecognized argument:
> /user/hive/warehouse/test
> 
> from the above error i found like it is not possible to use --query in
> export.
> 
> is there any other way to achieve this? i know it is simple by having the
> exact datatype and do a normal export to mysql table but i badly wanna to
> check with this...........
> 
> Thanks for your help!
> 
> Regards,
> dti