How to read a table which is saved by saveAsTable in Apache Spark?

930 views Asked by At

I am trying to save a dataframe by using df.write.saveAsTable("table_name")

but i am unable to retrieve this table again (not in the same run).

I tried

spark.read.table("table_name")

and

spark.sql("select * from table_name")

but both didn't worked give error

 Table or view not found: table_name
1

There are 1 answers

0
A.M. On BEST ANSWER

Here is an example:

df.write.saveAsTable('table_name')

df = spark.table('table_name')