简体   繁体   中英

INSERT with UNION ALL returns only the first select result - HIVE Beeline

I want to do a query that inserts the result of table1 with table2 union's result. But when I try on beeline:

insert into table table3
select * from (
    select * from table1 t1 
    where 
        h_time > '2019-05-01 00:00:00' 
        and t1.id in (select id from table4)
    union all
    select * from table2 t2 
    where 
        h_time > '2019-05-01 00:00:00' 
        and t2.id not in (select id from table4)
);

Consider that the both tables 1 and 2 have the same column numbers and datatypes have already fixed previously.

The result in table3 is only the rows of table1. And when I change the position of table 1 and 2, I get only the rows of table2. Anyone have a guess what's happening?

Tks in advance!

it may be problem with table too, it may not show the actual count sometimes, use select * from tablename. If the count is as expected the run Analyze statement it'll re-compute and repair the statistics

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM