我正在尝试将以下查询等效转换为hive。
更新rpt表中的tier_cd,但是hive 0.13不支持更新,因此使用更改为hive等效项并且输出不正确。
UPDATE test_report A
SET TIER_CD = (SELECT B.TIER_CD FROM lk B
WHERE B.CLASS_CD = A.CLASS_CD AND B.RC_TYPE_CD = 'OATS'
AND A.ACPTD_ROE_CT >= B.BEGIN_QT
AND A.ACPTD_ROE_CT <= B.END_QT
AND EFCTV_DT = (SELECT MAX(C.EFCTV_DT) FROM LK C WHERE
C.CLASS_CD = B.CLASS_CD AND C.RC_TYPE_CD = 'OATS' AND
C.TIER_CD = B.TIER_CD AND
C.EFCTV_DT <= ?
AND B.TIER_CD <> 'I')
WHERE A.YEAR_CD = ?
AND A.MONTH_CD = ?;
等同于等于
select z.*,x.tier_Cd from
(
select * from test_report
where year_Cd=?
and month_Cd=?')z
left outer join
(SELECT B.TIER_CD TIER_cD, A.MKT_CLASS_CD,A.year_cd FROM LK B, test_report A
WHERE B.CLASS_CD = A.CLASS_CD AND B.RC_TYPE_CD = 'OATS'
AND A.ACPTD_ROE_CT >= B.BEGIN_QT
AND A.ACPTD_ROE_CT <= B.END_QT
AND EFCTV_DT = (SELECT MAX(C.EFCTV_DT) FROM LK C WHERE
C.CLASS_CD = B.CLASS_CD AND C.RC_TYPE_CD = 'OATS' AND
C.TIER_CD = B.TIER_CD AND
C.EFCTV_DT <= ?)
AND B.TIER_CD <> 'I')x
on(z.class_Cd=x.Class_Cd)
请帮助解决它的错误。
答案 0 :(得分:0)
Hive不支持多个子查询,而是可以连接三个只有连接的表。我的猜测是你在select (max