You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/11/03 02:13:20 UTC

[GitHub] [spark] zhengruifeng commented on a diff in pull request #38468: [WIP][CONNECT][PYTHON] Arrow-based collect

zhengruifeng commented on code in PR #38468:
URL: https://github.com/apache/spark/pull/38468#discussion_r1012441577


##########
connector/connect/src/main/scala/org/apache/spark/sql/connect/service/SparkConnectStreamHandler.scala:
##########
@@ -117,7 +121,38 @@ class SparkConnectStreamHandler(responseObserver: StreamObserver[Response]) exte
       responseObserver.onNext(response.build())
     }
 
-    responseObserver.onNext(sendMetricsToResponse(clientId, rows))
+    responseObserver.onNext(sendMetricsToResponse(clientId, dataframe))
+    responseObserver.onCompleted()
+  }
+
+  def processRowsAsArrowBatches(clientId: String, dataframe: DataFrame): Unit = {
+    import org.apache.arrow.vector.ipc.message.{IpcOption, MessageSerializer}
+
+    val schema = dataframe.schema
+    val maxRecordsPerBatch = dataframe.sparkSession.sessionState.conf.arrowMaxRecordsPerBatch
+    val timeZoneId = dataframe.sparkSession.sessionState.conf.sessionLocalTimeZone
+    val arrowSchema = ArrowUtils.toArrowSchema(schema, timeZoneId)
+    val schemaBuffer = MessageSerializer.serializeMetadata(arrowSchema, IpcOption.DEFAULT)
+
+    val rows = dataframe.queryExecution.executedPlan.execute().map(_.copy()).collect()

Review Comment:
   1, agree, will update
   2, i think we can use `toLocalIterator`, but it may trigger multi jobs https://github.com/apache/spark/pull/38300#discussion_r1001301224



-- 
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