Skip to content

Commit e52376c

Browse files
committed
Add numDeltaFiles/totalDeltaFilesByteSize to SnapshotDescriptor
Adds numDeltaFiles and totalDeltaFilesByteSize to the SnapshotDescriptor trait with default implementations that throw UnsupportedOperationException, and overrides them in Snapshot to delegate to logSegment. This lets callers read these file statistics through the SnapshotDescriptor abstraction instead of reaching into the snapshot's log segment directly.
1 parent 13ff198 commit e52376c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

spark/src/main/scala/org/apache/spark/sql/delta/Snapshot.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ trait SnapshotDescriptor extends DeltaLoggingProvider {
6767

6868
def schema: StructType = metadata.schema
6969

70+
def numDeltaFiles: Long =
71+
throw new UnsupportedOperationException("numDeltaFiles is not implemented for this descriptor")
72+
def totalDeltaFilesByteSize: Long =
73+
throw new UnsupportedOperationException(
74+
"totalDeltaFilesByteSize is not implemented for this descriptor")
75+
7076
def dataPath: Path
7177

7278
protected[delta] def numOfFilesIfKnown: Option[Long]
@@ -124,6 +130,8 @@ class Snapshot(
124130
import org.apache.spark.sql.delta.implicits._
125131

126132
override def dataPath: Path = deltaLog.dataPath
133+
override def numDeltaFiles: Long = logSegment.numDeltaFiles
134+
override def totalDeltaFilesByteSize: Long = logSegment.totalDeltaFilesByteSize
127135

128136
protected def spark = SparkSession.active
129137

0 commit comments

Comments
 (0)