AnalyzePartitionCommand Logical Command¶
AnalyzePartitionCommand
is a LeafRunnableCommand that represents ANALYZE TABLE PARTITION COMPUTE STATISTICS (AnalyzeTable logical command with partition specification) at analysis.
AnalyzeTableCommand Logical Command
AnalyzeTable logical command without partition specification is resolved to AnalyzeTableCommand logical command.
Creating Instance¶
AnalyzePartitionCommand
takes the following to be created:
-
TableIdentifier
- Partition Spec (
Map[String, Option[String]]
) -
noscan
flag (default:true
) that indicates whether NOSCAN option was used or not
AnalyzePartitionCommand
is created when:
- ResolveSessionCatalog logical analysis rule is executed (to resolve an AnalyzeTable logical command)
Demo¶
// Seq((0, 0, "zero"), (1, 1, "one")).toDF("id", "p1", "p2").write.partitionBy("p1", "p2").saveAsTable("t1")
val analyzeTable = "ANALYZE TABLE t1 PARTITION (p1, p2) COMPUTE STATISTICS"
val plan = spark.sql(analyzeTable).queryExecution.logical
import org.apache.spark.sql.execution.command.AnalyzePartitionCommand
val cmd = plan.asInstanceOf[AnalyzePartitionCommand]
scala> println(cmd)
AnalyzePartitionCommand `t1`, Map(p1 -> None, p2 -> None), false