Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maropu committed Mar 26, 2019
1 parent b51b9a8 commit b4bbdad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ case class AnalyzeTableCommand(
val table = sparkSession.table(tableIdent.quotedString)
val cacheManager = sparkSession.sharedState.cacheManager
if (cacheManager.lookupCachedData(table.logicalPlan).isDefined) {
// To collect table stats, materializes an underlying columnar RDD
table.collect()
if (!noscan) {
// To collect table stats, materializes an underlying columnar RDD
table.collect()
}
} else {
throw new AnalysisException("ANALYZE TABLE is not supported on views.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,16 @@ class StatisticsCollectionSuite extends StatisticsCollectionTestBase with Shared
val stats2 = getTableStats(s"$database.v")
assert(stats2.sizeInBytes === OneRowRelation().computeStats().sizeInBytes)
assert(stats2.rowCount === None)
sql(s"ANALYZE TABLE $database.v COMPUTE STATISTICS")

sql(s"ANALYZE TABLE $database.v COMPUTE STATISTICS NOSCAN")
val stats3 = getTableStats(s"$database.v")
assert(stats3.sizeInBytes === stats1.sizeInBytes)
assert(stats3.rowCount === Some(1))
assert(stats3.sizeInBytes === OneRowRelation().computeStats().sizeInBytes)
assert(stats3.rowCount === None)

sql(s"ANALYZE TABLE $database.v COMPUTE STATISTICS")
val stats4 = getTableStats(s"$database.v")
assert(stats4.sizeInBytes === stats1.sizeInBytes)
assert(stats4.rowCount === Some(1))
}
}
}

0 comments on commit b4bbdad

Please sign in to comment.