Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/17015#discussion_r103387597
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/AnalyzeColumnCommand.scala
---
@@ -40,38 +38,24 @@ case class AnalyzeColumnCommand(
val sessionState = sparkSession.sessionState
val db =
tableIdent.database.getOrElse(sessionState.catalog.getCurrentDatabase)
val tableIdentWithDB = TableIdentifier(tableIdent.table, Some(db))
- val relation =
-
EliminateSubqueryAliases(sparkSession.table(tableIdentWithDB).queryExecution.analyzed)
-
- // Compute total size
- val (catalogTable: CatalogTable, sizeInBytes: Long) = relation match {
- case catalogRel: CatalogRelation =>
- // This is a Hive serde format table
- (catalogRel.catalogTable,
- AnalyzeTableCommand.calculateTotalSize(sessionState,
catalogRel.catalogTable))
-
- case logicalRel: LogicalRelation if
logicalRel.catalogTable.isDefined =>
- // This is a data source format table
- (logicalRel.catalogTable.get,
- AnalyzeTableCommand.calculateTotalSize(sessionState,
logicalRel.catalogTable.get))
-
- case otherRelation =>
- throw new AnalysisException("ANALYZE TABLE is not supported for " +
- s"${otherRelation.nodeName}.")
+ val tableMeta = sessionState.catalog.getTableMetadata(tableIdentWithDB)
+ if (tableMeta.tableType == CatalogTableType.VIEW) {
+ throw new AnalysisException("ANALYZE TABLE is not supported on
views.")
}
+ val sizeInBytes = AnalyzeTableCommand.calculateTotalSize(sessionState,
tableMeta)
// Compute stats for each column
val (rowCount, newColStats) =
- AnalyzeColumnCommand.computeColumnStats(sparkSession,
tableIdent.table, relation, columnNames)
+ AnalyzeColumnCommand.computeColumnStats(sparkSession,
tableIdentWithDB, columnNames)
--- End diff --
`object AnalyzeColumnCommand` is not needed. We can move
`computeColumnStats ` into the `case class AnalyzeColumnCommand`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]