Pooja Agrawal
Pooja Agrawal

Reputation: 71

access a hive table specifying database qualifier in spark 2.0

I am trying to access a hive table specifying database qualifier using spark sql. I am using sparksession as it is spark 2.0 or above. For example, I am trying to add a partition to an existing table. The query is

sparksession.sql("ALTER TABLE $databasename.$tablename ADD PARTITION (...) LOCATION ...")

It doesn't throw any error but not even creating any partition. Is it the case that I can't specify databaseName in spark sql?

Upvotes: 0

Views: 105

Answers (1)

Anupam Alok
Anupam Alok

Reputation: 433

use Database

Command is supported in Latest Spark version you can use

sparksession.sql("use $databasename");
sparksession.sql("ALTER TABLE $tablename ADD PARTITION (...) LOCATION ...");

Try using the above code this can solve you problem.

Upvotes: 1

Related Questions