Skip to content

OptimizeTableCommand

OptimizeTableCommand is an OptimizeTableCommandBase for the following high-level operators:

OptimizeTableCommand uses OptimizeExecutor to optimize (when executed).

OptimizeTableCommand is a RunnableCommand (Spark SQL).

Creating Instance

OptimizeTableCommand takes the following to be created:

OptimizeTableCommand is created when:

  • DeltaOptimizeBuilder is requested to execute
  • DeltaReorgTableCommand is requested to optimizeByReorg
  • OptimizeTableCommand is requested to apply

Creating OptimizeTableCommand

apply(
  path: Option[String],
  tableIdentifier: Option[TableIdentifier],
  userPartitionPredicates: Seq[String],
  optimizeContext: DeltaOptimizeContext = DeltaOptimizeContext())(
  zOrderBy: Seq[UnresolvedAttribute]): OptimizeTableCommand

apply creates an OptimizeTableCommand for a delta table (based on the given path or tableIdentifier).


apply is used when:

Executing Command

RunnableCommand
run(
  sparkSession: SparkSession): Seq[Row]

run is part of the RunnableCommand (Spark SQL) abstraction.

run extracts the delta table from the child logical plan.

run starts a transaction (for this DeltaTableV2).

run...FIXME

run validates the zOrderBy columns (that may throw DeltaIllegalArgumentException or DeltaAnalysisException exceptions and so break the command execution).

In the end, run creates an OptimizeExecutor to run optimization (with the given userPartitionPredicates, the zOrderBy attributes).

Note

isAutoCompact flag is disabled (false).