You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "hvanhovell (via GitHub)" <gi...@apache.org> on 2023/04/18 01:00:46 UTC

[GitHub] [spark] hvanhovell commented on a diff in pull request #40782: [SPARK-42669][CONNECT] Short circuit local relation RPCs

hvanhovell commented on code in PR #40782:
URL: https://github.com/apache/spark/pull/40782#discussion_r1169388839


##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/SparkSession.scala:
##########
@@ -439,7 +440,23 @@ class SparkSession private[sql] (
   }
 
   private[sql] def execute[T](plan: proto.Plan, encoder: AgnosticEncoder[T]): SparkResult[T] = {
-    val value = client.execute(plan)
+    val value = if (plan.hasRoot && plan.getRoot.hasLocalRelation) {
+      // Short circuit local relation RPCs
+      val localRelation = plan.getRoot.getLocalRelation
+      val response = proto.ExecutePlanResponse.newBuilder()
+      val reader = new ArrowStreamReader(localRelation.getData.newInput(), allocator)
+      reader.loadNextBatch()
+      val batch = proto.ExecutePlanResponse.ArrowBatch
+        .newBuilder()
+        .setRowCount(reader.getVectorSchemaRoot.getRowCount)

Review Comment:
   Do we need to set row count? You can just modify SparkResult to make the assert a bit more lenient.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org