Skip to content

OptimizeTableCommand

OptimizeTableCommand is a LeafRunnableCommand (Spark SQL) for the following high-level operators:

OptimizeTableCommand is an OptimizeTableCommandBase.

Creating Instance

OptimizeTableCommand takes the following to be created:

  • Table Path
  • TableIdentifier
  • Partition Predicate (optional)
  • zOrderBy attributes (aka interleaveBy attributes)

OptimizeTableCommand is created when:

Executing Command

run(
  sparkSession: SparkSession): Seq[Row]

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


run gets the DeltaLog of the Delta table (by the path or tableId).

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 that is in turn requested to optimize.