配置单元表数据加载给出NULL值

时间:2019-06-24 09:19:48

标签: hive hiveql create-table

Select * from movierating给出NULL值作为结果。

我在下面尝试过创建表查询:

CREATE TABLE movierating(id INT, movieid INT, rating INT, time string);
CREATE TABLE movierating(id INT, movieid INT, rating INT, time string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ' ' stored as textfile;

尝试以下负载查询:

load data local inpath '/tmp/Movie-rating.txt' into table movierating;
load data local inpath '/tmp/Movie-rating.txt' OVERWRITE into table movierating;

将数据导入“ Movie-rating.txt”文件:(用分号显示)

1     123      3   881250949   
2     125      4   881250123

1 个答案:

答案 0 :(得分:1)

对于制表符分隔的数据,请使用'\t'作为字段分隔符:

CREATE TABLE movierating(id int,movieid int,rating int,time string) 
ROW FORMAT DELIMITED 
FIELDS TERMINATED BY  '\t' LINES TERMINATED BY '\n' 
STORED AS TEXTFILE;