2021年3月6日星期六

Is there a way to "set *" on a Spark/Databricks merge query when all columns are not in the source?

I'm merging data from one table into another in Spark/Databricks. I can do and update set * if all columns are selected but this fails if all columns are not selected (e.g. if there is a col9 in the dst table in the query below). Is there a way to do this merge without repeating the long list of columns in the when matched (i.e. match by column name in the source query) and when not matched segments?

merge into demo dst  using (  select distinct    col1,    col2,    col3,    col4,    col5,    col6,    col7,    col8  from    demo_raw  where 1=1    and col1 = 'ac'    and col2 is not null  ) src  on src.col1 = dst.col1  when matched then    update set *  when not matched then    insert *  ;    
https://stackoverflow.com/questions/66505889/is-there-a-way-to-set-on-a-spark-databricks-merge-query-when-all-columns-are March 06, 2021 at 08:57PM

没有评论:

发表评论