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

    https://github.com/apache/spark/pull/21193#discussion_r189767747
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala
 ---
    @@ -167,9 +170,40 @@ object Block {
               case other => throw new IllegalArgumentException(
                 s"Can not interpolate ${other.getClass.getName} into code 
block.")
             }
    -        CodeBlock(sc.parts, args)
    +
    +        val (codeParts, blockInputs) = foldLiteralArgs(sc.parts, args)
    +        CodeBlock(codeParts, blockInputs)
    +      }
    +    }
    +  }
    +
    +  // Folds eagerly the literal args into the code parts.
    +  private def foldLiteralArgs(parts: Seq[String], args: Seq[Any]): 
(Seq[String], Seq[Any]) = {
    +    val codeParts = ArrayBuffer.empty[String]
    +    val blockInputs = ArrayBuffer.empty[Any]
    +
    +    val strings = parts.iterator
    +    val inputs = args.iterator
    +    val buf = new StringBuilder(Block.CODE_BLOCK_BUFFER_LENGTH)
    +
    +    buf append strings.next
    --- End diff --
    
    Ok.


---

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

Reply via email to