Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hive insert into table from select statement with different schemas

Tags:

hive

hiveql

For two tables in Hive:

Schema of Table A:
id  name  age

Schema of Table B:
name

# The type of "name" in Table A and B are both string

I want to select all rows from Table B and then append them to Table A, leaving the columns id and age null.

The following statement would not work since the number of columns are not identical

insert into Table_A
select * from Table_B
;

Is there any viable methods to append the data?

like image 638
Zelong Avatar asked Jan 19 '16 10:01

Zelong


1 Answers

insert into table Table_A select null,name,null from Table_B;
like image 98
Legato Avatar answered Oct 21 '22 15:10

Legato