You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by cloud-fan <gi...@git.apache.org> on 2017/11/04 13:58:09 UTC

[GitHub] spark pull request #19598: [SPARK-22378][SQL] Eliminate redundant null check...

Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19598#discussion_r148931334
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeExtractors.scala ---
    @@ -186,6 +186,7 @@ case class GetArrayStructFields(
           val values = ctx.freshName("values")
           val j = ctx.freshName("j")
           val row = ctx.freshName("row")
    +      val nullCheckElement = if (!field.nullable) "false" else s"$row.isNullAt($ordinal)"
    --- End diff --
    
    how about
    ```
    val nullSafeEval = if (field.nullable) {
      s"""
        if ($row.isNullAt($ordinal)) {
          $values[$j] = null;
        } else
      """
    } else ""
    ...
    ...
    
    $nullSafeEval {
      $values[$j] = ${ctx.getValue(row, field.dataType, ordinal.toString)};
    }
    ```


---

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