Skip to content

Commit ce702c7

Browse files
committed
move
1 parent 292e87f commit ce702c7

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ import org.scalatest.Matchers._
2828

2929
import org.apache.spark.SparkException
3030
import org.apache.spark.sql.catalyst.TableIdentifier
31-
import org.apache.spark.sql.catalyst.plans.logical.{Filter, LocalRelation, OneRowRelation, Union}
31+
import org.apache.spark.sql.catalyst.plans.logical.{Filter, OneRowRelation, Union}
3232
import org.apache.spark.sql.execution.{FilterExec, QueryExecution, WholeStageCodegenExec}
3333
import org.apache.spark.sql.execution.aggregate.HashAggregateExec
3434
import org.apache.spark.sql.execution.exchange.{BroadcastExchangeExec, ReusedExchangeExec, ShuffleExchangeExec}
3535
import org.apache.spark.sql.functions._
3636
import org.apache.spark.sql.internal.SQLConf
37-
import org.apache.spark.sql.internal.SQLConf.OPTIMIZER_METADATA_ONLY
3837
import org.apache.spark.sql.test.{ExamplePoint, ExamplePointUDT, SharedSQLContext}
3938
import org.apache.spark.sql.test.SQLTestData.TestData2
4039
import org.apache.spark.sql.types._
@@ -2253,25 +2252,6 @@ class DataFrameSuite extends QueryTest with SharedSQLContext {
22532252
assert(mean.collect().toSet === Set(Row("0.0345678900000000000000000000000000000")))
22542253
}
22552254

2256-
test("Incorrect result caused by the rule OptimizeMetadataOnlyQuery") {
2257-
withSQLConf(OPTIMIZER_METADATA_ONLY.key -> "true") {
2258-
withTempPath { path =>
2259-
val tablePath = new File(s"${path.getCanonicalPath}/cOl3=c/cOl1=a/cOl5=e")
2260-
Seq(("a", "b", "c", "d", "e")).toDF("cOl1", "cOl2", "cOl3", "cOl4", "cOl5")
2261-
.write.json(tablePath.getCanonicalPath)
2262-
2263-
val df = spark.read.json(path.getCanonicalPath).select("CoL1", "CoL5", "CoL3").distinct()
2264-
checkAnswer(df, Row("a", "e", "c"))
2265-
2266-
val localRelation = df.queryExecution.optimizedPlan.collectFirst {
2267-
case l: LocalRelation => l
2268-
}
2269-
assert(localRelation.nonEmpty, "expect to see a LocalRelation")
2270-
assert(localRelation.get.output.map(_.name) == Seq("cOl3", "cOl1", "cOl5"))
2271-
}
2272-
}
2273-
}
2274-
22752255
test("SPARK-22520: support code generation for large CaseWhen") {
22762256
val N = 30
22772257
var expr1 = when($"id" === lit(0), 0)

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
package org.apache.spark.sql.execution
1919

20+
import java.io.File
21+
2022
import org.apache.spark.sql._
2123
import org.apache.spark.sql.catalyst.plans.logical.LocalRelation
2224
import org.apache.spark.sql.internal.SQLConf
25+
import org.apache.spark.sql.internal.SQLConf.OPTIMIZER_METADATA_ONLY
2326
import org.apache.spark.sql.test.SharedSQLContext
2427

2528
class OptimizeMetadataOnlyQuerySuite extends QueryTest with SharedSQLContext {
@@ -125,4 +128,23 @@ class OptimizeMetadataOnlyQuerySuite extends QueryTest with SharedSQLContext {
125128
sql("SELECT COUNT(DISTINCT p) FROM t_1000").collect()
126129
}
127130
}
131+
132+
test("Incorrect result caused by the rule OptimizeMetadataOnlyQuery") {
133+
withSQLConf(OPTIMIZER_METADATA_ONLY.key -> "true") {
134+
withTempPath { path =>
135+
val tablePath = new File(s"${path.getCanonicalPath}/cOl3=c/cOl1=a/cOl5=e")
136+
Seq(("a", "b", "c", "d", "e")).toDF("cOl1", "cOl2", "cOl3", "cOl4", "cOl5")
137+
.write.json(tablePath.getCanonicalPath)
138+
139+
val df = spark.read.json(path.getCanonicalPath).select("CoL1", "CoL5", "CoL3").distinct()
140+
checkAnswer(df, Row("a", "e", "c"))
141+
142+
val localRelation = df.queryExecution.optimizedPlan.collectFirst {
143+
case l: LocalRelation => l
144+
}
145+
assert(localRelation.nonEmpty, "expect to see a LocalRelation")
146+
assert(localRelation.get.output.map(_.name) == Seq("cOl3", "cOl1", "cOl5"))
147+
}
148+
}
149+
}
128150
}

0 commit comments

Comments
 (0)