DROP TABLE IF EXISTS mdc_appdev_lifeflux.mdc_flx_events_procedures_icd; CREATE TABLE mdc_appdev_lifeflux.mdc_flx_events_procedures_icd PARTITIONED BY (internalpatientid) STORED AS PARQUET AS select insertDate, dateOfEvent, eventXML, internalpatientid from ( SELECT now() insertDate, procedures_icd.startdate dateOfEvent, CONCAT ( '', '',isnull(cast(procedures_icd.ageatevent as string),'Null'), '','',isnull(cast(procedures_icd.servicecode as string),'Null'), '','',isnull(cast(procedures_icd.insert_date as string),'Null'), '','',isnull(cast(procedures_icd.internalpatientid as string),'Null'), '','',isnull(cast(procedures_icd.startdate as string),'Null'), '','',isnull(cast(procedures_icd.sequencenumber as string),'Null'), '','',isnull(cast(procedures_icd.servicecodedesc as string),'Null'), '', '' ) eventXML, procedures_icd.internalpatientid internalpatientId FROM mimic_db.procedures_icd INNER JOIN mimic_db.demographics_static ON (mimic_db.procedures_icd.internalpatientid=mimic_db.demographics_static.internalpatientid) ) tbl;