Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16608#discussion_r96276562
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/GenerateExec.scala ---
    @@ -160,9 +160,20 @@ case class GenerateExec(
     
         // Generate looping variables.
         val index = ctx.freshName("index")
    +    val numElements = ctx.freshName("numElements")
    +
    +    // In case of outer=true we need to make sure the loop is executed 
at-least once when the
    +    // array/map contains no input.
    +    // generateOuter is an int. it is set to 1 iff outer is true and the 
input is empty or null.
    +    val generateOuter = ctx.freshName("generateOuter")
    +    val isOuter = if (outer) {
    --- End diff --
    
    How about we generate the expressions for the `generateOuter` variable here 
instead? It is always `0` when `outer == false` and `$numElements == 0 ? 1 : 0` 
when it is true. This increases the probability that the generated code gets 
eliminated at compile time.


---
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]

Reply via email to