viirya commented on a change in pull request #31296:
URL: https://github.com/apache/spark/pull/31296#discussion_r562952128
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/objects.scala
##########
@@ -624,3 +624,32 @@ case class CoGroupExec(
}
}
}
+
+/**
+ * Piping elements to a forked external process.
+ * The output of its child must be a single-field row containing the input
object.
+ */
+case class PipeElementsExec(
+ outputObjAttr: Attribute,
+ command: String,
+ child: SparkPlan)
+ extends ObjectConsumerExec with ObjectProducerExec {
+
+ override protected def doExecute(): RDD[InternalRow] = {
+ val getObject =
ObjectOperator.unwrapObjectFromRow(child.output.head.dataType)
+ val printRDDElement: (InternalRow, String => Unit) => Unit = (row,
printFunc) => {
+ printFunc(getObject(row).toString)
+ }
+
+ child.execute()
+ .pipe(command = PipedRDD.tokenize(command), printRDDElement =
printRDDElement)
+ .mapPartitionsInternal { iter =>
+ val outputObject = ObjectOperator.wrapObjectToRow(outputObjectType)
+ iter.map(ele => outputObject(ele))
Review comment:
changed.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]