Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2023 01:10 AM
@Retko Okter :
Use the isEmpty method of the DataFrame API in Spark to check if a Delta table is empty
from delta.tables import DeltaTable
def is_delta_table_empty(table_name):
delta_table = DeltaTable.forPath(spark, table_name)
return delta_table.toDF().isEmpty()
# Usage example
if is_delta_table_empty("table_name"):
print("Table is empty")
else:
print("Table is not empty")