0
我想從HDFS上的表向sqoop導出到MySQL服務器。這些列的排列順序不同。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與不同的順序列?
可能重複的問題。檢查這個答案。 http://stackoverflow.com/questions/36190726/sqoop-export-specific-columns-from-hdfs-to-mysql-is-not-working-properly – TamilK