Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expecting KW_EXCHANGE near 'table' in alter exchange partition

Tags:

ddl

hadoop

hive

I am dealing with a table in hive which does not have partitions and with input format as textinputformat. This is not an external table and I create it using "Create table as select" template.

I use the alter table statement to rename the table as given below:

ALTER TABLE testdb.temptable RENAME TO testdb.newtable;

I get the following error:

Error: Error while compiling statement: FAILED: ParseException line 1:32 mismatched input 'RENAME' expecting KW_EXCHANGE near 'temptable' in alter exchange partition (state=42000,code=40000)
Closing: org.apache.hive.jdbc.HiveConnection

I see it is a bug in hive. I use the version: Hive 0.12.0-cdh5.1.4

How do i go about fixing this issue. Thanks in advance for the help!

like image 885
user1189851 Avatar asked Dec 05 '22 01:12

user1189851


1 Answers

It's not exactly a bug, just a side effect of Open Source when it's done by a motley crew of people all around the world with no "product owner" and no incentives to use a common programming style (or run extensive regression tests, or <insert your complaint here>).

Aaaaaaah, now that it's said, I feel better... Let's get to the point.

In HiveQL the alter command does not use the same semantics as create or select; specifically, you cannot use the "ALTER DATABASE.TABLE" notation. If you try, then the HQL parser just fails with a queer error message, as you can see by yourself.

That's the way it is. You must type a use command first, then your alter command with just the table name. Yes, it sucks. But that's the way it is. And I see no reason why it should improve any time soon.


[Update Jun-2017]   looks like ALTER finally supports the DB.TABLE syntax, on recent Cloudera distro (tested on CDH 5.10 with Hive 1.1.0 - but since they usually include a number of back-ports in their distro, maybe it's a feature of Hive 1.2+)
like image 86
Samson Scharfrichter Avatar answered Dec 22 '22 15:12

Samson Scharfrichter