cloud-fan commented on a change in pull request #34738:
URL: https://github.com/apache/spark/pull/34738#discussion_r769248348
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
##########
@@ -194,39 +196,49 @@ class JDBCV2Suite extends QueryTest with
SharedSparkSession with ExplainSuiteHel
val scan = df4.queryExecution.optimizedPlan.collectFirst {
case s: DataSourceV2ScanRelation => s
}.get
- assert(scan.schema.names.sameElements(Seq("NAME", "SALARY")))
+ assert(scan.schema.names.sameElements(Seq("NAME")))
+ checkSortRemoved(df4)
checkPushedLimit(df4, Some(1), createSortValues(nullOrdering =
NullOrdering.NULLS_LAST))
checkAnswer(df4, Seq(Row("david")))
val df5 = spark.read.table("h2.test.employee")
.where($"dept" === 1).orderBy($"salary")
- checkPushedLimit(df5, None, Seq.empty)
+ checkSortRemoved(df5, false)
+ checkPushedLimit(df5, None)
checkAnswer(df5, Seq(Row(1, "cathy", 9000.00, 1200.0), Row(1, "amy",
10000.00, 1000.0)))
- val df6 = spark.read.table("h2.test.employee")
- .where($"dept" === 1).limit(1)
- checkPushedLimit(df6, Some(1), Seq.empty)
- checkAnswer(df6, Seq(Row(1, "amy", 10000.00, 1000.0)))
-
- val df7 = spark.read
+ val df6 = spark.read
.table("h2.test.employee")
.groupBy("DEPT").sum("SALARY")
.orderBy("DEPT")
.limit(1)
- checkPushedLimit(df7)
- checkAnswer(df7, Seq(Row(1, 19000.00)))
+ checkSortRemoved(df6, false)
+ checkPushedLimit(df6)
+ checkAnswer(df6, Seq(Row(1, 19000.00)))
val name = udf { (x: String) => x.matches("cat|dav|amy") }
val sub = udf { (x: String) => x.substring(0, 3) }
- val df8 = spark.read
+ val df7 = spark.read
.table("h2.test.employee")
.select($"SALARY", $"BONUS", sub($"NAME").as("shortName"))
.filter(name($"shortName"))
.sort($"SALARY".desc)
.limit(1)
+ checkSortRemoved(df7, false)
// LIMIT is pushed down only if all the filters are pushed down
- checkPushedLimit(df8)
- checkAnswer(df8, Seq(Row(10000.00, 1000.0, "amy")))
+ checkPushedLimit(df7)
+ checkAnswer(df7, Seq(Row(10000.00, 1000.0, "amy")))
+ }
+
+ private def checkSortRemoved(df: DataFrame, removed: Boolean = true): Unit =
{
Review comment:
Can we do this in `checkPushedLimit`? If `sortValues` is nonEmpty, we
check if the sort has been removed from the query plan.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]