Find the size of a table snapshot

How to find the size of a table.

Written by mathan.pillai

Last published at: January 10th, 2025

This article explains how to find the size of a table snapshot.

The command used depends on if you are trying to find the size of a Delta table or a non-Delta table.

Size of a Delta table snapshot

To find the size of a Delta table snapshot, you can use a Apache Spark SQL command.

%scala

import com.databricks.sql.transaction.tahoe._
val deltaLog = DeltaLog.forTable(spark, "dbfs:/<path-to-delta-table>")
val snapshot = deltaLog.snapshot               // the current delta table snapshot
println(s"Total file size (bytes): ${deltaLog.snapshot.sizeInBytes}")

Size of a non-Delta table snapshot

You can determine the size of a non-Delta table snapshot by calculating the total sum of the individual files within the underlying directory.

You can also use queryExecution.analyzed.stats to return the size.

%scala

spark.read.table("<non-delta-table-name>").queryExecution.analyzed.stats