Support Questions
Find answers, ask questions, and share your expertise

Does hive need exact schema in Hive Export/Import?

New Contributor

I am using HDP 2.3.2

  • 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 table 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?

1 REPLY 1

Explorer

Yes it needs, in your char(10)and String does not match with each other.

Have you tried using this?

create table dev103 like create table dev101;

Repeat the steps to do the Export/Import proceedings