Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/21830#discussion_r204250861
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
---
@@ -1244,46 +1244,50 @@ case class Reverse(child: Expression) extends
UnaryExpression with ImplicitCastI
}
private def arrayCodeGen(ctx: CodegenContext, ev: ExprCode, childName:
String): String = {
- val length = ctx.freshName("length")
- val javaElementType = CodeGenerator.javaType(elementType)
+
val isPrimitiveType = CodeGenerator.isPrimitiveType(elementType)
+ val numElements = ctx.freshName("numElements")
+ val arrayData = ctx.freshName("arrayData")
+
val initialization = if (isPrimitiveType) {
- s"$childName.copy()"
+ ctx.createUnsafeArray(arrayData, numElements, elementType, s"
$prettyName failed.")
--- End diff --
IIUC, the code in the master also create `UnsafeArrayData` per input row in
`UnsafeArrayData.copy()`.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]