goks
goks

Reputation: 1206

create table temp2 select * from temp1 is not taking all the properties of the source table in hive 0.14

I am trying to create table (temp2) from another table(temp1) using below procedure and table is getting created but few properties are missing in the temp2 table like below example.

Properties missing in table temp2 are

field.delim '\t' --- This is missing serialization.format '\t' --- This is missing

        create table temp1 (
        id int,
        name string,
        age int,
        address string
        ) row format delimited fields terminated by '\t';


        describe formatted temp1;

        id int,
        name string,
        age int,
        address string

        <additional messages>
        -----
        ----

        field.delim          '\t'
        serialization.format '\t'

        create table temp2 select * from temp1 where 1=2;

        descibe formatted temp2;

        id int,
        name string,
        age int,
        address string

        <additional messages>
        -----
        ----

        field.delim          '\t'  --- This is missing
        serialization.format '\t'  --- This is missing

Upvotes: 1

Views: 92

Answers (1)

Tremo
Tremo

Reputation: 599

"Create table" just use data incomming from the "select" to build his properties. I guess there is no format associated to the data when hive push data from a table to another.

You can use something like the code below:

CREATE TABLE IF NOT EXISTS temp2 LIKE temp1;
FROM temp1 INSERT INTO temp2 SELECT * FROM temp1 WHERE 1=2;

Upvotes: 2

Related Questions