Interface RowDelta

  • All Superinterfaces:
    PendingUpdate<Snapshot>, SnapshotUpdate<RowDelta>

    public interface RowDelta
    extends SnapshotUpdate<RowDelta>
    API for encoding row-level changes to a table.

    This API accumulates data and delete file changes, produces a new Snapshot of the table, and commits that snapshot as the current.

    When committing, these changes will be applied to the latest table snapshot. Commit conflicts will be resolved by applying the changes to the new latest snapshot and reattempting the commit.

    • Method Detail

      • addRows

        RowDelta addRows​(DataFile inserts)
        Add a DataFile to the table.
        Parameters:
        inserts - a data file of rows to insert
        Returns:
        this for method chaining
      • addDeletes

        RowDelta addDeletes​(DeleteFile deletes)
        Add a DeleteFile to the table.
        Parameters:
        deletes - a delete file of rows to delete
        Returns:
        this for method chaining
      • validateFromSnapshot

        RowDelta validateFromSnapshot​(long snapshotId)
        Set the snapshot ID used in any reads for this operation.

        Validations will check changes after this snapshot ID. If the from snapshot is not set, all ancestor snapshots through the table's initial snapshot are validated.

        Parameters:
        snapshotId - a snapshot ID
        Returns:
        this for method chaining
      • caseSensitive

        RowDelta caseSensitive​(boolean caseSensitive)
        Enables or disables case sensitive expression binding for validations that accept expressions.
        Parameters:
        caseSensitive - whether expression binding should be case sensitive
        Returns:
        this for method chaining
      • validateDataFilesExist

        RowDelta validateDataFilesExist​(java.lang.Iterable<? extends java.lang.CharSequence> referencedFiles)
        Add data file paths that must not be removed by conflicting commits for this RowDelta to succeed.

        If any path has been removed by a conflicting commit in the table since the snapshot passed to validateFromSnapshot(long), the operation will fail with a ValidationException.

        By default, this validation checks only rewrite and overwrite commits. To apply validation to delete commits, call validateDeletedFiles().

        Parameters:
        referencedFiles - file paths that are referenced by a position delete file
        Returns:
        this for method chaining
      • validateDeletedFiles

        RowDelta validateDeletedFiles()
        Enable validation that referenced data files passed to validateDataFilesExist(Iterable) have not been removed by a delete operation.

        If a data file has a row deleted using a position delete file, rewriting or overwriting the data file concurrently would un-delete the row. Deleting the data file is normally allowed, but a delete may be part of a transaction that reads and re-appends a row. This method is used to validate deletes for the transaction case.

        Returns:
        this for method chaining
      • validateNoConflictingAppends

        @Deprecated
        default RowDelta validateNoConflictingAppends​(Expression conflictDetectionFilter)
        Deprecated.
        since 0.13.0, will be removed in 0.14.0; use conflictDetectionFilter(Expression) and validateNoConflictingDataFiles() instead.
        Enables validation that data files added concurrently do not conflict with this commit's operation.

        This method should be called when the table is queried to determine which files to delete/append. If a concurrent operation commits a new file after the data was read and that file might contain rows matching the specified conflict detection filter, the overwrite operation will detect this during retries and fail.

        Calling this method with a correct conflict detection filter is required to maintain serializable isolation for update/delete operations. Otherwise, the isolation level will be snapshot isolation.

        Validation applies to files added to the table since the snapshot passed to validateFromSnapshot(long).

        Parameters:
        conflictDetectionFilter - an expression on rows in the table
        Returns:
        this for method chaining
      • conflictDetectionFilter

        RowDelta conflictDetectionFilter​(Expression conflictDetectionFilter)
        Sets a conflict detection filter used to validate concurrently added data and delete files.

        If not called, a true literal will be used as the conflict detection filter.

        Parameters:
        conflictDetectionFilter - an expression on rows in the table
        Returns:
        this for method chaining
      • validateNoConflictingDataFiles

        RowDelta validateNoConflictingDataFiles()
        Enables validation that data files added concurrently do not conflict with this commit's operation.

        This method should be called when the table is queried to determine which files to delete/append. If a concurrent operation commits a new file after the data was read and that file might contain rows matching the specified conflict detection filter, this operation will detect this during retries and fail.

        Calling this method is required to maintain serializable isolation for update/delete operations. Otherwise, the isolation level will be snapshot isolation.

        Validation uses the conflict detection filter passed to conflictDetectionFilter(Expression) and applies to operations that happened after the snapshot passed to validateFromSnapshot(long).

        Returns:
        this for method chaining
      • validateNoConflictingDeleteFiles

        RowDelta validateNoConflictingDeleteFiles()
        Enables validation that delete files added concurrently do not conflict with this commit's operation.

        This method must be called when the table is queried to produce a row delta for UPDATE and MERGE operations independently of the isolation level. Calling this method isn't required for DELETE operations as it is OK to delete a record that is also deleted concurrently.

        Validation uses the conflict detection filter passed to conflictDetectionFilter(Expression) and applies to operations that happened after the snapshot passed to validateFromSnapshot(long).

        Returns:
        this for method chaining