hadoophivesubquerybigdataderived-column

How to load the values of three column from one table1 to another table 2 which is having single column in hive?


Could you please help me below query.

enter image description here

Table 1 (Input)had three columns (Credit_date, Debit_date, Payment_date) and Table 2 (Output) has one column date

The three column values from Table 1 should be available in Table 2.

I tried below query but not working.

insert into table2
select date 
from (
 (select credit_date, debit_date, Payment_date from table 1) as date)t;

Could you please guide.


Solution

  • Try doing a union all:

    insert into table2 
    select * from (
    select credit_date as date from table1
    union all
    select debit_date as date from table1
    union all
    select payment_date as date from table1
    ) t