Reputation: 71
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
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