我在hive中有一个名为PHAR的表。 当我尝试通过spark-submit(Spark版本1.6)创建视图/表时,我收到以下错误。 查询在hive / beeline shell中运行良好。
User class threw exception: org.apache.spark.sql.AnalysisException: cannot resolve 'ph.pharmacy_id' given input columns: []; line 1 pos
查看导致错误的说明:
create view if not exists V_TMP as
select ph.pharmacy_id
, ph.pharmacy_nm
, ph.pharmacy_addr_line_1_txt
, ph.pharmacy_addr_line_2_txt
, ph.pharmacy_addr_line_3_txt
, ph.pharmacy_addr_line_4_txt --optional
from PHAR ph ;
表格描述:
hive> desc PHAR ;
+---------------------------+---------------+----------+--+
| col_name | data_type | comment |
+---------------------------+---------------+----------+--+
| pharmacy_id | varchar(510) | |
| pharmacy_nm | varchar(205) | |
| pharmacy_addr_line_1_txt | varchar(200) | |
| pharmacy_addr_line_2_txt | varchar(50) | |
| pharmacy_addr_line_3_txt | varchar(50) | |
| pharmacy_addr_line_4_txt | varchar(50) | |
+---------------------------+---------------+----------+--+
答案 0 :(得分:0)
我意识到查询中的注释以“ - ”开头。 虽然看起来它不适用于查询中的下一行,但是spark-sql在一行中解析整个sql文本。所以任何事情之后 - 甚至在下一行中都被视为评论。 我删除了评论,解决问题的有效查询是:
create view if not exists V_TMP as
select ph.pharmacy_id
, ph.pharmacy_nm
, ph.pharmacy_addr_line_1_txt
, ph.pharmacy_addr_line_2_txt
, ph.pharmacy_addr_line_3_txt
, ph.pharmacy_addr_line_4_txt
from PHAR ph ;