如何将具有空格的列名传递给sqoop --map-column-java

时间:2019-03-07 13:47:56

标签: hadoop sqoop avro

我必须使用sqoop导入数据,我的源列名称之间存在空格,因此当我将其添加到--map-column-java参数中时会收到错误消息。

示例Sqoop导入:

  

sqoop import --connect jdbc-con --username“ user1” --query“ select * from table where \ $ CONDITIONS” --target-dir / target / path / -m 1 --map-column-java data col1 = String,data col2 = String,data col3 = String --as-avrodatafile

列名:

data col1,
data col2,
data col3

错误:

  

19/03/07 07:31:55调试sqoop.Sqoop:格式错误的映射。列映射的格式应为key = value [,key = value] *   java.lang.IllegalArgumentException:格式错误的映射。列映射的格式应为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)   格式不正确的映射。列映射的格式应为key = value [,key = value] *

1 个答案:

答案 0 :(得分:0)

能够解决此问题:

1。空间问题: sqoop import --connect jdbc-con --username“ user1” --query“ select * from table where \ $ CONDITIONS” --target-dir / target / path / -m 1 --map-column-java“ data col1 = String,data col2 = String,data col3 = String“ --as-avrodatafile

2。错误工具。导入工具:导入失败:无法转换SQL类型2005:    源代码中有3列包含2005,nvarchar在--map-column-java中添加了它们,从而解决了该问题

3 。 org.apache.avro.file.DataFileWriter $ AppendWriteException:org.apache.avro.UnresolvedUnionException:不在联合中[“ null”,“ long”]:1 ****

这是由于在选择查询中使用*导致的,因此将sqoop查询修改为:

sqoop import --connect jdbc-con --username“ user1” --query“从表中的[$ CONDITIONS]中选择[col1,data col2,data col3]” --target-dir / target / path / -m 1 --map-column-java“ data col1 = String,data col2 = String,data col3 = String” --as-avrodatafile