<?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 How to quickly check if Delta Table is Empty in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-quickly-check-if-delta-table-is-empty/m-p/8041#M3769</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need some quick way to return True if Delta Table is Empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tried this, but is is quite slow when checking more tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;spark.read.table("table_name").count()&lt;/P&gt;&lt;P&gt;spark.read.table("table_name").rdd.isEmpty()&lt;/P&gt;&lt;P&gt;len(spark.read.table("table_name").head(1)) == 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 07:47:18 GMT</pubDate>
    <dc:creator>Retko</dc:creator>
    <dc:date>2023-03-09T07:47:18Z</dc:date>
    <item>
      <title>How to quickly check if Delta Table is Empty</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-quickly-check-if-delta-table-is-empty/m-p/8041#M3769</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need some quick way to return True if Delta Table is Empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tried this, but is is quite slow when checking more tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;spark.read.table("table_name").count()&lt;/P&gt;&lt;P&gt;spark.read.table("table_name").rdd.isEmpty()&lt;/P&gt;&lt;P&gt;len(spark.read.table("table_name").head(1)) == 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 07:47:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-quickly-check-if-delta-table-is-empty/m-p/8041#M3769</guid>
      <dc:creator>Retko</dc:creator>
      <dc:date>2023-03-09T07:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to quickly check if Delta Table is Empty</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-quickly-check-if-delta-table-is-empty/m-p/8042#M3770</link>
      <description>&lt;P&gt;@Retko Okter​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Use the isEmpty method of the DataFrame API in Spark to check if a Delta table is empty&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from delta.tables import DeltaTable
&amp;nbsp;
def is_delta_table_empty(table_name):
  delta_table = DeltaTable.forPath(spark, table_name)
  return delta_table.toDF().isEmpty()
&amp;nbsp;
# Usage example
if is_delta_table_empty("table_name"):
  print("Table is empty")
else:
  print("Table is not empty")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 08:10:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-quickly-check-if-delta-table-is-empty/m-p/8042#M3770</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-13T08:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to quickly check if Delta Table is Empty</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-quickly-check-if-delta-table-is-empty/m-p/8043#M3771</link>
      <description>&lt;P&gt;Hi @Retko Okter​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just wanted to check in if you were able to resolve your issue. If yes, would you be happy to mark an answer as best? If not, please tell us so we can help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 09:59:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-quickly-check-if-delta-table-is-empty/m-p/8043#M3771</guid>
      <dc:creator>Vartika</dc:creator>
      <dc:date>2023-03-31T09:59:44Z</dc:date>
    </item>
  </channel>
</rss>

