@@ -2869,43 +2869,6 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
28692869 }
28702870 }
28712871 }
2872-
2873- test(" SPARK-26709: OptimizeMetadataOnlyQuery does not handle empty records correctly" ) {
2874- Seq (true , false ).foreach { enableOptimizeMetadataOnlyQuery =>
2875- withSQLConf(SQLConf .OPTIMIZER_METADATA_ONLY .key -> enableOptimizeMetadataOnlyQuery.toString) {
2876- withTable(" t" ) {
2877- sql(" CREATE TABLE t (col1 INT, p1 INT) USING PARQUET PARTITIONED BY (p1)" )
2878- sql(" INSERT INTO TABLE t PARTITION (p1 = 5) SELECT ID FROM range(1, 1)" )
2879- if (enableOptimizeMetadataOnlyQuery) {
2880- // The result is wrong if we enable the configuration.
2881- checkAnswer(sql(" SELECT MAX(p1) FROM t" ), Row (5 ))
2882- } else {
2883- checkAnswer(sql(" SELECT MAX(p1) FROM t" ), Row (null ))
2884- }
2885- checkAnswer(sql(" SELECT MAX(col1) FROM t" ), Row (null ))
2886- }
2887-
2888- withTempPath { path =>
2889- val tabLocation = path.getCanonicalPath
2890- val partLocation1 = tabLocation + " /p=3"
2891- val partLocation2 = tabLocation + " /p=1"
2892- // SPARK-23271 empty RDD when saved should write a metadata only file
2893- val df = spark.emptyDataFrame.select(lit(1 ).as(" col" ))
2894- df.write.parquet(partLocation1)
2895- val df2 = spark.range(10 ).toDF(" col" )
2896- df2.write.parquet(partLocation2)
2897- val readDF = spark.read.parquet(tabLocation)
2898- if (enableOptimizeMetadataOnlyQuery) {
2899- // The result is wrong if we enable the configuration.
2900- checkAnswer(readDF.selectExpr(" max(p)" ), Row (3 ))
2901- } else {
2902- checkAnswer(readDF.selectExpr(" max(p)" ), Row (1 ))
2903- }
2904- checkAnswer(readDF.selectExpr(" max(col)" ), Row (9 ))
2905- }
2906- }
2907- }
2908- }
29092872}
29102873
29112874case class Foo (bar : Option [String ])
0 commit comments