选择仅适用于特定的临时表

时间:2019-01-29 23:43:36

标签: python-3.x pyspark apache-spark-sql apache-zeppelin

我在下面的代码中尝试创建3个临时表,然后在临时表上运行select语句。我正在齐柏林飞艇笔记本中运行代码。如果我在order_temp表上运行select语句,则该代码有效,但如果在其他两个临时表中的任何一个上运行select语句,则返回与以下错误类似的错误。我已经仔细检查过,并且数据框存在并且可以查询。例如,ahist_df.show()将返回记录。有人看到问题出在哪里吗?我是pyspark sql的新手。

代码:

ahist_df.registerTempTable("ahist_temp")

order_df.registerTempTable("order_temp")

pview_df.registerTempTable("pview_temp")




hive_context.sql("select * from ahist_temp").show()

错误:

Traceback (most recent call last):
  File "/tmp/zeppelin_pyspark-5310843562876721701.py", line 367, in <module>
    raise Exception(traceback.format_exc())
Exception: Traceback (most recent call last):
  File "/tmp/zeppelin_pyspark-5310843562876721701.py", line 360, in <module>
    exec(code, _zcUserQueryNameSpace)
  File "<stdin>", line 4, in <module>
  File "/usr/hdp/current/spark-client/python/pyspark/sql/context.py", line 580, in sql
    return DataFrame(self._ssql_ctx.sql(sqlQuery), self)
  File "/usr/hdp/current/spark-client/python/lib/py4j-0.9-src.zip/py4j/java_gateway.py", line 813, in __call__
    answer, self.gateway_client, self.target_id, self.name)
  File "/usr/hdp/current/spark-client/python/pyspark/sql/utils.py", line 51, in deco
    raise AnalysisException(s.split(': ', 1)[1], stackTrace)
AnalysisException: u'Table not found: ahist_temp; line 1 pos 14'

代码:

hive_context.sql("select * from order_temp").show()

0 个答案:

没有答案