我想从Hbase读取.tsv文件到hive。该文件有一个columnfamily,里面有3列:news,social和all。目的是将这些列存储在hbase中的表中,该表包含news,social和all列。
CREATE EXTERNAL TABLE IF NOT EXISTS topwords_logs (key String,
columnfamily String , wort String , col String, occurance int)ROW FORMAT
DELIMITED FIELDS TERMINATED BY '\t'STORED AS TEXTFILE LOCATION '/home
/hfu/Testdaten';
load data local inpath '/home/hfu/Testdaten/part-r-00000.tsv' into table topwords_logs;
CREATE TABLE newtopwords (columnall int, columnsocial int , columnnews int) PARTITIONED BY(wort STRING) STORED AS SEQUENCEFILE;
这里我创建了一个外部表,其中包含来自hbase的数据。此外,我创建了一个包含3列的表格。
到目前为止,我所尝试的是:
insert overwrite table newtopwords partition(wort)
select occurance ,'1', '1' , wort from topwords_log;
此代码工作正常,但我为每列添加了一个额外的where子句。我该如何插入这样的数据?
insert overwrite table newtopwords partition(wort)
values(columnall,(select occurance from topwords_logs where col =' all')),(columnnews,( select occurance from topwords_logs where col =' news')) ,(columnsocial,( select occurance from topwords_logs where col =' social')),(wort,(select wort from topwords_log));
此代码无效 - > NoViableAltException。
在每个例子中,我只看到Code,它们在没有Where子句的情况下插入数据。如何使用Where子句插入数据?