@@ -23,32 +23,16 @@ import org.apache.spark.sql.QueryTest
2323import org .apache .spark .sql .execution .{BroadcastHashJoin , ShuffledHashJoin }
2424import org .apache .spark .sql .hive .test .TestHive
2525import org .apache .spark .sql .hive .test .TestHive ._
26- import org .apache .spark .sql .parquet .{ParquetRelation , ParquetTestData }
27- import org .apache .spark .util .Utils
2826
2927class StatisticsSuite extends QueryTest {
3028
31- test(" estimates the size of a test ParquetRelation" ) {
32- ParquetTestData .writeFile()
33- val testRDD = parquetFile(ParquetTestData .testDir.toString)
34-
35- val sizes = testRDD.logicalPlan.collect { case j : ParquetRelation =>
36- (j.statistics.sizeInBytes, j.newInstance.statistics.sizeInBytes)
37- }
38- assert(sizes.size === 1 )
39- assert(sizes(0 )._1 == sizes(0 )._2, " after .newInstance, estimates are different from before" )
40- assert(sizes(0 )._1 > 1 , " 1 is the default, indicating the absence of a meaningful estimate" )
41-
42- Utils .deleteRecursively(ParquetTestData .testDir)
43- }
44-
4529 test(" estimates the size of a test MetastoreRelation" ) {
4630 val rdd = hql(""" SELECT * FROM src""" )
4731 val sizes = rdd.queryExecution.analyzed.collect { case mr : MetastoreRelation =>
4832 mr.statistics.sizeInBytes
4933 }
5034 assert(sizes.size === 1 )
51- assert(sizes(0 ) > 1 , " 1 is the default, indicating the absence of a meaningful estimate " )
35+ assert(sizes(0 ) == 5812 , s " expected exact size 5812 for test table 'src', got ${sizes( 0 )} " )
5236 }
5337
5438 test(" auto converts to broadcast hash join, by size estimate of a relation" ) {
@@ -95,30 +79,6 @@ class StatisticsSuite extends QueryTest {
9579 after()
9680 }
9781
98- /** Tests for ParquetRelation */
99- val parquetQuery =
100- """ SELECT a.mystring, b.myint
101- |FROM psrc a
102- |JOIN psrc b
103- |ON a.mylong = 0 AND a.mylong = b.mylong""" .stripMargin
104- val parquetAnswer = Seq ((" abc" , 5 ))
105- def parquetBefore (): Unit = {
106- ParquetTestData .writeFile()
107- val testRDD = parquetFile(ParquetTestData .testDir.toString)
108- testRDD.registerAsTable(" psrc" )
109- }
110- def parquetAfter () = {
111- Utils .deleteRecursively(ParquetTestData .testDir)
112- reset()
113- }
114- mkTest(
115- parquetBefore,
116- parquetAfter,
117- parquetQuery,
118- parquetAnswer,
119- implicitly[ClassTag [ParquetRelation ]]
120- )
121-
12282 /** Tests for MetastoreRelation */
12383 val metastoreQuery = """ SELECT * FROM src a JOIN src b ON a.key = 238 AND a.key = b.key"""
12484 val metastoreAnswer = Seq .fill(4 )((238 , " val_238" , 238 , " val_238" ))
0 commit comments