spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiszk <...@git.apache.org>
Subject [GitHub] spark pull request #21045: [WIP][SPARK-23931][SQL] Adds zip function to spar...
Date Fri, 13 Apr 2018 01:48:39 GMT
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21045#discussion_r181267751
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
---
    @@ -87,6 +87,62 @@ case class MapKeys(child: Expression)
       override def prettyName: String = "map_keys"
     }
     
    +@ExpressionDescription(
    +  usage = """_FUNC_(a1, a2) - Returns a merged array matching N-th element of first
    +  array with the N-th element of second.""",
    +  examples = """
    +    Examples
    +      > SELECT _FUNC_(array(1, 2, 3), array(2, 3, 4));
    +        [[1, 2], [2, 3], [3, 4]]
    +  """,
    +  since = "2.4.0")
    +case class Zip(left: Expression, right: Expression)
    +  extends BinaryExpression with ExpectsInputTypes {
    +
    +  override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType, ArrayType)
    +
    +  override def dataType: DataType = ArrayType(left.dataType.asInstanceOf[ArrayType].elementType)
    +
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
    +    nullSafeCodeGen(ctx, ev, (arr1, arr2) => {
    +      val i = ctx.freshName("i")
    +      s"""
    +      for (int $i = 0; $i < $arr1.numElements(); $i ++) {
    +        if ($arr1.isNullAt($i)) {
    +          ${ev.isNull} = true;
    +        } else {
    +          ${ev.value}[$i] = ($arr1[$i], $arr2[$i]);
    --- End diff --
    
    One high level question. Do we have performance or other advantages when we generate Java
code? 


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message