我有这样的文件:
1^%~binod^*~1^%~ritesh^*~1^%~shisir^*~1^%~budhdha^*~1^%~romika^*~1^%~rubeena^*~
其中 --input-fields-terminated-by '^%~' --input-lines-terminated-by '^*~'。
我尝试通过命令导出:
sqoop export --connect jdbc:mysql://localhost/sqoop --username root -P --table makalu --export-dir sqoop/makalu --input-fields-terminated-by '^%~' --input-lines-terminated-by '^*~'
但是它写了一行:
id|name 1|%~binod
在 MySQL 中。
- 现在我的问题是解决这种情况的命令是什么。
最佳答案
参数 --input-fields-terminated-by 和 --input-lines-terminated-by 接受单个字符
当您在终端中执行导出命令时,您会看到以下警告
02/03 18:55:21 WARN sqoop.SqoopOptions: Character argument ^%~ has multiple characters; only the first will be used.
15/02/03 18:55:21 WARN sqoop.SqoopOptions: Character argument ^*~ has multiple characters; only the first will be used.
更新:
我观察到的一件事是,如果行终止不是\n 或新行,那么它只会在您导出时将一条记录插入数据库。我尝试了几个与字段和行终止的组合,但仅在行终止的情况下\n 数据被导出到 RDBMS 表中
甚至尝试使用 --input-lines-terminated-by 和 --lines-terminated-by 参数但没有成功。
我已经测试过了
Cloudera CDH-5.0.0-1
Sqoop version: 1.4.4-cdh5.0.0
我唯一能找到的是 this .
关于mysql - 通过 Sqoop 将带有自定义分隔符的 HDFS 文件导出到 Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28298817/