<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Append to a record when updating Delta Table in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31213#M22710</link>
    <description>&lt;P&gt;Set is just the equivalent of SQL UPDATE SET, so it sets a value from one table to a value from the expression.&lt;/P&gt;&lt;P&gt;So you can use built-in functions like col or exp:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from pyspark.sql.functions import *
...
set = { 'gender': col('segments_old.segments') + col('updates.segments') }
OR
set = { 'gender': exp('segments_old.segments + updates.segments') }&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image.png"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1474i06ADA6F100A7B9D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Sep 2022 19:21:33 GMT</pubDate>
    <dc:creator>Hubert-Dudek</dc:creator>
    <dc:date>2022-09-21T19:21:33Z</dc:date>
    <item>
      <title>Append to a record when updating Delta Table</title>
      <link>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31212#M22709</link>
      <description>&lt;P&gt;I am updating the delta table in Databricks as follows &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    segments_data.alias('segments_old').merge(
        segments_data_new.alias("updates"),
        "segments_old.source_url = updates.source_url",
    ).whenMatchedUpdate(
        set={"segments": "segments_old.segments"  + "updates.segments"  } # &amp;lt;- the line is pseudocode, don't know correct API
    ).whenNotMatchedInsertAll().execute()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;where "segments" is a list of StructType&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    StructField(
      "segments",
      StructType(
        [ ....&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How can I append to the existing list - namely append to "segments" column in segments_old from updates within "whenMatchedUpdate"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of replacing - say "segments":  "updates.segments" I would like to append "segments": "segments_old.segments"  + "updates.segments" &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for suggestions in advance! &lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 10:40:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31212#M22709</guid>
      <dc:creator>Serhii</dc:creator>
      <dc:date>2022-09-21T10:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: Append to a record when updating Delta Table</title>
      <link>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31213#M22710</link>
      <description>&lt;P&gt;Set is just the equivalent of SQL UPDATE SET, so it sets a value from one table to a value from the expression.&lt;/P&gt;&lt;P&gt;So you can use built-in functions like col or exp:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from pyspark.sql.functions import *
...
set = { 'gender': col('segments_old.segments') + col('updates.segments') }
OR
set = { 'gender': exp('segments_old.segments + updates.segments') }&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image.png"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1474i06ADA6F100A7B9D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2022 19:21:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31213#M22710</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-09-21T19:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Append to a record when updating Delta Table</title>
      <link>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31214#M22711</link>
      <description>&lt;P&gt;Hi @Sergii Ivakhno​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 06:24:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31214#M22711</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-03T06:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Append to a record when updating Delta Table</title>
      <link>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31215#M22712</link>
      <description>&lt;P&gt;Yes it worked for us - thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 16:58:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/append-to-a-record-when-updating-delta-table/m-p/31215#M22712</guid>
      <dc:creator>Serhii</dc:creator>
      <dc:date>2022-11-01T16:58:01Z</dc:date>
    </item>
  </channel>
</rss>

