<?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: Drop and re-create table Using notebook, While loading objects doesn't exist while insert &amp;amp; in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Drop-and-re-create-table-Using-notebook-While-loading-objects/m-p/4090405#M3498</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/716552"&gt;@Dhanapal&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand your need now, here's my suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like mentioned in the case below, you can explicitly refresh the table metadata using the &lt;STRONG&gt;spark.catalog.refreshTable("table_name")&lt;/STRONG&gt; command.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/45809152/how-to-refresh-a-table-and-do-it-concurrently" target="_blank"&gt;apache spark - How to refresh a table and do it concurrently? - Stack Overflow&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran some tests and deleted a table named salesorders.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_0-1723169418978.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147616i0F2C0DACC223A310/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_0-1723169418978.png" alt="vhuijieymsft_0-1723169418978.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error occurs when I create the form with the same name again.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_1-1723169418985.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147617i603FC75AE69C848B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_1-1723169418985.png" alt="vhuijieymsft_1-1723169418985.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After using the following command, the table with the same name is created successfully.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Define the table name
table_name = "salesorders"

# Drop and create table with actual schema
spark.sql(f"""
    DROP TABLE IF EXISTS {table_name}
""")

spark.sql(f"""
    CREATE TABLE {table_name} (
        SalesOrderID INT,
        OrderDate DATE,
        CustomerID INT,
        Item STRING,
        Quantity INT,
        UnitPrice DOUBLE,
        Tax DOUBLE,
        TotalAmount DOUBLE
    )
""")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_2-1723169475879.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147622i387A443C26536B50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_2-1723169475879.png" alt="vhuijieymsft_2-1723169475879.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that when you use it, change the table names, column names, and data types to your own.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any other questions please feel free to contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Aug 2024 02:14:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-08-09T02:14:24Z</dc:date>
    <item>
      <title>Drop and re-create table Using notebook, While loading objects doesn't exist while insert &amp; fail</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Drop-and-re-create-table-Using-notebook-While-loading-objects/m-p/4089927#M3491</link>
      <description>&lt;P&gt;We have a notebook, which has script as below (refer the screen shot)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Drop table from Lakehouse and Create table same in takehouse. When we try to load data, its getting some weird error .. saying "Table is not found" or&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Error name - AnalysisException, Error value - [TABLE_OR_VIEW_NOT_FOUND] The table or view `lh_sales`.`dim_cots` cannot be found.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dhanapal_0-1723141576459.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147466i9E5E04D83A58A540/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dhanapal_0-1723141576459.png" alt="Dhanapal_0-1723141576459.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To Resolve notebook issue, We have added some pyspark script to refresh meta_data, but still failing.. If we re-run the failure step &amp;amp; its getting executed successfully. Some of my friends says, its &lt;SPAN&gt;&lt;SPAN class=""&gt;intermittent failure..&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;Any alternative or perment fix to resolve this type of issues ?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dhanapal_1-1723141701218.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147467iD8428039ED97CBB1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Dhanapal_1-1723141701218.png" alt="Dhanapal_1-1723141701218.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 18:34:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Drop-and-re-create-table-Using-notebook-While-loading-objects/m-p/4089927#M3491</guid>
      <dc:creator>Dhanapal</dc:creator>
      <dc:date>2024-08-08T18:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Drop and re-create table Using notebook, While loading objects doesn't exist while insert &amp;</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Drop-and-re-create-table-Using-notebook-While-loading-objects/m-p/4090405#M3498</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/716552"&gt;@Dhanapal&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand your need now, here's my suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Like mentioned in the case below, you can explicitly refresh the table metadata using the &lt;STRONG&gt;spark.catalog.refreshTable("table_name")&lt;/STRONG&gt; command.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/45809152/how-to-refresh-a-table-and-do-it-concurrently" target="_blank"&gt;apache spark - How to refresh a table and do it concurrently? - Stack Overflow&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran some tests and deleted a table named salesorders.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_0-1723169418978.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147616i0F2C0DACC223A310/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_0-1723169418978.png" alt="vhuijieymsft_0-1723169418978.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error occurs when I create the form with the same name again.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_1-1723169418985.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147617i603FC75AE69C848B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_1-1723169418985.png" alt="vhuijieymsft_1-1723169418985.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After using the following command, the table with the same name is created successfully.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Define the table name
table_name = "salesorders"

# Drop and create table with actual schema
spark.sql(f"""
    DROP TABLE IF EXISTS {table_name}
""")

spark.sql(f"""
    CREATE TABLE {table_name} (
        SalesOrderID INT,
        OrderDate DATE,
        CustomerID INT,
        Item STRING,
        Quantity INT,
        UnitPrice DOUBLE,
        Tax DOUBLE,
        TotalAmount DOUBLE
    )
""")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_2-1723169475879.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1147622i387A443C26536B50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_2-1723169475879.png" alt="vhuijieymsft_2-1723169475879.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that when you use it, change the table names, column names, and data types to your own.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any other questions please feel free to contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 02:14:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Drop-and-re-create-table-Using-notebook-While-loading-objects/m-p/4090405#M3498</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-09T02:14:24Z</dc:date>
    </item>
  </channel>
</rss>

