gpt4 book ai didi

export - sqoop EXPORT - 在目标表中找不到列

转载 作者:行者123 更新时间:2023-12-02 06:38:58 28 4
gpt4 key购买 nike

我编写了一个简单的脚本来创建用户 (TestV100)、在该架构中创建表 (Xy100) 并将制表符分隔的平面文件从 hadoop 导出到此 Oracle 表。

这是 shell 脚本:-ExportOracleTestV100.sh

#!/bin/bash

# Testing connectivity to Oracle DB
#sqoop eval --connect jdbc:oracle:thin:@hostname:1521:orcl -username test -password password --query "SELECT count(*) as bob FROM \"TestV1\".\"Test\"" --verbose

HOST=$1
USER=$2
PASS=$3
SCHEMA=$4
PORT=$5
SID=$6
SQOOP=/usr/bin/sqoop
JDBC="jdbc:oracle:thin:@$1:$5:$6"
SQOOP_EVAL="$SQOOP eval --connect $JDBC --username $USER --password $PASS --query"

#Create Schema and Tables;
${SQOOP_EVAL} "CREATE USER \"TestV100\" identified by \"password\""
${SQOOP_EVAL} "GRANT CONNECT TO \"TestV100\""
${SQOOP_EVAL} "ALTER USER \"TestV100\" QUOTA UNLIMITED ON USERS"

${SQOOP_EVAL} "DROP TABLE \"TestV100\".\"Xy100\""
${SQOOP_EVAL} "CREATE TABLE \"TestV100\".\"Xy100\"( \"a\" NVARCHAR2(255) DEFAULT NULL, \"x\" NUMBER(10,0) DEFAULT NULL, \"y\" NUMBER(10,0) DEFAULT NULL )"


############################
## Load Data into tables; ##
############################

SQOOP_EXPORT="/usr/bin/sudo -u hdfs $SQOOP export --connect ${JDBC} --username $USER --password $PASS --export-dir"
${SQOOP_EXPORT} "/tmp/rv/TestV100/xy100.txt" --table "\"\"$SCHEMA\".\"Xy100\"\"" --fields-terminated-by "\t" --input-null-string null -m 1

这是输入文件: - cat/tmp/rv/TestV100/Xy100.txt

c       8       3
a 1 4
c 6 1
c 2 0
a 7 7
c 4 2
c 7 5
a 0 0
c 5 6
a 2 2
a 5 5
a 3 6
c 9 7
a 4 1
c 3 4
a 6 3
b 6 5
b 8 7
b 5 1
b 7 3
b 2 4
b 1 0
b 4 6
b 3 2

这就是 shell 脚本的调用方式:

sh ./ExportOracleTestV100.sh oracle11 test password TestV100 1521 orcl --verbose

注意:“测试”用户对 TestV100 架构具有完全访问权限。

输出:

[root@abc-repo-app1 rv]# sh ./ExportOracleTestV100.sh oracle11 test password TestV100 1521 orcl --verbose
Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
15/11/02 12:40:07 INFO sqoop.Sqoop: Running Sqoop version: 1.4.5-cdh5.4.1
15/11/02 12:40:07 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
15/11/02 12:40:07 INFO oracle.OraOopManagerFactory: Data Connector for Oracle and Hadoop is disabled.
15/11/02 12:40:07 INFO manager.SqlManager: Using default fetchSize of 1000
15/11/02 12:40:07 INFO tool.CodeGenTool: Beginning code generation
15/11/02 12:40:08 INFO manager.OracleManager: Time zone has been set to GMT
15/11/02 12:40:08 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM "TestV100"."xy100" t WHERE 1=0
15/11/02 12:40:08 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.IllegalArgumentException: There is no column found in the target table "TestV100"."xy100". Please ensure that your table name is correct.
java.lang.IllegalArgumentException: There is no column found in the target table "TestV100"."xy100". Please ensure that your table name is correct.
at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1658)
at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)
at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:64)
at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:100)
at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
at org.apache.sqoop.Sqoop.main(Sqoop.java:236)

如上所示,Sqoop版本为1.4.5-cdh5.4.1

我不知何故设法走到了这一步。我在网上看到很多关于 sqoop import 和这个错误的帖子,解决方案是在命令中将表名更改为大写。但是,我正在进行导出。此外,oracle 表必须使用混合大小写创建。

我希望我在这里提供了所有必需的信息。有人可以帮忙或指出一些可以帮助我克服这个错误的地方吗?

最佳答案

大写的表名有效。

sqoop 导出 --connect jdbc:oracle:thin:@xyzx:1569:xyz --用户名 xyz --密码 xyz --table CIPHADOOPCUSTOMERREPORT --export-dir/apps/hive/warehouse/ciprpt.db/dtd_customer_report - -输入字段终止于“\t” --输入行终止于“\n” --verbose -m 8 --输入空字符串 '\N' --输入空非-字符串 '\N'

关于export - sqoop EXPORT - 在目标表中找不到列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33487278/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com