Search code examples
apache-sparkhive-table

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


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

Solution

  • Here is an example:

    df.write.saveAsTable('table_name')

    df = spark.table('table_name')