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 视图: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_temp 的系统临时数据库。All 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>;