<?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 _sqldf value in case of query failure in %sql cell in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37272#M26308</link>
    <description>&lt;P&gt;I am trying to write a code for Error Handling in Databricks notebook in case of a SQL magic cell failure. I have a %sql cell followed by some python code in next cells. I want to abort the notebook if the query in %sql cell fails. To do so I am looking at the value of _sqldf variable. I am aware that the temporary variable holds the sql results when the query is successful however I couldn't find How the magic cell will behave in case of let say SQL Server connection failure. I want to stop the execution of complete notebook in case SQL magic cell fails. As the sql REPL cannot handle the python's code, I cannot throw the exception using try/except in the same %sql cell.&lt;BR /&gt;Am I thinking in the right direction or is there any other way to handle the failure?&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2023 06:22:17 GMT</pubDate>
    <dc:creator>pjain</dc:creator>
    <dc:date>2023-07-10T06:22:17Z</dc:date>
    <item>
      <title>_sqldf value in case of query failure in %sql cell</title>
      <link>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37272#M26308</link>
      <description>&lt;P&gt;I am trying to write a code for Error Handling in Databricks notebook in case of a SQL magic cell failure. I have a %sql cell followed by some python code in next cells. I want to abort the notebook if the query in %sql cell fails. To do so I am looking at the value of _sqldf variable. I am aware that the temporary variable holds the sql results when the query is successful however I couldn't find How the magic cell will behave in case of let say SQL Server connection failure. I want to stop the execution of complete notebook in case SQL magic cell fails. As the sql REPL cannot handle the python's code, I cannot throw the exception using try/except in the same %sql cell.&lt;BR /&gt;Am I thinking in the right direction or is there any other way to handle the failure?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 06:22:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37272#M26308</guid>
      <dc:creator>pjain</dc:creator>
      <dc:date>2023-07-10T06:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: _sqldf value in case of query failure in %sql cell</title>
      <link>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37273#M26309</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/84564"&gt;@pjain&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Why not triggering the sql code with spark.sql? IMO it would be much easier to create error handling by using python.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 06:33:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37273#M26309</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2023-07-10T06:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: _sqldf value in case of query failure in %sql cell</title>
      <link>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37367#M26335</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/84564"&gt;@pjain&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We haven't heard from you since the last response from &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/79106"&gt;@daniel_sahal&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;​, and I was checking back to see if her suggestions helped you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or else, If you have any solution, please share it with the community, as it can be helpful to others.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also, Please don't forget to click on the "Select As Best" button whenever the information provided helps resolve your question.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 10:12:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37367#M26335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-11T10:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: _sqldf value in case of query failure in %sql cell</title>
      <link>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37397#M26341</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/79106"&gt;@daniel_sahal&lt;/a&gt;&amp;nbsp;, this was my initial thought too but many scripts are using the %sql cell and changing the code would take more effort than error handling. Also, there are multiple queries running in a single magic cell. This is the reason why I wanted to handle the failure in the magic cell itself.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am planning to re-evaluate this with my team and we might take the spark.sql path. Will keep this thread updated on the actions.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 18:35:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37397#M26341</guid>
      <dc:creator>pjain</dc:creator>
      <dc:date>2023-07-11T18:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: _sqldf value in case of query failure in %sql cell</title>
      <link>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37398#M26342</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous. Thank you for checking in. I am still looking for the solutions and will update the thread with my findings.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 18:37:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sqldf-value-in-case-of-query-failure-in-sql-cell/m-p/37398#M26342</guid>
      <dc:creator>pjain</dc:creator>
      <dc:date>2023-07-11T18:37:07Z</dc:date>
    </item>
  </channel>
</rss>

