Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/12057#discussion_r58106827
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/python/BatchPythonEvaluation.scala
---
@@ -69,19 +70,47 @@ case class BatchPythonEvaluation(udf: PythonUDF,
output: Seq[Attribute], child:
// combine input with output from Python.
val queue = new
java.util.concurrent.ConcurrentLinkedQueue[InternalRow]()
- val (pyFuncs, children) = collectFunctions(udf)
-
- val pickle = new Pickler
- val currentRow = newMutableProjection(children, child.output)()
- val fields = children.map(_.dataType)
- val schema = new StructType(fields.map(t => new StructField("", t,
true)).toArray)
+ val (pyFuncs, inputs) = udfs.map(collectFunctions).unzip
+
+ // flatten all the arguments
+ val allInputs = new ArrayBuffer[Expression]
+ val dataTypes = new ArrayBuffer[DataType]
+ val argOffsets = inputs.map { input =>
+ input.map { e =>
+ if (allInputs.exists(_.semanticEquals(e))) {
+ allInputs.indexWhere(_.semanticEquals(e))
+ } else {
+ allInputs += e
+ dataTypes += e.dataType
+ allInputs.length - 1
+ }
+ }.toArray
+ }.toArray
+ val projection = newMutableProjection(allInputs, child.output)()
+ val schema = StructType(dataTypes.map(dt => StructField("", dt)))
--- End diff --
I'm not sure whether the name of this struct field will ever appear / get
used anywhere, but if you wanted to provide a nicer name I suppose you could
pull in the name or .toString from the expression in `allInput`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]