How insert overwrite table in hive with diffrent where clauses?

半腔热情 提交于 2019-12-13 06:36:50

问题


I want to read a .tsv file from Hbase into hive. The file has a columnfamily, which has 3 columns inside: news, social and all. The aim is to store these columns in an table in hbase which has the columns news, social and 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;

Here i created a external table, which contain the data from hbase. Further on I created a table with the 3 columns.

What i have tried so far is this:

insert overwrite table newtopwords partition(wort)
select occurance ,'1', '1' , wort from topwords_log;

This Code works fine, but i have for each column an extra where clause. How can I insert data like this?

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));

This code isnt working ->NoViableAltException.

On every example I just see Code, where they insert data without a Where clause. How can I insert Data with a Where clause?

来源:https://stackoverflow.com/questions/33346060/how-insert-overwrite-table-in-hive-with-diffrent-where-clauses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!