首页 > 其他分享 >FAILED: ParseException line 1:65 cannot recognize input near 'row' 'formatted' &

FAILED: ParseException line 1:65 cannot recognize input near 'row' 'formatted' &

时间:2023-12-10 22:13:15浏览次数:28  
标签:delimited format col0 col1 student row

hive报FAILED: ParseException line 1:65 cannot recognize input near 'row' 'formatted' 'delimited' in table row format specification

错误语句:
insert overwrite local directory '/home/ljpbd/datas/student' row formatted delimited fields terminated by '\t' select id,name from student;
正确语句:
insert overwrite local directory '/home/ljpbd/datas/student' row format delimited fields terminated by '\t' select id,name from student;

 

正确语法:INSERT OVERWRITE [LOCAL] DIRECTORY directory
  [ROW FORMAT row_format] [STORED AS file_format] select_statement;
注意事项:保存的文件夹中不可有其他文件,会被清空;

例子:可以将数据保存成json格式
insert overwrite local directory '/opt/module/datas/student' ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
select id,name from student;
输出格式:
{"_col0":1001,"_col1":"student1"}
{"_col0":1002,"_col1":"student2"}
{"_col0":1003,"_col1":"student3"}
{"_col0":1004,"_col1":"student4"}
{"_col0":1005,"_col1":"student5"}
{"_col0":1006,"_col1":"student6"}
{"_col0":1007,"_col1":"student7"}
{"_col0":1008,"_col1":"student8"}
{"_col0":1009,"_col1":"student9"}

 

标签:delimited,format,col0,col1,student,row
From: https://www.cnblogs.com/huifeidezhuzai/p/17893333.html

相关文章