pyspark - Table not found error after submitting a spark script consisting with spark sql after enabling hivesupport -
i want run simple spark script has sparksql query basicaly hiveql. corresponding tables saved in spark-warehouse folder.
from pyspark.sql import sparksession
from pyspark.sql import row spark=sparksession.builder.config("spark.sql.warehouse.dir", "file:///c:/tmp").appname("testapp").enablehivesupport().getorcreate() sqlstring="select lflow1.leasetype leasetype, lflow1.status status, lflow1.property property, lflow1.city city, lesflow2.dealtype dealtype, lesflow2.area area, lflow1.did did, lesflow2.mid mid lflow1, lesflow2 lflow1.did = lesflow2.mid" def querybuilder(sqlval): df=spark.sql(sqlval) df.show() result=querybuilder(sqlstring) print(result.collect()) print("type of",type(result))
after performing spark submit operation facing bellow error
py4j.protocol.py4jjavaerror: error occurred while calling o27.sql. : org.apache.spark.sql.analysisexception: table or view not found: lflow1; line 1 pos 211
i not figure out why happening. have seen posts stackoverflow , suggested have enable hive support have done in script writing enablehivesupport(). still getting error. running pyspark 2.2 in windows 10. kindly me figure out
i have created , saved lflow1 , lesflow2 permanent table in pyspark shell dataframe. here mycode
df = spark.read.json("c:/users/codemen/desktop/test sparkreport engine/leaseflow1.json") df2 = spark.read.json("c:/users/codemen/desktop/test sparkreport engine/leaseflow2.json") df.write.saveastable("lflow1") df2.write.saveastable("lesflow2")
in pyspark shell have performed query
spark.sql("select lflow1.leasetype leasetype, lflow1.status status, lflow1.property property, lflow1.city city, lesflow2.dealtype dealtype, lesflow2.area area, lflow1.did did, lesflow2.mid mid lflow1, lesflow2 lflow1.did = lesflow2.mid").show()
and pyspark console showing this
Comments
Post a Comment