Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchao committed Nov 9, 2023
1 parent e623a33 commit 9e2d874
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ class StatisticsSuite extends StatisticsCollectionTestBase with TestHiveSingleto
}

val partitionDates = List("2010-01-01", "2010-01-02", "2010-01-03")
val expectedRowCount = 500

Seq(true, false).foreach { partitionStatsEnabled =>
withSQLConf(SQLConf.UPDATE_PART_STATS_IN_ANALYZE_TABLE_ENABLED.key ->
Expand All @@ -382,16 +383,16 @@ class StatisticsSuite extends StatisticsCollectionTestBase with TestHiveSingleto
// Create a table with 3 partitions all located under a directory 'path'
sql(
s"""
|CREATE TABLE $tableName (key STRING, value STRING)
|USING hive
|CREATE TABLE $tableName (key INT, value STRING)
|USING parquet
|PARTITIONED BY (ds STRING)
|LOCATION '${path.toURI}'
""".stripMargin)

partitionDates.foreach { ds =>
sql(s"ALTER TABLE $tableName ADD PARTITION (ds='$ds') LOCATION '$path/ds=$ds'")
sql("SELECT * FROM src").write.mode(SaveMode.Overwrite)
.format("parquet").save(s"$path/ds=$ds")
.format("parquet").save(s"$path/ds=$ds")
}

assert(getCatalogTable(tableName).stats.isEmpty)
Expand Down Expand Up @@ -421,15 +422,15 @@ class StatisticsSuite extends StatisticsCollectionTestBase with TestHiveSingleto

assert(getTableStats(tableName).sizeInBytes > 0)
// Table row count should be updated
assert(getTableStats(tableName).rowCount.get > 0)
assert(getTableStats(tableName).rowCount.get == 3 * expectedRowCount)

partitionDates.foreach { ds =>
val partStats = queryStats(ds)
if (partitionStatsEnabled) {
assert(partStats.nonEmpty)
// The scan option should update partition row count
assert(partStats.get.sizeInBytes > 0)
assert(partStats.get.rowCount.get > 0)
assert(partStats.get.rowCount.get == expectedRowCount)
} else {
assert(partStats.isEmpty)
}
Expand Down

0 comments on commit 9e2d874

Please sign in to comment.