SQL 陳述式中的錯誤:AnalysisException: Table or view not foundError in SQL statement: AnalysisException: Table or view not found


當您嘗試查詢資料表或視圖時,您會收到此錯誤:When you try to query a table or view, you get this error:

AnalysisException:Table or view not found when trying to query a global temp view


您通常會建立全域 temp 查看,讓它們可以從不同的會話存取並保持運作,直到應用程式結束為止。You typically create global temp views so they can be accessed from different sessions and kept alive until the application ends. 您可以 temp 使用下列語句來建立全域 view:You can create a global temp view with the following statement:


在這裡, dfDataFrameHere, df is the DataFrame. 建立此視圖的另一種方式是使用:Another way to create the view is with:

CREATE GLOBAL TEMP VIEW <global-view-name>

所有全域暫存視圖都會系結至名為的系統暫存資料庫 global_tempAll global temporary views are tied to a system temporary database named global_temp. 如果您在不明確提及資料庫的情況下查詢全域資料表或視圖 global_temp ,則會發生錯誤。If you query the global table or view without explicitly mentioning the global_temp database, then the error occurs.


請一律使用限定的資料表名稱與 global_temp 資料庫,讓您可以順利查詢全域查看資料。Always use the qualified table name with the global_temp database, so that you can query the global view data successfully.

例如:For example:

select * from global_temp.<global-view-name>;