wangyum commented on a change in pull request #34291:
URL: https://github.com/apache/spark/pull/34291#discussion_r732412083
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
##########
@@ -92,6 +93,34 @@ class JDBCV2Suite extends QueryTest with SharedSparkSession
with ExplainSuiteHel
checkAnswer(sql("SELECT name, id FROM h2.test.people"), Seq(Row("fred",
1), Row("mary", 2)))
}
+ test("simple scan with LIMIT") {
+ val df1 = spark.read.table("h2.test.employee").limit(4)
+ checkLimitResult(df1)
+
+ val df2 = spark.read
+ .option("partitionColumn", "dept")
+ .option("lowerBound", "1")
+ .option("upperBound", "2")
+ .option("numPartitions", "2")
+ .table("h2.test.employee")
+ .limit(4)
+ checkLimitResult(df2)
+ }
+
+ private def checkLimitResult(df: DataFrame): Unit = {
+ df.queryExecution.optimizedPlan.collect {
+ case _: DataSourceV2ScanRelation =>
+ val expected_plan_fragment =
+ "PushedLimit: TRUE"
+ checkKeywordsExistsInExplain(df, expected_plan_fragment)
+ }
+
+ checkAnswer(df, Seq(Row(1, "amy", 10000.00, 1000.0),
+ Row(2, "alex", 12000.00, 1200.0),
+ Row(1, "cathy", 9000.00, 1200.0),
+ Row(2, "david", 10000.00, 1300.0)))
+ }
+
Review comment:
Could we add more test cases. For example, the case that cannot be
pushed down:
```scala
val df2 = spark.read
.option("partitionColumn", "dept")
.option("lowerBound", "1")
.option("upperBound", "2")
.option("numPartitions", "2")
.table("h2.test.employee").groupBy("DEPT").sum("SALARY")
.limit(1)
```
--
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]