i need to insert data into hive table from two different table counts.
example, let assume i have a table sample
having fields counter1
and counter2
now i have another two tables test1
and test2
.
i need to insert into sample.counter1 as select count(*) from test1
and sample.counter2 as select count(*) from test2
it works if final table is having one column like:
insert into table sample select count(*) from test1
now i need to insert two columns.
any suggestions?
Advertisement
Answer
Is this what you are looking for?
insert into sample.counter1 (counter1, counter2) select t1.cnt, t2.cnt from (select count(*) as cnt from test1) t1 cross join (select count(*) as cnt from test2) t2;