Package io.delta.kernel.internal
Class TransactionImpl
Object
io.delta.kernel.internal.TransactionImpl
- All Implemented Interfaces:
Transaction
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionTransactionImpl(boolean isCreateOrReplace, Path dataPath, Optional<SnapshotImpl> readSnapshotOpt, String engineInfo, Operation operation, Optional<Protocol> newProtocol, Optional<Metadata> newMetadata, Committer committer, Optional<SetTransaction> setTxnOpt, Optional<List<Column>> newClusteringColumnsOpt, Optional<Integer> maxRetriesOpt, int logCompactionInterval, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDomainMetadata(String domain, String config) Commit the provided domain metadata as part of this transaction.voidaddDomainMetadataInternal(String domain, String config) commit(Engine engine, CloseableIterable<Row> dataActions) Commit the transaction including the data action rows generated byTransaction.generateAppendActions(io.delta.kernel.engine.Engine, io.delta.kernel.data.Row, io.delta.kernel.utils.CloseableIterator<io.delta.kernel.utils.DataFileStatus>, io.delta.kernel.DataWriteContext).getPartitionColumns(Engine engine) Get the list of logical names of the partition columns.longGets the latest version of the table used as the base of this transaction.Get the schema of the table.getStatisticsColumns(Row transactionState) Get the part of the schema of the table that needs the statistics to be collected per file.getTransactionState(Engine engine) Get the state of the transaction.voidremoveDomainMetadata(String domain) Mark the domain metadata with identifierdomainas removed in this transaction.voidremoveDomainMetadataInternal(String domain) voidwithCommitterProperties(Supplier<Map<String, String>> committerProperties) Adds custom properties that will be passed through to the committer.
-
Field Details
-
DEFAULT_READ_VERSION
public static final int DEFAULT_READ_VERSION- See Also:
-
DEFAULT_WRITE_VERSION
public static final int DEFAULT_WRITE_VERSION- See Also:
-
-
Constructor Details
-
TransactionImpl
public TransactionImpl(boolean isCreateOrReplace, Path dataPath, Optional<SnapshotImpl> readSnapshotOpt, String engineInfo, Operation operation, Optional<Protocol> newProtocol, Optional<Metadata> newMetadata, Committer committer, Optional<SetTransaction> setTxnOpt, Optional<List<Column>> newClusteringColumnsOpt, Optional<Integer> maxRetriesOpt, int logCompactionInterval, Clock clock)
-
-
Method Details
-
getStatisticsColumns
Get the part of the schema of the table that needs the statistics to be collected per file. -
getTransactionState
Description copied from interface:TransactionGet the state of the transaction. The state helps Kernel do the transformations to logical data according to the Delta protocol and table features enabled on the table. The engine should use this at the data writer task to transform the logical data that the engine wants to write to the table in to physical data that goes in data files usingTransaction.transformLogicalData(Engine, Row, CloseableIterator, Map)- Specified by:
getTransactionStatein interfaceTransaction
-
getCommitter
- Specified by:
getCommitterin interfaceTransaction- Returns:
- a committer that owns and controls commits to this table
-
getPartitionColumns
Description copied from interface:TransactionGet the list of logical names of the partition columns. This helps the connector to do physical partitioning of the data before asking the Kernel to stage the data per partition.- Specified by:
getPartitionColumnsin interfaceTransaction
-
getSchema
Description copied from interface:TransactionGet the schema of the table. If the connector is adding any data to the table through this transaction, it should have the same schema as the table schema.- Specified by:
getSchemain interfaceTransaction
-
getReadTableVersion
public long getReadTableVersion()Description copied from interface:TransactionGets the latest version of the table used as the base of this transaction. This returns -1 when the table is being created in this transaction.- Specified by:
getReadTableVersionin interfaceTransaction- Returns:
- The version of the table as of the beginning of this Transaction
-
withCommitterProperties
Description copied from interface:TransactionAdds custom properties that will be passed through to the committer. These properties allow connectors to inject catalog-specific metadata without Kernel inspection. Repeated calls to this method will overwrite any previously set properties.- Specified by:
withCommitterPropertiesin interfaceTransaction
-
addDomainMetadata
Description copied from interface:TransactionCommit the provided domain metadata as part of this transaction. If this is called more than once with the samedomainthe latest providedconfigwill be committed in the transaction. Only user-controlled domains are allowed (aka. domains with a `delta.` prefix are not allowed). Adding and removing a domain with the same identifier in the same txn is not allowed. Adding domain metadata to a table that does not support the table feature is not allowed. To enable the table feature, make sure to callTransactionBuilder.withDomainMetadataSupported()- Specified by:
addDomainMetadatain interfaceTransaction- Parameters:
domain- the domain identifierconfig- configuration string for this domain
-
removeDomainMetadata
Description copied from interface:TransactionMark the domain metadata with identifierdomainas removed in this transaction. If this domain does not exist in the latest version of the table, callingTransaction.commit(Engine, CloseableIterable)will throw aDomainDoesNotExistException. Adding and removing a domain with the same identifier in one txn is not allowed.- Specified by:
removeDomainMetadatain interfaceTransaction- Parameters:
domain- the domain identifier for the domain to remove
-
commit
public TransactionCommitResult commit(Engine engine, CloseableIterable<Row> dataActions) throws ConcurrentWriteException Description copied from interface:TransactionCommit the transaction including the data action rows generated byTransaction.generateAppendActions(io.delta.kernel.engine.Engine, io.delta.kernel.data.Row, io.delta.kernel.utils.CloseableIterator<io.delta.kernel.utils.DataFileStatus>, io.delta.kernel.DataWriteContext).- Specified by:
commitin interfaceTransaction- Parameters:
engine-Engineinstance.dataActions- Iterable of data actions to commit. These data actions are generated by theTransaction.generateAppendActions(Engine, Row, CloseableIterator, DataWriteContext). TheCloseableIterableallows the Kernel to access the list of actions multiple times (in case of retries to resolve the conflicts due to other writers to the table). Kernel provides a in-memory based implementation ofCloseableIterablewith utility APICloseableIterable.inMemoryIterable(CloseableIterator)- Returns:
TransactionCommitResultstatus of the successful transaction.- Throws:
ConcurrentWriteException- when the transaction has encountered a non-retryable conflicts or exceeded the maximum number of retries reached. The connector needs to rerun the query on top of the latest table state and retry the transaction.
-
addDomainMetadataInternal
-
removeDomainMetadataInternal
-
getDataPath
-
getLogPath
-
getProtocol
-
getSetTxnOpt
-
getEffectiveClusteringColumns
-