I'm trying to update a table based on a match to another table for multiple columns. I've tried what is shown below but I'm getting the error shown. How is this done?
update my_table set flag = '1' where (patient_id, org) in (
select distinct (patient_id, org) from enc where lower(enc_type) like '%visit%'
)
Error:
Error in SQL statement: AnalysisException: IN/EXISTS predicate sub-queries can only be used in Filter/Join and a few commands: 'DeltaUpdateTable [post_partum#1911], [1], named_struct
--- EDIT------------------------------
The following is a full example of updating a table based on a complex query that worked based upon the documentation given in the accepted answer.
MERGE INTO events eve
USING (
select
enc.org as org,
enc.person_id as person_id,
min(encounter_date) as visit_day
from
enc
join events eve on enc.org = eve.org and enc.person_id = eve.person_id and eve.is_post_partum = 1
where
lower(enc.enc_type) like '%visit%'
group by 1, 2
) visits
ON eve.org = visits.org and eve.person_id = visits.person_id
WHEN MATCHED THEN
UPDATE SET eve.delivery_date = visits.visit_day
;