ttccppp
ttccppp

Reputation: 11

Sqoop export from Hcatalog to MySQL with different col names assign

Now my hive table with columns - id, name

and MySQL table - number, id, name

I want to map id (from hive) with number (from mysql), name (from hive) with id (from mysql).

I use the command :

  sqoop export --hcatalog-database <my_db> --hcatalog-table <my_table> --columns "number,id" \
  --connect jdbc:mysql://db...:3306/test \
  --username <my_user> --password <my_passwd> --table <my_mysql_table>  

However, it didn't work.

The same scenario liked this case can work fine [1]. The requirement can be fulfilled by locating the hive table on hdfs and using the following command to achieve.

  sqoop export --export-dir /[hdfs_path] --columns "number,id" \
  --connect jdbc:mysql://db...:3306/test \
  --username <my_user> --password <my_passwd> --table <my_mysql_table>  

Is there any solution can fulfill my scenario via Hcatalog?

reference :

[1]. Sqoop export from hive to oracle with different col names, number of columns and order of columns

Upvotes: 1

Views: 1205

Answers (1)

F.Lazarescu
F.Lazarescu

Reputation: 1385

I didn't used the hcatalog part of sqoop, but as is written in the manual, the next script should do the work:

sqoop export --hcatalog-database <my_db> --hcatalog-table <my_table> --map-column-hive "number,id" \
  --connect jdbc:mysql://db...:3306/test \
  --username <my_user> --password <my_passwd> --table <my_mysql_table>

This option: --map-column-hive when is used along with --hcatalog, does the work for hcatalog instead of hive.

Hope that this works for you.

Upvotes: 0

Related Questions