我正在尝试将 HDFS 上的表 sqoop 导出到 MySQL 服务器。这些列的顺序不同。
我的 sqoop 脚本是:
<workflow-app name="sqoop" xmlns="uri:oozie:workflow:0.4">
<start to="sqoop"/>
<action name="sqoop">
<sqoop xmlns="uri:oozie:sqoop-action:0.2">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<arg>export</arg>
<arg>--connect</arg>
<arg>jdbc:mysql://10.1.1.1:501/db_name</arg>
<arg>--username</arg>
<arg>sqoop</arg>
<arg>--password-file</arg>
<arg>/user/sqoop.password</arg>
<arg>--table</arg>
<arg>table_name</arg>
<arg>--export-dir</arg>
<arg>/user/location</arg>
<arg>-m</arg>
<arg>5</arg>
<arg>--input-fields-terminated-by</arg>
<arg>\001</arg>
<arg>--input-null-non-string</arg>
<arg>\\N</arg>
<arg>--input-null-string</arg>
<arg>\\N</arg>
<arg>--columns</arg>
<arg>col_1,col_2,col_3</arg>
</sqoop>
<ok to="end"/>
<error to="kill"/>
</action>
<kill name="kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
我的 HDFS 表创建为:
CREATE EXTERNAL TABLE `table_name`(
`col_2` bigint,
`col_1` bigint,
`col_3` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
STORED AS INPUTFORMAT
'com.hadoop.mapred.DeprecatedLzoTextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://nameservice1/user/location'
我收到以下错误:
Caused by: java.lang.NumberFormatException: For input string: "AA"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
我尝试导出到具有完全相同顺序的表,并通过从 sqoop 脚本中删除 --columns 选项,一切正常。是否无法 sqoop 到具有不同顺序的列?
最佳答案
看看这个,Sqoop User Guide
关于mysql - Sqoop导出到MySQL,不同的列顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33441459/