嗨,我有一个 SQL 查询如下。当我在 PostgreSQL 查询工具中运行相同的查询时,它工作正常。但是当我在 Spark SQL 中尝试时,它在 Spark 日志中显示以下错误
val SQLDF = spark.sqlContext.sql("""
select m.v_number, o.u_id, r_number, v_name, p.pr_name
from
PG_DF_VHM m,
OBU_VIN_DF o,
PROJ_NAME_DF p
where
m.v_number = o.v_number
and p.pr_id in (
select pr_id
from PROJ_USER_DF
where
user_id in (
select user_id
from PG_MAP_DF
where
project_user_id in (
select project_user_id
from PROJ_USER_DF u
where
u.user_id = o.created_by
)
and user_role_id = 3
limit 1
)
)
""")
ERROR ApplicationMaster: User class threw exception: org.apache.spark.sql.AnalysisException: cannot resolve '`o.created_by`' given input columns:24/03/11 06:46:51
ERROR ApplicationMaster: User class threw exception: org.apache.spark.sql.AnalysisException:
cannot resolve '`o.created_by`'
given input columns: [
u.project_id,
u.created_by,
u.user_id,
u.project_user_id,
u.updated_timestamp,
u.is_deleted,
u.updated_by,
u.created_timestamp
]; line 1 pos 33
来自 PG_DF_VHM m, OBU_VIN_DF o, PROJ_NAME_DF p 错误。这里使用一些常见的列来加入。例如 id 是常见的 来自 PG_DF_VHM m 加入 OBU_VIN_DF o 在 m.id=o.id 上加入 PROJ_NAME_DF p 在 m.id =p.id 上
类似这样的事情