使用--input-lines-terminated-by =“:”导出sqoop不起作用

问题描述 投票:0回答:1

我正在尝试从hdfs导出到mysql一个文件,其中“:”作为行终止符。我的sqoop命令只导出第一行。我的预期结果是用两列id和description来编写表测试。请帮助我。谢谢。

在文件文件/ departments_enclosedby / part-m-00000-test中:

'2'~'fitness new':'3'~'footwear':'4'~'Apparel':'5'~'Golf':'6'~'Outdoors':'7'~'Fan Shop':'2'~'fitness new':'3'~'footwear':'12'~'Mathematics':'13'~'Science':'14'~'engineering  ':'1000'~'management':'9999'~'\'Data Science\'':

我的命令:

sqoop export \
    --connect="jdbc:mysql://***********" \
    --username=********* \
    --password=******* \
    --table=test \
    -m 1 \
    --export-dir="file/departments_enclosedby/part-m-00000-test" \
    --input-enclosed-by="'" \
    --input-escaped-by="\\" \
    --input-fields-terminated-by="~" \
    --input-lines-terminated-by=":"

此命令以以下内容结束:导出1条记录。

我试图以这种方式在文件中添加一行:

'2'~'fitness new':'3'~'footwear':'4'~'Apparel':'5'~'Golf':'6'~'Outdoors':'7'~'Fan Shop':'2'~'fitness new':'3'~'footwear':'12'~'Mathematics':'13'~'Science':'14'~'engineering  ':'1000'~'management':'9999'~'\'Data Science\'':
'3'~'footwear':'4'~'Apparel':'5'~'Golf':'6'~'Outdoors':'7'~'Fan Shop':'2'~'fitness new':'3'~'footwear':'12'~'Mathematics':'13'~'Science':'14'~'engineering  ':'1000'~'management':'9999'~'\'Data Science\'':

使用此文件,sqoop命令导出2行,id 2和3。

mysql sqoop cloudera
1个回答
0
投票

我的hive版本不支持与\ n不同的行终止符。

SemanticException 7:20 LINES TERMINATED BY现在只支持换行符'\ n'。令牌' - '附近遇到错误

因此导入工作正常,但hive无法读取文件或再次导出。

再见,谢谢

© www.soinside.com 2019 - 2024. All rights reserved.