Class AddFile

Object
io.delta.kernel.internal.actions.RowBackedAction
io.delta.kernel.internal.actions.AddFile

public class AddFile extends RowBackedAction
Delta log action representing an `AddFile`
  • Field Details

    • SCHEMA_WITHOUT_STATS

      public static final StructType SCHEMA_WITHOUT_STATS
      Schema of the add action in the Delta Log without stats. Used for constructing table snapshot to read data from the table.
    • SCHEMA_WITH_STATS

      public static final StructType SCHEMA_WITH_STATS
    • FULL_SCHEMA

      public static final StructType FULL_SCHEMA
      Full schema of the add action in the Delta Log.
  • Constructor Details

    • AddFile

      public AddFile(Row row)
      Constructs an AddFile action from the given 'AddFile' Row.
  • Method Details

    • convertDataFileStatus

      public static AddFile convertDataFileStatus(StructType physicalSchema, URI tableRoot, DataFileStatus dataFileStatus, Map<String,Literal> partitionValues, boolean dataChange, Map<String,String> tags, Optional<Long> baseRowId, Optional<Long> defaultRowCommitVersion, Optional<DeletionVectorDescriptor> deletionVectorDescriptor)
      Utility to generate AddFile action instance from the given DataFileStatus and partition values.
    • createAddFileRow

      public static Row createAddFileRow(StructType physicalSchema, String path, MapValue partitionValues, long size, long modificationTime, boolean dataChange, Optional<DeletionVectorDescriptor> deletionVector, Optional<MapValue> tags, Optional<Long> baseRowId, Optional<Long> defaultRowCommitVersion, Optional<DataFileStatistics> stats)
      Utility to generate an 'AddFile' row from the given fields.
    • getPath

      public String getPath()
    • getPartitionValues

      public MapValue getPartitionValues()
    • getSize

      public long getSize()
    • getModificationTime

      public long getModificationTime()
    • getDataChange

      public boolean getDataChange()
    • getDeletionVector

      public Optional<DeletionVectorDescriptor> getDeletionVector()
    • getTags

      public Optional<MapValue> getTags()
    • getStatsJson

      public Optional<String> getStatsJson()
    • getBaseRowId

      public Optional<Long> getBaseRowId()
    • getDefaultRowCommitVersion

      public Optional<Long> getDefaultRowCommitVersion()
    • getNumRecords

      public Optional<Long> getNumRecords()
    • getStats

      public Optional<DataFileStatistics> getStats(StructType physicalSchema)
      Returns the file statistics parsed from the stats JSON string using the provided schema. This method deserializes the statistics JSON with full type information, ensuring that min/max values and null counts are correctly typed according to the physical schema.
      Parameters:
      physicalSchema - the physical schema of the table, used to correctly parse and type the statistics values (min/max values and null counts)
      Returns:
      an Optional containing the deserialized DataFileStatistics if the stats field is present and non-null, or Optional.empty() otherwise
      Throws:
      KernelException - if the stats JSON is malformed or if values don't match the expected types from the schema
      See Also:
    • withNewBaseRowId

      public AddFile withNewBaseRowId(long baseRowId)
      Returns a new AddFile with the provided baseRowId.
    • withNewDefaultRowCommitVersion

      public AddFile withNewDefaultRowCommitVersion(long defaultRowCommitVersion)
      Returns a new AddFile with the provided defaultRowCommitVersion.
    • toRemoveFileRow

      public Row toRemoveFileRow(boolean dataChange, Optional<Long> deletionTimestamp)
      Utility to generate a 'RemoveFile' action from this AddFile action.
      Parameters:
      dataChange - this will override the dataChange field in current AddFile
      deletionTimestamp - the deletion timestamp of the operation, this will override the modificationTime field in current AddFile
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object