Skip to content

Commit c848508

Browse files
committed
change ut
1 parent 86f28d5 commit c848508

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

sql/core/src/test/scala/org/apache/spark/sql/execution/OptimizeMetadataOnlyQuerySuite.scala

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,27 @@ class OptimizeMetadataOnlyQuerySuite extends QueryTest with SharedSparkSession {
152152
}
153153

154154
test("SPARK-31590 The filter used by Metadata-only queries should not have Unevaluable") {
155-
withTable("test_tbl") {
156-
withSQLConf(OPTIMIZER_METADATA_ONLY.key -> "true") {
157-
sql("CREATE TABLE test_tbl (a INT,d STRING,h STRING) USING PARQUET PARTITIONED BY (d ,h)")
158-
sql("""
159-
|INSERT OVERWRITE TABLE test_tbl PARTITION(d,h)
160-
|SELECT 1,'2020-01-01','23'
161-
|UNION ALL
162-
|SELECT 2,'2020-01-02','01'
163-
|UNION ALL
164-
|SELECT 3,'2020-01-02','02'
165-
""".stripMargin)
166-
sql(
167-
s"""
168-
|SELECT d, MAX(h) AS h
169-
|FROM test_tbl
170-
|WHERE d= (
171-
| SELECT MAX(d) AS d
172-
| FROM test_tbl
173-
|)
174-
|GROUP BY d
175-
""".stripMargin).collect()
155+
Seq(true, false).foreach { enableOptimizeMetadataOnlyQuery =>
156+
withSQLConf(OPTIMIZER_METADATA_ONLY.key -> enableOptimizeMetadataOnlyQuery.toString) {
157+
val df = sql(
158+
"""
159+
|SELECT partcol1, MAX(partcol2) AS partcol2
160+
|FROM srcpart
161+
|WHERE partcol1 = (
162+
| SELECT MAX(partcol1)
163+
| FROM srcpart
164+
|)
165+
|GROUP BY partcol1
166+
""".stripMargin)
167+
val localRelations = df.queryExecution.optimizedPlan.collect {
168+
case l@LocalRelation(_, _, _) => l
169+
}
170+
if (enableOptimizeMetadataOnlyQuery) {
171+
assert(localRelations.size == 1)
172+
} else {
173+
assert(localRelations.size == 0)
174+
}
175+
df.collect()
176176
}
177177
}
178178
}

0 commit comments

Comments
 (0)