Search code examples
apache-sparkapache-spark-sqlspark-streaming

Executing multiple SQL queries on Spark - Table or view not found


I trying to execute these spark statements but it is not working

spark.sql("CREATE OR REPLACE GLOBAL TEMPORARY VIEW VIEW_1 
AS SELECT * from orc.`/apps/hive/warehouse/userdb.db/rb`")   

spark.sql("CREATE OR REPLACE GLOBAL TEMPORARY VIEW VIEW_2 AS SELECT * from VIEW_1") 

spark.sql("SELECT * from VIEW_2").show()

This fails with the following error -

Table or view not found: VIEW_1


Solution

  • Why are you registering your data as GLOBAL TEMPORARY VIEW Try using Just TEMPORARY VIEW

    global temp view to share the data through different sessions