【问题标题】:Sqoop export from Hcatalog to MySQL with different col names assignSqoop 从 Hcatalog 导出到 MySQL 并分配不同的 col 名称
【发布时间】:2019-09-12 13:59:38
【问题描述】:

现在我的蜂巢表带有列 - id, name

和 MySQL 表 - number, id, name

我想将id (from hive) 映射到number (from mysql),将name (from hive) 映射到id (from mysql)

我使用命令:

  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>  

但是,它不起作用。

与此案例相同的场景可以正常工作 [1]。可以通过在hdfs上定位hive表,使用如下命令来实现。

  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>  

是否有任何解决方案可以通过 Hcatalog 实现我的方案?

参考:

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

【问题讨论】:

    标签: hadoop hive sqoop hcatalog


    【解决方案1】:

    我没有使用 sqoop 的 hcatalog 部分,但正如 in the manual 所写,下一个脚本应该可以完成工作:

    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>
    

    此选项:--map-column-hive--hcatalog 一起使用时,为 hcatalog 而不是 hive 工作。

    希望这对你有用。

    【讨论】:

    • 感谢您的回复。在我尝试了参数 --map-column-hive 之后,它仍然得到 ERROR : java.io.IOException: Caught Exception checks database column number in hcatalog table。这个错误和我使用的参数一样--column
    • hm .. 所以你在 hcatalog 表中的列是数字吗? -> "..checking database column number in hcatalog table" 同样,hive 的结构与 hcatalog 的结构不同?
    • hcatalog 和 MySQL 中的所有列都设置为 STRING 类型。
    猜你喜欢
    • 1970-01-01
    • 2016-12-17
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    • 2013-08-16
    • 2014-05-11
    • 1970-01-01
    相关资源
    最近更新 更多