hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Markovitz, Dudu" <dmarkov...@paypal.com>
Subject RE: Does hive need exact schema in Hive Export/Import?
Date Mon, 30 May 2016 15:52:37 GMT
Hi

1)
I was able to do the import by doing the following manipulation:


·         Export table dev101

·         Create an empty table dev102

·         Export table dev102

·         replace the _metadata file of dev101 with the _metadata file of dev102

·         import table dev101 to table dev102

2)
Another option is not to create dev102 in advance but let the import from dev101 to create
it.
After the import you can alter the table, e.g.:

Alter table dev102 change column col2 col2 varchar(10);


Dudu

From: Devender Yadav [mailto:devender.yadav@impetus.co.in]
Sent: Monday, May 30, 2016 2:38 PM
To: user@hive.apache.org
Subject: Does hive need exact schema in Hive Export/Import?


Hi All,


I am using HDP 2.3

- Hadoop version - 2.7.1

- Hive version - 1.2.1


I created a table dev101 in hive using

    create table dev101 (col1 int, col2 char(10));

I inserted two records using

    insert into dev101 values (1, 'value1');
    insert into dev101 values (2, 'value2');

I exported data to HDFS using

    export table dev101 to '/tmp/dev101';


Then, I created a new table dev102 using

    create table dev102 (col1 int, col2 String);


I imported data from `/tmp/dev10` in `dev102` using

    import table dev102 from '/tmp/dev101';

I got error:

>FAILED: SemanticException [Error 10120]: The existing table is not compatible with the
import spec.   Column Schema does not match


Then I created another table `dev103` using

    create table dev103 (col1 int, col2 char(50));

Again imported:

    import table dev103 from '/tmp/dev101';

Same error:

>FAILED: SemanticException [Error 10120]: The existing table is not compatible with the
import spec.   Column Schema does not match

Finally, I create table with **exactly same schema**

    create table dev104 (col1 int, col2 char(10));

And imported

    import table dev104 from '/tmp/dev101';

Imported Successfully.

Does hive need exact schema in Hive Export/Import? ​




Regards,
Devender​

________________________________






NOTE: This message may contain information that is confidential, proprietary, privileged or
otherwise protected by law. The message is intended solely for the named addressee. If received
in error, please destroy and notify the sender. Any use of this email is prohibited when received
in error. Impetus does not represent, warrant and/or guarantee, that the integrity of this
communication has been maintained nor that the communication is free of errors, virus, interception
or interference.
Mime
View raw message