Package io.delta.kernel
Interface Table
Represents the Delta Lake table for a given path.
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkpoint
(Engine engine, long version) Checkpoint the table at given version.void
Computes and writes a checksum file for the table at given version.createTransactionBuilder
(Engine engine, String engineInfo, Operation operation) Create aTransactionBuilder
which can create aTransaction
object to mutate the table.static Table
Instantiate a table object for the Delta Lake table at the given path.getLatestSnapshot
(Engine engine) Get the latest snapshot of the table.The fully qualified path of thisTable
instance.getSnapshotAsOfTimestamp
(Engine engine, long millisSinceEpochUTC) Get the snapshot of the table at the giventimestamp
.getSnapshotAsOfVersion
(Engine engine, long versionId) Get the snapshot at the givenversionId
.
-
Method Details
-
forPath
Instantiate a table object for the Delta Lake table at the given path.- Behavior when the table location doesn't exist:
- Reads will fail with a
TableNotFoundException
- Writes will create the location
- Reads will fail with a
- Behavior when the table location exists (with contents or not) but not a Delta table:
- Reads will fail with a
TableNotFoundException
- Writes will create a Delta table at the given location. If there are any existing files in the location that are not already part of the Delta table, they will remain excluded from the Delta table.
- Reads will fail with a
- Behavior when the table location doesn't exist:
-
getPath
The fully qualified path of thisTable
instance.- Parameters:
engine
-Engine
instance.- Returns:
- the table path.
- Since:
- 3.2.0
-
getLatestSnapshot
Get the latest snapshot of the table.- Parameters:
engine
-Engine
instance to use in Delta Kernel.- Returns:
- an instance of
Snapshot
- Throws:
TableNotFoundException
- if the table is not found
-
getSnapshotAsOfVersion
Get the snapshot at the givenversionId
.- Parameters:
engine
-Engine
instance to use in Delta Kernel.versionId
- snapshot version to retrieve- Returns:
- an instance of
Snapshot
- Throws:
TableNotFoundException
- if the table is not foundKernelException
- if the provided version is less than the first available version or greater than the last available version- Since:
- 3.2.0
-
getSnapshotAsOfTimestamp
Snapshot getSnapshotAsOfTimestamp(Engine engine, long millisSinceEpochUTC) throws TableNotFoundException Get the snapshot of the table at the giventimestamp
. This is the latest version of the table that was committed before or attimestamp
.Specifically:
- If a commit version exactly matches the provided timestamp, we return the table snapshot at that version.
- Else, we return the latest commit version with a timestamp less than the provided one.
- If the provided timestamp is less than the timestamp of any committed version, we throw an error.
- If the provided timestamp is after (strictly greater than) the timestamp of the latest version of the table, we throw an error
- Parameters:
engine
-Engine
instance to use in Delta Kernel.millisSinceEpochUTC
- timestamp to fetch the snapshot for in milliseconds since the unix epoch- Returns:
- an instance of
Snapshot
- Throws:
TableNotFoundException
- if the table is not foundKernelException
- if the provided timestamp is before the earliest available version or after the latest available version- Since:
- 3.2.0
-
createTransactionBuilder
Create aTransactionBuilder
which can create aTransaction
object to mutate the table.- Parameters:
engine
-Engine
instance to use.engineInfo
- information about the engine that is making the updates.operation
- metadata of operation that is being performed. E.g. "insert", "delete".- Returns:
TransactionBuilder
instance to build the transaction.- Since:
- 3.2.0
-
checkpoint
void checkpoint(Engine engine, long version) throws TableNotFoundException, CheckpointAlreadyExistsException, IOException Checkpoint the table at given version. It writes a single checkpoint file.- Parameters:
engine
-Engine
instance to use.version
- Version to checkpoint.- Throws:
TableNotFoundException
- if the table is not foundCheckpointAlreadyExistsException
- if a checkpoint already exists at the given versionIOException
- for any I/O error.- Since:
- 3.2.0
-
checksum
Computes and writes a checksum file for the table at given version. If a checksum file already exists, this method does nothing.Note: For very large tables, this operation may be expensive as it requires scanning the log to compute table statistics.
- Parameters:
engine
-Engine
instance to use.version
- Version to generate checksum file for.- Throws:
TableNotFoundException
- if the table is not foundIOException
- for any I/O error.- Since:
- 4.0.0
-