2016-01-13 70 views
0

我試圖將下面的查詢轉換爲相當於配置單元。配置單元相當於sql更新

更新rpt表中的tier_cd,但hive 0.13不支持更新,因此使用更改爲配置單元等效和輸出不正確。

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

Hive不支持多個子查詢,您可以連接三個只有連接的表。我的猜測是你在select (max

附近發生錯誤