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

    https://github.com/apache/spark/pull/21193#discussion_r186250552
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala
 ---
    @@ -112,6 +112,112 @@ object JavaCode {
       def isNullExpression(code: String): SimpleExprValue = {
         expression(code, BooleanType)
       }
    +
    +  def block(code: String): Block = {
    +    CodeBlock(codeParts = Seq(code), blockInputs = Seq.empty)
    +  }
    +}
    +
    +/**
    + * A trait representing a block of java code.
    + */
    +trait Block extends JavaCode {
    +
    +  // The expressions to be evaluated inside this block.
    +  def exprValues: Seq[ExprValue]
    +
    +  // This will be called during string interpolation.
    +  override def toString: String = _marginChar match {
    +    case Some(c) => code.stripMargin(c)
    +    case _ => code
    +  }
    +
    +  var _marginChar: Option[Char] = None
    +
    +  def stripMargin(c: Char): this.type = {
    --- End diff --
    
    Currently we have many usage like"
    ```
      s"""
        | val isNull = false;
        | ...
       """.stripMargin
    ```
    
    To enable this usage with `Block`, so we need to make `Block` with 
`stripMargin` API. 


---

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

Reply via email to