Zelong
Zelong

Reputation: 2556

Hive insert into table from select statement with different schemas

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?

Upvotes: 5

Views: 13320

Answers (1)

Legato
Legato

Reputation: 1081

insert into table Table_A select null,name,null from Table_B;

Upvotes: 11

Related Questions