[英]hive left outer join with between condition
我知道我們不能在蜂巢中進行不平等的聯接。 我需要將下面的查詢轉換為蜂巢(hql)。 任何建議/解決方法將不勝感激。
table_A和table_B都沒有主鍵。
SELECT *
FROM table_A f
LEFT OUTER JOIN table_B dom1
ON dom1.country = f.issuing_office_country
AND dom1.ulr_source = 'Loss'
AND dom1.valuation_class = f.dsp_level_join
AND dom1.year_type = 'UW'
AND f.undwrtr_yr_prd_fy_mnth BETWEEN dom1.start_year_month AND dom1.end_year_month
LEFT OUTER JOIN table_B dom2
ON dom2.country = f.issuing_office_country
AND dom2.ulr_source = 'Short'
AND dom2.valuation_class = f.div_level_join
AND dom2.year_type = 'UW'
AND f.undwrtr_yr_prd_fy_mnth BETWEEN dom2.start_year_month AND dom2.end_year_month
我認為您可以使用where
子句解決此問題(近似)。 它應顯示為:
where (f.undwrtr_yr_prd_fy_mnth BETWEEN dom1.start_year_month AND dom1.end_year_month or
dom1.valuation_class is null
) and
(f.undwrtr_yr_prd_fy_mnth BETWEEN dom2.start_year_month AND dom2.end_year_month or
dom2.valuation_class is null
)
在where
子句和on
子句中具有條件之間存在一些細微的差異,但是它們可能不會影響您的查詢。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.