Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/13778#discussion_r70197694
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
---
@@ -346,14 +346,47 @@ case class LambdaVariable(value: String, isNull:
String, dataType: DataType) ext
object MapObjects {
private val curId = new java.util.concurrent.atomic.AtomicInteger()
+ /**
+ * Construct an instance of MapObjects case class.
+ *
+ * @param function The function applied on the collection elements.
+ * @param inputData An expression that when evaluated returns a
collection object.
+ * @param elementType The data type of elements in the collection.
+ */
def apply(
function: Expression => Expression,
inputData: Expression,
elementType: DataType): MapObjects = {
val loopValue = "MapObjects_loopValue" + curId.getAndIncrement()
val loopIsNull = "MapObjects_loopIsNull" + curId.getAndIncrement()
val loopVar = LambdaVariable(loopValue, loopIsNull, elementType)
- MapObjects(loopValue, loopIsNull, elementType, function(loopVar),
inputData)
+ MapObjects(loopValue, loopIsNull, elementType, function(loopVar),
inputData, None)
+ }
+
+ /**
+ * Construct an instance of MapObjects case class.
+ *
+ * @param function The function applied on the collection elements.
+ * @param inputData An expression that when evaluated returns a
collection object.
+ * @param elementType The data type of elements in the collection.
+ * @param inputDataType The explicitly given data type of inputData to
override the
+ * data type inferred from inputData (i.e.,
inputData.dataType).
+ * When Python UDT whose sqlType is an array, the
deserializer
+ * expression will apply MapObjects on it. However,
as the data type
+ * of inputData is Python UDT, which is not an
expected array type
+ * in MapObjects. In this case, we need to
explicitly use
+ * Python UDT's sqlType as data type.
--- End diff --
But now we expose too. Readers have to know about python udt to understand
this code.
---
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]