<?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: Delta table and AnalysisException: [PATH_NOT_FOUND] Path does not exist in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/delta-table-and-analysisexception-path-not-found-path-does-not/m-p/81146#M36238</link>
    <description>&lt;P&gt;yes it is weird , workaround for this&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;files &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; dbutils.fs.&lt;/SPAN&gt;&lt;SPAN&gt;ls&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"s3 bucket or azure blob path"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;file_paths &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;file&lt;/SPAN&gt;&lt;SPAN&gt;.path &lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;file&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; files]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; target_path &lt;/SPAN&gt;&lt;SPAN&gt;not&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; file_paths:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dbutils.fs.&lt;/SPAN&gt;&lt;SPAN&gt;mkdirs&lt;/SPAN&gt;&lt;SPAN&gt;(target_path)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 31 Jul 2024 04:21:22 GMT</pubDate>
    <dc:creator>kumar_ravi</dc:creator>
    <dc:date>2024-07-31T04:21:22Z</dc:date>
    <item>
      <title>Delta table and AnalysisException: [PATH_NOT_FOUND] Path does not exist</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-table-and-analysisexception-path-not-found-path-does-not/m-p/53411#M29789</link>
      <description>&lt;P&gt;I am performing some tests with delta tables. For each test, I write a delta table to Azure Blob Storage. Then I manually delete the delta table. After deleting the table and running my code again, I get this error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;AnalysisException: [PATH_NOT_FOUND] Path does not exist: /mnt/delta-sharing/temp/df.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a minimal working example to reproduce my problem and the exact order of operations I am performing.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Minimal working example:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Databricks notebook cell 1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from delta.tables import DeltaTable&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Databricks notebook cell 2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;df = spark.createDataFrame(
    [
        (0, 1)
    ],
    ('col_1', 'col_2')
)

path = '/mnt/delta-sharing/temp/df'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Databricks notebook cell 3:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# If delta table does not exist, create it
if not DeltaTable.isDeltaTable(spark, path):
    print('Delta table does not exist. Creating it')
    df.write.format('delta').save(path)
    delta_table = DeltaTable.forPath(spark, path)

# Load existing data in the delta table
delta_table = DeltaTable.forPath(spark, path)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Order of operations:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Step 1&lt;/STRONG&gt;: Check in Azure Blob Storage that the path provided in cell 2 is empty:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 482px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/5265i8CA83E4BE3014B19/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Step 2&lt;/STRONG&gt;: Run all three cells in the notebook. I get the error:&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;AnalysisException: [PATH_NOT_FOUND] Path does not exist: /mnt/delta-sharing/temp/df.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 847px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/5266i73A4E6F9C8CD7CE7/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Step 3&lt;/STRONG&gt;: Don't do anything else except rerun cell 3. I do not get an error, and the delta table is created successfully:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 724px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/5268iC913A9B903C08B41/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 363px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/5274iAB17AB474BB945B5/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Step 4&lt;/STRONG&gt;: Delete the delta table&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 531px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/5275i1A3A979413BD1753/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Step 5&lt;/STRONG&gt;: Rerun cell 3. Get the error: "AnalysisException&lt;SPAN&gt;: [PATH_NOT_FOUND] Path does not exist: /mnt/delta-sharing/temp/df."&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&lt;STRONG&gt;Step 6&lt;/STRONG&gt;: Rerun cell 3. The delta table is created successfully.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;As shown above, every time I delete the delta table, I have to rerun cell 3 twice to successfully enter the if statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if not DeltaTable.isDeltaTable(spark, path)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I should note that there are some random (at least to me) times when if I restart the cluster or detach and reattach the notebook then the first run of cell 3 works. But then after deleting the delta table I always have to run cell 3 twice for the delta table to be created.&lt;/P&gt;&lt;P&gt;Why is this happening? Is this a problem with delta table or Azure Blob Storage? Is there any solution? Is there a best practice for deleting delta tables that I am violating?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 22:18:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-table-and-analysisexception-path-not-found-path-does-not/m-p/53411#M29789</guid>
      <dc:creator>alex-syk</dc:creator>
      <dc:date>2023-11-21T22:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Delta table and AnalysisException: [PATH_NOT_FOUND] Path does not exist</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-table-and-analysisexception-path-not-found-path-does-not/m-p/81146#M36238</link>
      <description>&lt;P&gt;yes it is weird , workaround for this&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;files &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; dbutils.fs.&lt;/SPAN&gt;&lt;SPAN&gt;ls&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"s3 bucket or azure blob path"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;file_paths &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;file&lt;/SPAN&gt;&lt;SPAN&gt;.path &lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;file&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; files]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; target_path &lt;/SPAN&gt;&lt;SPAN&gt;not&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; file_paths:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dbutils.fs.&lt;/SPAN&gt;&lt;SPAN&gt;mkdirs&lt;/SPAN&gt;&lt;SPAN&gt;(target_path)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 31 Jul 2024 04:21:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-table-and-analysisexception-path-not-found-path-does-not/m-p/81146#M36238</guid>
      <dc:creator>kumar_ravi</dc:creator>
      <dc:date>2024-07-31T04:21:22Z</dc:date>
    </item>
  </channel>
</rss>

