Class SnapshotQueryContext

Object
io.delta.kernel.internal.metrics.SnapshotQueryContext

public class SnapshotQueryContext extends Object
Stores the context for a given Snapshot query. This includes information about the query parameters (i.e. table path, time travel parameters), updated state as the snapshot query progresses (i.e. resolved version), and metrics.

This is used to generate a SnapshotReport. It exists from snapshot query initiation until either successful snapshot construction or failure.

  • Method Details

    • forLatestSnapshot

      public static SnapshotQueryContext forLatestSnapshot(String tablePath)
      Creates a SnapshotQueryContext for a Snapshot created by a latest snapshot query
    • forVersionSnapshot

      public static SnapshotQueryContext forVersionSnapshot(String tablePath, long version)
      Creates a SnapshotQueryContext for a Snapshot created by a AS OF VERSION query
    • forTimestampSnapshot

      public static SnapshotQueryContext forTimestampSnapshot(String tablePath, long timestamp)
      Creates a SnapshotQueryContext for a Snapshot created by a AS OF TIMESTAMP query
    • getTablePath

      public String getTablePath()
    • getResolvedVersion

      public Optional<Long> getResolvedVersion()
    • getCheckpointVersion

      public Optional<Long> getCheckpointVersion()
    • getProvidedTimestamp

      public Optional<Long> getProvidedTimestamp()
    • isLatestQuery

      public boolean isLatestQuery()
      Returns true if this snapshot was requested as the latest snapshot (i.e., no time-travel parameters were provided). Note that this is intent-based - it indicates what the user requested, not whether the snapshot is actually the latest version.
    • getSnapshotMetrics

      public SnapshotMetrics getSnapshotMetrics()
    • getQueryDisplayStr

      public String getQueryDisplayStr()
    • setResolvedVersion

      public void setResolvedVersion(long resolvedVersion)
      Set the resolved version that was actually loaded for this snapshot query.

      For AS OF TIMESTAMP queries, this should be set upon timestamp-to-version resolution.

      For AS OF LATEST queries, this should be set after log segment construction, when we learn what the latest version of the table really is.

    • setCheckpointVersion

      public void setCheckpointVersion(Optional<Long> checkpointVersion)
      Updates the checkpointVersion stored in this snapshot context.
    • recordSnapshotErrorReport

      public void recordSnapshotErrorReport(Engine engine, Exception e)
      Creates a SnapshotReport and pushes it to any MetricsReporters.
    • toString

      public String toString()
      Overrides:
      toString in class Object