<?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: Multi Statement Writes from Spark to Snowflake in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7979#M3713</link>
    <description>&lt;P&gt;Yes. I have tried the DELETE command using sfutils runQuery and then my data insertion using df.write method. They are captured in different sessions with two different session id in Snowflake.  I basically want to wrap these two statements as a single transaction&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 12:45:00 GMT</pubDate>
    <dc:creator>pvignesh92</dc:creator>
    <dc:date>2023-03-10T12:45:00Z</dc:date>
    <item>
      <title>Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7973#M3707</link>
      <description>&lt;P&gt;Does Spark support multi statement writes to Snowflake in a single session? To elaborate, I have a requirement where I need to do &lt;/P&gt;&lt;OL&gt;&lt;LI&gt;A selective deletion of data from a Snowflake table and &lt;/LI&gt;&lt;LI&gt;Insert records to Snowflake table ( Ranges from around 1 M rows)&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I want to wrap these both into a single transaction so that I could get Consistency here. I can't use overwrite mode as it will overwrite my entire table in Snowflake. I have seen runQuery of sfutils support multiStatements but it is more to handle data within Snowflake and not from Databricks to Snowflake. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vignesh &lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 08:32:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7973#M3707</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-03-10T08:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7974#M3708</link>
      <description>&lt;P&gt;are you looking for something like a merge (upsert) or a replaceWhere?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 10:53:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7974#M3708</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-03-10T10:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7975#M3709</link>
      <description>&lt;P&gt;Yes. It's kind of replace where.  My input tables are in Databricks layer. So I join them and write to a dataframe. Then I want to write this dataframe to Snowflake table by selectively deleting certain data as I have separate pipeline for different regions. So my overwrite on Snowflake table should only be for that region. &lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 12:16:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7975#M3709</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-03-10T12:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7976#M3710</link>
      <description>&lt;P&gt;Hi @Vigneshraja Palaniraj​&amp;nbsp;, Could you please check the below document if this meets your use case&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/sql/language-manual/delta-merge-into.html" target="test_blank"&gt;https://docs.databricks.com/sql/language-manual/delta-merge-into.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 12:40:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7976#M3710</guid>
      <dc:creator>Lakshay</dc:creator>
      <dc:date>2023-03-10T12:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7977#M3711</link>
      <description>&lt;P&gt;The only way this can be done in a single command is if snowflake has something like a replaceWhere.  I did some searching but did not find anything.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 12:40:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7977#M3711</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-03-10T12:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7978#M3712</link>
      <description>&lt;P&gt;Hi @Lakshay Goel​&amp;nbsp;. Thanks for your response. This option is more about when you want to update your delta table that is existing in Databricks layer itself. But I'm looking for the option when I want to write to Snowflake with dataframe write API using Spark snowflake connector&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 12:42:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7978#M3712</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-03-10T12:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7979#M3713</link>
      <description>&lt;P&gt;Yes. I have tried the DELETE command using sfutils runQuery and then my data insertion using df.write method. They are captured in different sessions with two different session id in Snowflake.  I basically want to wrap these two statements as a single transaction&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 12:45:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7979#M3713</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-03-10T12:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7980#M3714</link>
      <description>&lt;P&gt;if snowflake does not have the possibility, it is not possible in spark either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 13:15:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7980#M3714</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-03-10T13:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Multi Statement Writes from Spark to Snowflake</title>
      <link>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7981#M3715</link>
      <description>&lt;P&gt;In my analysis, I got the below understanding &lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If your data is sitting in Snowflake and you have a set of DDL/DML queries that need to wrapped into a single transaction, you can use MULTI_STATEMENT option to 0 and use snowflake utils runQuery method to run them as single transaction. All these command will be executed in Snowflake with a single session id&lt;/LI&gt;&lt;LI&gt;If the requirement is to write a  dataframe computed from Databricks to Snowflake along with DDL command, then they will be executed as two different transactions with two different session ids. So not really possible out of the box to wrap them to a single session. &lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 21 Mar 2023 12:16:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/multi-statement-writes-from-spark-to-snowflake/m-p/7981#M3715</guid>
      <dc:creator>pvignesh92</dc:creator>
      <dc:date>2023-03-21T12:16:54Z</dc:date>
    </item>
  </channel>
</rss>

