HyukjinKwon commented on code in PR #36683: URL: https://github.com/apache/spark/pull/36683#discussion_r882541257
########## sql/core/src/main/scala/org/apache/spark/sql/execution/arrow/ArrowConverters.scala: ########## @@ -190,32 +191,30 @@ private[sql] object ArrowConverters { } /** - * Create a DataFrame from an RDD of serialized ArrowRecordBatches. + * Create a DataFrame from an iterator of serialized ArrowRecordBatches. */ - private[sql] def toDataFrame( - arrowBatchRDD: JavaRDD[Array[Byte]], + def toDataFrame( + arrowBatches: Iterator[Array[Byte]], schemaString: String, session: SparkSession): DataFrame = { - val schema = DataType.fromJson(schemaString).asInstanceOf[StructType] - val timeZoneId = session.sessionState.conf.sessionLocalTimeZone - val rdd = arrowBatchRDD.rdd.mapPartitions { iter => - val context = TaskContext.get() - ArrowConverters.fromBatchIterator(iter, schema, timeZoneId, context) - } - session.internalCreateDataFrame(rdd.setName("arrow"), schema) + val attrs = DataType.fromJson(schemaString).asInstanceOf[StructType].toAttributes + val data = ArrowConverters.fromBatchIterator( + arrowBatches, + DataType.fromJson(schemaString).asInstanceOf[StructType], + session.sessionState.conf.sessionLocalTimeZone, + TaskContext.get()) + // Project it. Otherwise, the Arrow column vectors will be closed and released out. Review Comment: ```suggestion // Project/copy it. Otherwise, the Arrow column vectors will be closed and released out. ``` -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org