hadoop—如何将带有空格的列名传递给sqoop—Map列java

xqk2d5yq  于 2021-05-27  发布在  Hadoop
关注(0)|答案(1)|浏览(391)

我必须使用sqoop导入数据,我的源列名之间有空格,所以在添加数据时 --map-column-java 参数获取错误。
示例sqoop导入:
sqoop import--connect jdbc con--username“user1”--query“select*from table where$conditions”--target dir/target/path/-m1--Map列java data col1=string,data col2=string,data col3=string--作为avrodatafile
列名:

data col1,
data col2,
data col3

错误:
19/03/07 07:31:55调试sqoop.sqoop:Map格式错误。列Map的格式应为key=value[,key=value]*java.lang.illegalargumentexception:Map格式错误。列Map的形式应为key=value[,key=value]位于org.apache.sqoop.sqoopoptions.parsecolumnmapping(sqoopoptions)。java:1355)在org.apache.sqoop.sqoopoptions.setmapcolumnjava(sqoopoptions。java:1375)在org.apache.sqoop.tool.basesqooptool.applycodegenoptions(basesqooptool。java:1363)在org.apache.sqoop.tool.importtool.applyoptions(importtool。java:1011)在org.apache.sqoop.tool.sqooptool.parsearguments(sqooptool。java:435)在org.apache.sqoop.sqoop.run(sqoop。java:135)在org.apache.hadoop.util.toolrunner.run(toolrunner。java:70)在org.apache.sqoop.sqoop.runsqoop(sqoop。java:183)在org.apache.sqoop.sqoop.runtool(sqoop。java:234)在org.apache.sqoop.sqoop.runtool(sqoop。java:243)在org.apache.sqoop.sqoop.main(sqoop。java:252)Map格式不正确。列Map的形式应为key=value[,key=value]

roejwanj

roejwanj1#

能够解决此问题:
1空间问题:sqoop import--connect jdbc con--username“user1”--query“selectfrom table where$conditions”--target dir/target/path/-m1--将列java“data col1=string,data col2=string,data col3=string”Map为avrodatafile
2error tool.importtool:导入失败:无法转换sql类型2005:源中有3列具有2005,nvarchar将它们添加到Map列中--java解决了此问题
三。org.apache.avro.file.datafilewriter$appendwriteexception:org.apache.avro.unsolvedUnionException:不在联合中[“null”,“long”]:1
***
这是由于在select query中使用*导致的,因此将sqoop query修改为:
sqoop import--connect jdbc con--username“user1”--query“select[col1,data col2,data col3]from table where$conditions”--target dir/target/path/-m1--Map列java“data col1=string,data col2=string,data col3=string”--作为avrodatafile

相关问题