Issue with saving hive table in Pyspark

queries

cust=spark.read.format(“csv”).load("/public/retail_db/customers")
cust.createOrReplaceTempView(“cust”)
spark.sql(“select _C7 as state,count(*) count from cust where _c1 like ‘M%’ group by _c7”).write.mode(“overwrite”).option(“fileFormat”,“parquet”).option(“compression”,“gzip”).format(“hive”).saveAsTable(“anjali_orders.customer_a4_m”)

error

File “”, line 1, in
File “/usr/hdp/current/spark2-client/python/pyspark/sql/readwriter.py”, line 744, in saveAsTable
self._jwrite.saveAsTable(name)
File “/usr/hdp/current/spark2-client/python/lib/py4j-0.10.6-src.zip/py4j/java_gateway.py”, line 1160, in call
File “/usr/hdp/current/spark2-client/python/pyspark/sql/utils.py”, line 69, in deco
raise AnalysisException(s.split(’: ‘, 1)[1], stackTrace)
pyspark.sql.utils.AnalysisException: u’org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(message:java.security.AccessControlException: Permission denied: user=anjalikrishna1985, access=WRITE, inode="/apps/hive":hdfs:hdfs:drwxr-xr-x\n\tat org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:353)\n\tat org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:252)\n\tat org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:190)\n\tat org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1950)\n\tat org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1934)\n\tat org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPathAccess(FSDirectory.java:1908)\n\tat org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkAccess(FSNamesystem.java:8800)\n\tat org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.checkAccess(NameNodeRpcServer.java:2089)\n\tat org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.checkAccess(ClientNamenodeProtocolServerSideTranslatorPB.java:1466)\n\tat org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)\n\tat org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:640)\n\tat org.apache.hadoop.ipc.RPC$Server.call(RPC.java:982)\n\tat org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2351)\n\tat org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2347)\n\tat java.security.AccessController.doPrivileged(Native Method)\n\tat javax.security.auth.Subject.doAs(Subject.java:422)\n\tat org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1869)\n\tat org.apache.hadoop.ipc.Server$Handler.run(Server.java:2347)\n);’

spark.sql(“select _C7 as state,count(*) count from cust where _c1 like ‘M%’ group by _c7”).write.mode(“overwrite”).option(“fileFormat”,“parquet”).option(“compression”,“gzip”).format(“hive”).saveAsTable(“anjali_orders.customer_a4_m”)

Hi @Anjali_krishna_Gopi,

Actually someone deleted warehouse dir thats why we are facing small issue with the hive. we are already working on it and try to bring them up as quickly as possible.

mean-while you can go through below cmd, it will be helpfull-