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

    https://github.com/apache/spark/pull/21405#discussion_r200247398
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeBlockSuite.scala
 ---
    @@ -133,4 +133,55 @@ class CodeBlockSuite extends SparkFunSuite {
                |}""".stripMargin
         assert(aliasedCode.toString == expected.toString)
       }
    +
    +  test ("transform expr in nested blocks") {
    +    val expr = JavaCode.expression("1 + 1", IntegerType)
    +    val isNull = JavaCode.isNullVariable("expr1_isNull")
    +    val exprInFunc = JavaCode.variable("expr1", IntegerType)
    +
    +    val funcs = Seq("callFunc1", "callFunc2", "callFunc3")
    +    val subBlocks = funcs.map { funcName =>
    +      code"""
    +           |$funcName(int $expr) {
    +           |  boolean $isNull = false;
    +           |  int $exprInFunc = $expr + 1;
    +           |}""".stripMargin
    +    }
    +
    +    val aliasedParam = JavaCode.variable("aliased", expr.javaType)
    +
    +    val block = code"${subBlocks(0)}\n${subBlocks(1)}\n${subBlocks(2)}"
    +    val transformedBlock = block.transform {
    +      case b: Block => b.transformExprValues {
    --- End diff --
    
    so the this should be
    ```
    block.transformExprValues {
      case SimpleExprValue ...
    }
    ```


---

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

Reply via email to