You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2021/08/07 02:20:39 UTC
[incubator-sedona] branch master updated: Extend UnaryExecNode
instead of Exchange to fix AQE execution (#534)
This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-sedona.git
The following commit(s) were added to refs/heads/master by this push:
new 057c375 Extend UnaryExecNode instead of Exchange to fix AQE execution (#534)
057c375 is described below
commit 057c375f00791ea307f71557af0afefc15403f6f
Author: Adam Binford <ad...@gmail.com>
AuthorDate: Fri Aug 6 22:20:32 2021 -0400
Extend UnaryExecNode instead of Exchange to fix AQE execution (#534)
---
.../strategy/join/SpatialIndexExec.scala | 5 ++--
.../sedona/sql/BroadcastIndexJoinSuite.scala | 27 ++++++++++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/sql/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/SpatialIndexExec.scala b/sql/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/SpatialIndexExec.scala
index c76ccfc..0ae2ce0 100644
--- a/sql/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/SpatialIndexExec.scala
+++ b/sql/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/SpatialIndexExec.scala
@@ -26,8 +26,7 @@ import org.apache.spark.internal.Logging
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.{Attribute, BindReferences, Expression, UnsafeRow}
-import org.apache.spark.sql.execution.SparkPlan
-import org.apache.spark.sql.execution.exchange.Exchange
+import org.apache.spark.sql.execution.{SparkPlan, UnaryExecNode}
@@ -35,7 +34,7 @@ case class SpatialIndexExec(child: SparkPlan,
shape: Expression,
indexType: IndexType,
radius: Option[Expression] = None)
- extends Exchange
+ extends UnaryExecNode
with TraitJoinQueryBase
with Logging {
diff --git a/sql/src/test/scala/org/apache/sedona/sql/BroadcastIndexJoinSuite.scala b/sql/src/test/scala/org/apache/sedona/sql/BroadcastIndexJoinSuite.scala
index 1689332..8395063 100644
--- a/sql/src/test/scala/org/apache/sedona/sql/BroadcastIndexJoinSuite.scala
+++ b/sql/src/test/scala/org/apache/sedona/sql/BroadcastIndexJoinSuite.scala
@@ -202,5 +202,32 @@ class BroadcastIndexJoinSuite extends TestBaseScala {
assert(distanceJoinDf.queryExecution.sparkPlan.collect{ case p: BroadcastIndexJoinExec => p }.size === 1)
assert(distanceJoinDf.count() == 2998)
}
+
+ it("Passed Correct partitioning for broadcast join for ST_Polygon and ST_Point with AQE enabled") {
+ sparkSession.conf.set("spark.sql.adaptive.enabled", true)
+ val polygonDf = buildPolygonDf.repartition(3)
+ val pointDf = buildPointDf.repartition(5)
+
+ var broadcastJoinDf = pointDf.alias("pointDf").join(broadcast(polygonDf).alias("polygonDf"), expr("ST_Contains(polygonDf.polygonshape, pointDf.pointshape)"))
+ assert(broadcastJoinDf.queryExecution.sparkPlan.collect{ case p: BroadcastIndexJoinExec => p }.size === 1)
+ assert(broadcastJoinDf.rdd.getNumPartitions == pointDf.rdd.getNumPartitions)
+ assert(broadcastJoinDf.count() == 1000)
+
+ broadcastJoinDf = broadcast(polygonDf).alias("polygonDf").join(pointDf.alias("pointDf"), expr("ST_Contains(polygonDf.polygonshape, pointDf.pointshape)"))
+ assert(broadcastJoinDf.queryExecution.sparkPlan.collect{ case p: BroadcastIndexJoinExec => p }.size === 1)
+ assert(broadcastJoinDf.rdd.getNumPartitions == pointDf.rdd.getNumPartitions)
+ assert(broadcastJoinDf.count() == 1000)
+
+ broadcastJoinDf = broadcast(pointDf).alias("pointDf").join(polygonDf.alias("polygonDf"), expr("ST_Contains(polygonDf.polygonshape, pointDf.pointshape)"))
+ assert(broadcastJoinDf.queryExecution.sparkPlan.collect{ case p: BroadcastIndexJoinExec => p }.size === 1)
+ assert(broadcastJoinDf.rdd.getNumPartitions == polygonDf.rdd.getNumPartitions)
+ assert(broadcastJoinDf.count() == 1000)
+
+ broadcastJoinDf = polygonDf.alias("polygonDf").join(broadcast(pointDf).alias("pointDf"), expr("ST_Contains(polygonDf.polygonshape, pointDf.pointshape)"))
+ assert(broadcastJoinDf.queryExecution.sparkPlan.collect{ case p: BroadcastIndexJoinExec => p }.size === 1)
+ assert(broadcastJoinDf.rdd.getNumPartitions == polygonDf.rdd.getNumPartitions)
+ assert(broadcastJoinDf.count() == 1000)
+ sparkSession.conf.set("spark.sql.adaptive.enabled", false)
+ }
}
}