Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

ClassCastException on Drop table query in apache spark hive

avatar

I'm using the following hive query :

this.queryExecutor.executeQuery("Drop table user")

and am getting the following exception :

java.lang.LinkageError: ClassCastException: attempting to castjar:file:/usr/hdp/2.4.2.0-258/spark/lib/spark-assembly-1.6.1.2.4.2.0-258-hadoop2.7.1.2.4.2.0-258.jar!/javax/ws/rs/ext/RuntimeDelegate.classtojar:file:/usr/hdp/2.4.2.0-258/spark/lib/spark-assembly-1.6.1.2.4.2.0-258-hadoop2.7.1.2.4.2.0-258.jar!/javax/ws/rs/ext/RuntimeDelegate.class

I saw there have been similar posts here and here but they haven't had any response till now.

Whats intriguing is that this is specific when we try to use drop table (or drop table if exists) query.

Hoping to find resolution for the same.

1 ACCEPTED SOLUTION

avatar
Super Guru

@kanwar singh

user is a reserved word in hive. You need to use escape characters for it. They are the back ticks, e.g. `user`. Since you are passing the statement as a string, you may have to escape the back-tick ` as well using a back-slash, \`.

Additionally, commands issued in hive require a semi-colon at the end.

To test the above theory just try to drop a table that does not have a reserved keyword in hive, e.g. MyTable.

If this helps, please vote/accept answer.

View solution in original post

1 REPLY 1

avatar
Super Guru

@kanwar singh

user is a reserved word in hive. You need to use escape characters for it. They are the back ticks, e.g. `user`. Since you are passing the statement as a string, you may have to escape the back-tick ` as well using a back-slash, \`.

Additionally, commands issued in hive require a semi-colon at the end.

To test the above theory just try to drop a table that does not have a reserved keyword in hive, e.g. MyTable.

If this helps, please vote/accept answer.