Skip to content

AlterDeltaTableCommand

AlterDeltaTableCommand is an extension of the DeltaCommand abstraction for Delta commands that alter a DeltaTableV2.

Contract

table

table: DeltaTableV2

DeltaTableV2

Used when:

Implementations

startTransaction

startTransaction(): OptimisticTransaction

startTransaction simply requests the DeltaTableV2 for the DeltaLog that in turn is requested to startTransaction.

Checking Dependent Expressions

checkDependentExpressions(
  sparkSession: SparkSession,
  columnParts: Seq[String],
  newMetadata: actions.Metadata,
  protocol: Protocol,
  operationName: String): Unit

checkDependentExpressions skips execution when spark.databricks.delta.alterTable.changeColumn.checkExpressions configuration property is disabled (false).

checkDependentExpressions checks if the column to change (columnParts) is referenced by check constraints or generated columns (and throws an AnalysisException if there are any).


checkDependentExpressions is used when:

Check Constraints

checkDependentExpressions findDependentConstraints (with the givencolumnParts and the newMetadata) and throws an AnalysisException if there are any:

Cannot [operationName] column [columnName] because this column is referenced by the following check constraint(s):
    [constraints]

Generated Columns

checkDependentExpressions findDependentGeneratedColumns (with the givencolumnParts, the newMetadata and protocol) and throws an AnalysisException if there are any:

Cannot [operationName] column [columnName] because this column is referenced by the following generated column(s):
    [fieldNames]