You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2018/06/12 08:55:12 UTC

[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

GitHub user viirya opened a pull request:

    https://github.com/apache/spark/pull/21537

    [SPARK-24505][SQL] Convert strings in codegen to blocks: Cast and BoundAttribute

    ## What changes were proposed in this pull request?
    
    This is split from #21520. This includes changes of `BoundAttribute` and `Cast`.
    This patch also adds few convenient APIs:
    
    ```scala
    CodeGenerator.freshName(name: String, dt: DataType): VariableValue
    CodeGenerator.freshName(name: String, javaClass: Class[_]): VariableValue
    CodeGenerator.isNullFreshName(name: String): VariableValue
    
    JavaCode.className(javaClass: Class[_]): InlineBlock
    JavaCode.javaType(dataType: DataType): InlineBlock
    JavaCode.boxedType(dataType: DataType): InlineBlock
    ```
    
    
    ## How was this patch tested?
    
    Existing tests.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/viirya/spark-1 SPARK-24505-1

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/21537.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #21537
    
----
commit 89d025225b557689389d16c207be8a25f5e82fa5
Author: Liang-Chi Hsieh <vi...@...>
Date:   2018-06-12T08:40:20Z

    Convert strings in codegen to blocks.

----


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93141 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93141/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93088 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93088/testReport)** for PR 21537 at commit [`d278017`](https://github.com/apache/spark/commit/d2780178d94e6bdc57f06a98815bdebe54c4bcfc).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `public class JavaSummarizerExample `
      * `class AvroDeserializer(rootAvroType: Schema, rootCatalystType: DataType) `
      * `  sealed trait CatalystDataUpdater `
      * `  final class RowUpdater(row: InternalRow) extends CatalystDataUpdater `
      * `  final class ArrayDataUpdater(array: ArrayData) extends CatalystDataUpdater `
      * `  class SerializableConfiguration(@transient var value: Configuration)`
      * `class AvroSerializer(rootCatalystType: DataType, rootAvroType: Schema, nullable: Boolean) `
      * `  case class SchemaType(dataType: DataType, nullable: Boolean)`
      * `class IncompatibleSchemaException(msg: String, ex: Throwable = null) extends Exception(msg, ex)`
      * `class SerializableSchema(@transient var value: Schema)`
      * `  implicit class AvroDataFrameWriter[T](writer: DataFrameWriter[T]) `
      * `  implicit class AvroDataFrameReader(reader: DataFrameReader) `
      * `class KMeansModel (@Since(\"1.0.0\") val clusterCenters: Array[Vector],`
      * `trait ComplexTypeMergingExpression extends Expression `
      * `case class Size(child: Expression) extends UnaryExpression with ExpectsInputTypes `
      * `case class MapConcat(children: Seq[Expression]) extends Expression `
      * `abstract class ArraySetLike extends BinaryArrayExpressionWithImplicitCast `
      * `case class ArrayUnion(left: Expression, right: Expression) extends ArraySetLike `
      * `  case class StreamingGlobalLimitStrategy(outputMode: OutputMode) extends Strategy `
      * `case class StreamingGlobalLimitExec(`
      * `sealed trait MultipleWatermarkPolicy `
      * `case class WatermarkTracker(policy: MultipleWatermarkPolicy) extends Logging `
      * `trait MemorySinkBase extends BaseStreamingSink `
      * `class MemorySink(val schema: StructType, outputMode: OutputMode) extends Sink`
      * `class MemoryWriter(sink: MemorySinkV2, batchId: Long, outputMode: OutputMode)`
      * `class MemoryStreamWriter(val sink: MemorySinkV2, outputMode: OutputMode)`


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91822 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91822/testReport)** for PR 21537 at commit [`b592e66`](https://github.com/apache/spark/commit/b592e66c030ba7c2d260c3be48c3b15139f40e5b).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195333092
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -805,43 +811,43 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToStringCode(from: DataType, ctx: CodegenContext): CastFunction = {
         from match {
           case BinaryType =>
    -        (c, evPrim, evNull) => s"$evPrim = UTF8String.fromBytes($c);"
    +        (c, evPrim, evNull) => code"$evPrim = UTF8String.fromBytes($c);"
           case DateType =>
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        (c, evPrim, evNull) => code"""$evPrim = UTF8String.fromString(
               org.apache.spark.sql.catalyst.util.DateTimeUtils.dateToString($c));"""
           case TimestampType =>
    -        val tz = ctx.addReferenceObj("timeZone", timeZone)
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        val tz = JavaCode.global(ctx.addReferenceObj("timeZone", timeZone), timeZone.getClass)
    +        (c, evPrim, evNull) => code"""$evPrim = UTF8String.fromString(
               org.apache.spark.sql.catalyst.util.DateTimeUtils.timestampToString($c, $tz));"""
           case ArrayType(et, _) =>
             (c, evPrim, evNull) => {
    -          val buffer = ctx.freshName("buffer")
    -          val bufferClass = classOf[UTF8StringBuilder].getName
    +          val buffer = ctx.freshVariable("buffer", classOf[UTF8StringBuilder])
    +          val bufferClass = JavaCode.className(classOf[UTF8StringBuilder])
    --- End diff --
    
    I think we could add a class  `Variable` which `GlobalVariable` and `LocalVariable` inherit from having a `declare` method taking an optional parameter `initialValue` so we can just invoke it to declare each variable. But maybe this can also be a followup. What do you think?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    For 2. and 3., it is harder to say my opinion in the comment. Let me say short comments at first.
    
    For 2., if I remember correctly, @viirya once wrote the API document in a JIRA entry. it would be good to update and add some thoughts about design as a first step. I understand that it is hard to keep the up-to-date design document, in particular, during the open-source development. This is because we have a lot of excellent comments in a PR. 
    
    For 3., at the early implementation of SQL codegen (i.e. use `s""` to represent code), I thought there are two problems.
    1. lack of type of an expression (in other words, `ExprCode` did not have the type of `value`)
    2. lack of a structure of statements
    
    Now, we meet a problem that it is hard to rewrite a method argument due to problem 1. In my understanding, the current effort led by @viirya is trying to resolve problem 1.
    It is hard to rewrite a set of statements due to Problem 2. To resolve problem 2, we need more effort. In my opinion, we are addressing them step by step.
    
    Of course, it would be happy for me to co-lead a discussion of the IR design for 2.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91752 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91752/testReport)** for PR 21537 at commit [`531faf4`](https://github.com/apache/spark/commit/531faf4aad4c942efb826fe7ca2ba8a7f1e5cf3f).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91743 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91743/testReport)** for PR 21537 at commit [`7f486fe`](https://github.com/apache/spark/commit/7f486fe8f76b0b5a2c1784e211ff95633968db59).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Thank for involving me in an important thread. I was busy this morning in Japan.
    
    I think there are three topics in the thread.
    1. Merge or revert this PR
    2. Design document
    3. IR design
    
    For 1., in short, my opinion is likely to revert this PR from the view like a release manager.
    
    As we know, it is a time to cut a release branch. This PR partially introduce a new representation. If there would be a bug in code generation at Spark 2.4, it may introduce a complication of debugging and fixing.
    As @mgaido91 pointed out, #20043 and #21026 have been merged. I think that they are a kind of refactoring (e.g. change the representation of literal, class, and so on). Thus, these two PRs can be there. However, this PR introduces a mixture of representation `s""` and `code""`.
    
    WDYT?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194841055
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, javaClass: Class[_]): VariableValue =
    +    JavaCode.variable(freshName(name), javaClass)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local boolean java variable.
    +   */
    +  def isNullFreshName(name: String): VariableValue = JavaCode.isNullVariable(freshName(name))
    --- End diff --
    
    hmmm, now looking at this, `isNullFreshName(name)` doesn't save much typing compared to `freshName(name, BooleanType)`...


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/728/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/373/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93141 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93141/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1014/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92668/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/166/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/43/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194704155
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    --- End diff --
    
    What about some better name like `getLocalVariable` or something similar? this is not just a fresh name...


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/177/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93200 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93200/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195331403
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -805,43 +811,43 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToStringCode(from: DataType, ctx: CodegenContext): CastFunction = {
         from match {
           case BinaryType =>
    -        (c, evPrim, evNull) => s"$evPrim = UTF8String.fromBytes($c);"
    +        (c, evPrim, evNull) => code"$evPrim = UTF8String.fromBytes($c);"
           case DateType =>
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        (c, evPrim, evNull) => code"""$evPrim = UTF8String.fromString(
               org.apache.spark.sql.catalyst.util.DateTimeUtils.dateToString($c));"""
           case TimestampType =>
    -        val tz = ctx.addReferenceObj("timeZone", timeZone)
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        val tz = JavaCode.global(ctx.addReferenceObj("timeZone", timeZone), timeZone.getClass)
    +        (c, evPrim, evNull) => code"""$evPrim = UTF8String.fromString(
               org.apache.spark.sql.catalyst.util.DateTimeUtils.timestampToString($c, $tz));"""
           case ArrayType(et, _) =>
             (c, evPrim, evNull) => {
    -          val buffer = ctx.freshName("buffer")
    -          val bufferClass = classOf[UTF8StringBuilder].getName
    +          val buffer = ctx.freshVariable("buffer", classOf[UTF8StringBuilder])
    +          val bufferClass = JavaCode.className(classOf[UTF8StringBuilder])
    --- End diff --
    
    Now, each variable defined by `freshVariable` has a type. We can get a type or its class name from the variable (e.g. `bufffer`). Therefore, it looks redundant to declare a name of each variable again (e.g. bufferClass).
    Do we have an API to get a type of the variable or define an API to get a name of the class? This is because this pattern is very common.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91893 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91893/testReport)** for PR 21537 at commit [`a972e0e`](https://github.com/apache/spark/commit/a972e0ef694a9e39913f2ea859034cbc4d871f02).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Thanks @mgaido91 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1055/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    I am sorry if I misunderstood. This was discussed sufficiently in the linked PRs. These are internal APIs and does not introduce behaviour changes by AnalysisBarrier which was a good enough idea to try because it brought many benefits to reduce reanalyzing plans - this resolved many JIRA on the other hand, and I don't think AnalysisBarrier was particularly a disaster. Sometimes we should take a step forward and see if that causes an actual problem or not too. That was a good enough try.
    
    When something should be reverted, there should usually be specific concerns; otherwise, I wouldn't revert this for vague concerns for now.
    
    This is an internal API that we can freely change later as well. Also, @viirya made a lot of efforts here and he's pretty active. I don't think dragging someone into this is a good idea for now.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93151 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93151/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93096 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93096/testReport)** for PR 21537 at commit [`f1f2180`](https://github.com/apache/spark/commit/f1f218068bc1e4c147c14dbc56c874c4c7d7cc4b).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93179/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91752 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91752/testReport)** for PR 21537 at commit [`531faf4`](https://github.com/apache/spark/commit/531faf4aad4c942efb826fe7ca2ba8a7f1e5cf3f).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/4015/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    LGTM apart from this [comment](https://github.com/apache/spark/pull/21537#discussion_r209353035)


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Sounds cool, let's move both to JIRAs or mailing lists. 


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202743580
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1024,26 +1033,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    --- End diff --
    
    nit: why isn't this a literal?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91743 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91743/testReport)** for PR 21537 at commit [`7f486fe`](https://github.com/apache/spark/commit/7f486fe8f76b0b5a2c1784e211ff95633968db59).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #94782 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94782/testReport)** for PR 21537 at commit [`508e091`](https://github.com/apache/spark/commit/508e091f53084deefc35001ce8d89455ca549e53).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #94654 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94654/testReport)** for PR 21537 at commit [`508e091`](https://github.com/apache/spark/commit/508e091f53084deefc35001ce8d89455ca549e53).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195628609
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -720,31 +719,36 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private def writeMapToStringBuilder(
           kt: DataType,
           vt: DataType,
    -      map: String,
    -      buffer: String,
    -      ctx: CodegenContext): String = {
    +      map: ExprValue,
    +      buffer: ExprValue,
    +      ctx: CodegenContext): Block = {
     
         def dataToStringFunc(func: String, dataType: DataType) = {
           val funcName = ctx.freshName(func)
           val dataToStringCode = castToStringCode(dataType, ctx)
    +      val data = JavaCode.variable("data", dataType)
    +      val dataStr = JavaCode.variable("dataStr", StringType)
           ctx.addNewFunction(funcName,
    --- End diff --
    
    Maybe we can consider this in follow-ups.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    I am fine to not revert it since it is too late. So many related PRs have been merged, but we need to seriously consider writing and reviewing the design docs before changing the code generation framework of Spark SQL.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @kiszk You are a JVM expert with a very strong IR background. Could you lead the efforts and drive the IR design?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/4057/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/721/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r200563441
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1004,26 +1012,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    +    code"($d.toBigDecimal().bigDecimal().multiply($block)).longValue()"
    +  }
    +  private[this] def longToTimeStampCode(l: ExprValue): Block = code"$l * 1000000L"
    +  private[this] def timestampToIntegerCode(ts: ExprValue): Block =
    +    code"java.lang.Math.floor((double) $ts / 1000000L)"
    +  private[this] def timestampToDoubleCode(ts: ExprValue): Block =
    +    code"$ts / 1000000.0"
     
       private[this] def castToBooleanCode(from: DataType): CastFunction = from match {
         case StringType =>
    -      val stringUtils = StringUtils.getClass.getName.stripSuffix("$")
    +      val stringUtils = inline"${StringUtils.getClass.getName.stripSuffix("$")}"
    --- End diff --
    
    I made inline not a `Block` but just a `JavaCode` now. After rethinking it, inline is used for embedding a piece of string into code block because we don't allow direct string interpolation. So inline as a `Block` doesn't make such sense.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91743/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93117 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93117/testReport)** for PR 21537 at commit [`f1f2180`](https://github.com/apache/spark/commit/f1f218068bc1e4c147c14dbc56c874c4c7d7cc4b).


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194697467
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -625,25 +625,23 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
         val eval = child.genCode(ctx)
         val nullSafeCast = nullSafeCastFunction(child.dataType, dataType, ctx)
     
    -    ev.copy(code =
    +    ev.copy(code = eval.code +
           code"""
    --- End diff --
    
    this can be removed, can't it?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #94654 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94654/testReport)** for PR 21537 at commit [`508e091`](https://github.com/apache/spark/commit/508e091f53084deefc35001ce8d89455ca549e53).


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195181950
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, javaClass: Class[_]): VariableValue =
    +    JavaCode.variable(freshName(name), javaClass)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local boolean java variable.
    +   */
    +  def isNullFreshName(name: String): VariableValue = JavaCode.isNullVariable(freshName(name))
    --- End diff --
    
    change the new one in this PR but open another PR to rename `JavaCode.isNullVariable`


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @HyukjinKwon sorry for being late. I was swampped with several things. I have just submitted it. Looking forward to seeing feedback.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196025306
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -113,6 +113,21 @@ object JavaCode {
       def isNullExpression(code: String): SimpleExprValue = {
         expression(code, BooleanType)
       }
    +
    +  /**
    +   * Create an `InlineBlock` for Java Class name.
    +   */
    +  def className(javaClass: Class[_]): InlineBlock = InlineBlock(javaClass.getName)
    --- End diff --
    
    I am not sure about the names of these 3 methods... They are doing kind of the same thing but this name is pretty different form the other 2... What do you think?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1004/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91754/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93108/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195356119
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -805,43 +811,43 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToStringCode(from: DataType, ctx: CodegenContext): CastFunction = {
         from match {
           case BinaryType =>
    -        (c, evPrim, evNull) => s"$evPrim = UTF8String.fromBytes($c);"
    +        (c, evPrim, evNull) => code"$evPrim = UTF8String.fromBytes($c);"
           case DateType =>
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        (c, evPrim, evNull) => code"""$evPrim = UTF8String.fromString(
               org.apache.spark.sql.catalyst.util.DateTimeUtils.dateToString($c));"""
           case TimestampType =>
    -        val tz = ctx.addReferenceObj("timeZone", timeZone)
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        val tz = JavaCode.global(ctx.addReferenceObj("timeZone", timeZone), timeZone.getClass)
    +        (c, evPrim, evNull) => code"""$evPrim = UTF8String.fromString(
               org.apache.spark.sql.catalyst.util.DateTimeUtils.timestampToString($c, $tz));"""
           case ArrayType(et, _) =>
             (c, evPrim, evNull) => {
    -          val buffer = ctx.freshName("buffer")
    -          val bufferClass = classOf[UTF8StringBuilder].getName
    +          val buffer = ctx.freshVariable("buffer", classOf[UTF8StringBuilder])
    +          val bufferClass = JavaCode.className(classOf[UTF8StringBuilder])
    --- End diff --
    
    It is fine with me to address this in another PR.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    seems the issue of `check_package_CRAN_incoming` again...


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Sure, I am fine with @kiszk leading the effort of course, I just wanted to give credit to @viirya for the (current) design as it was mostly done by him.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202816019
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1024,26 +1033,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    --- End diff --
    
    Does it matter? I think a literal is a piece of code (small) which is a left value and does not contain any reference to any reference to variables and can be put anywhere in the code returning always the same result. In the use case of splitting function, for instance, I imagine a literal is just reused everywhere needed without need to pass it to the new methods. So for these reasons IMHO this is a literal. WDYT? Also @cloud-fan WDYT?


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195626998
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -155,6 +170,17 @@ object Block {
     
       val CODE_BLOCK_BUFFER_LENGTH: Int = 512
     
    +  /**
    +   * A custom string interpolator which inlines all types of input arguments into a string without
    --- End diff --
    
    I will also do some improvement of document.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202269577
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -720,31 +719,36 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private def writeMapToStringBuilder(
           kt: DataType,
           vt: DataType,
    -      map: String,
    -      buffer: String,
    -      ctx: CodegenContext): String = {
    +      map: ExprValue,
    +      buffer: ExprValue,
    +      ctx: CodegenContext): Block = {
     
         def dataToStringFunc(func: String, dataType: DataType) = {
           val funcName = ctx.freshName(func)
           val dataToStringCode = castToStringCode(dataType, ctx)
    +      val data = JavaCode.variable("data", dataType)
    +      val dataStr = JavaCode.variable("dataStr", StringType)
           ctx.addNewFunction(funcName,
    --- End diff --
    
    Since this method `dataToStringFunc()` is not used in other files, it would be good to address it in this PR. WDYT?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91831 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91831/testReport)** for PR 21537 at commit [`b592e66`](https://github.com/apache/spark/commit/b592e66c030ba7c2d260c3be48c3b15139f40e5b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @gatorsmile Thank you for your reply. Could you elaborate on your suggestion?
    >A general suggestion. To avoid introducing the regressions, how about implementing a new one without changing the existing one? We can easily switch to the new one when it becomes stable.
    
    Does it mean to work in a particular branch or to work in a fork repository until its implementation has been completed ? 



---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/94782/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r197352302
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    +    case b: Blocks => Blocks(Seq(this) ++ b.blocks)
    --- End diff --
    
    Ok. I will do that PR first. Will ping you on the PR when it's ready.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91831/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/4067/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/719/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196769413
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -113,6 +113,21 @@ object JavaCode {
       def isNullExpression(code: String): SimpleExprValue = {
         expression(code, BooleanType)
       }
    +
    +  /**
    +   * Create an `InlineBlock` for Java Class name.
    +   */
    +  def className(javaClass: Class[_]): InlineBlock = InlineBlock(javaClass.getName)
    --- End diff --
    
    Is `javaClass` better for you?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91883/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194961281
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -625,25 +625,23 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
         val eval = child.genCode(ctx)
         val nullSafeCast = nullSafeCastFunction(child.dataType, dataType, ctx)
     
    -    ev.copy(code =
    +    ev.copy(code = eval.code +
           code"""
    --- End diff --
    
    Oh. Yes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Thanks everyone for this discussion. I think we all agree that what we need as a first thing is a design doc and we can move the discussion there.
    
    @kiszk thank you for your comments. I remember too a document with the proposed API, but I didn't remember if it was a design doc or not and if there was an official agreement on it. Anyway, the document is this one: https://docs.google.com/document/d/1By_V-A2sxCWbP7dZ5EzHIuMSe8K0fQL9lqovGWXnsfs. Probably we can start from it for a proper SPIP?
    
    I think the main goal of this is well described there, ie. allowing param replacement for splitting code in wholestage-codegen scenario.
    
    Thanks everybody for this discussion.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202597179
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -196,7 +221,7 @@ object Block {
             EmptyBlock
           } else {
             args.foreach {
    -          case _: ExprValue =>
    +          case _: ExprValue | _: Inline =>
    --- End diff --
    
    nit: also move `_: Block` here?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93200 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93200/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195284656
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, javaClass: Class[_]): VariableValue =
    +    JavaCode.variable(freshName(name), javaClass)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local boolean java variable.
    +   */
    +  def isNullFreshName(name: String): VariableValue = JavaCode.isNullVariable(freshName(name))
    --- End diff --
    
    Rename `JavaCode.isNullVariable`?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Yea, yea. I understand. I wasn't trying to say the severity of effect by introducing AnalysisBarrier wasn't trivial. True, I understand it is not an easy job. Thank you Reynold for that. Yea, also I don't mean to say we should just go ahead without sufficient discussion. Wanted to point out that there are positive aspects of the effort and try about AnalysisBarrier too. It wasn't all bad in a way.
    
    > The reason why we did not merge this PR is that we are doubting this is the right thing to do. @rednaxelafx
    
    If that's true, the concerns should be mentioned here and discussed. Was there a discussion about it in the community and did I miss it? I would appreciate if we can talk here.
    
    > Instead of reinventing a compiler, how about letting the compiler internal expert (in our community, we have @kiszk) to lead the effort and offer a design for this. 
    
    If there is a design concern for that and better suggestion, let's file a JIRA. I want to see the problem, concerns and possible suggestions as well.
    
    Yup, I got that it might be better for someone who has some expertise in that area but I was thinking that they should purely based upon the community work primarily - in that way, it looked reasonable @viirya goes ahead since it's basically his work. If not, to me I don't see any particular one is preferred. 
    
    Just wanted to point out that the baseline is open for anyone not for specific persons. If anyone is willing to do this, anyone is welcome to go ahead. So, primarily they should voluntarily join in without other factors.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    We are fully swamped by the hotfix and regressions of 2.3 release and the new features that are targeting to 2.4. We should post some comments in this PR earlier. 
    
    Designing an IR for our codegen is the right thing we should do. [If you do not agree on this, we can discuss about it.] How to design an IR is a challenging task. The whole community is welcome to submit the designs and PRs. Everyone can show the ideas. The best idea will win. @HyukjinKwon If you have a bandwidth, please also have a try


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91744 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91744/testReport)** for PR 21537 at commit [`531faf4`](https://github.com/apache/spark/commit/531faf4aad4c942efb826fe7ca2ba8a7f1e5cf3f).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @kiszk Thanks. Your comments are addressed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1011/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    AnalysisBarrier does not introduce a behavior change. However, this requires our analyzer rules must be idempotent. The most recent correctness bug also shows another big potential hole https://issues.apache.org/jira/browse/SPARK-25051. It could break Analyzer rules without notice, since AnalysisBarrier is a leaf node. Basically, this is a disaster for Spark 2.3 release. You can count how many regressions we found after the release. This is bad. Unfortunately, I made the merge without enough consideration. If possible, I would revert that PR, but it is too late. 
    
    Now, we are facing the similar issue again. We should stop continuing this direction without a proper design and review. Designing/enhancing the codegen framework requires more inputs from the experts in this area. I do not think the current design is well discussed, even if I saw some discussions in the initial PR. I am not the expert in this area. That is why I pinged @kiszk to drive this. 
    
    BTW, the internal APIs we can change easily, but the design need a review especially for the core components of Spark SQL. 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @kiszk, have we created a JIRA or sent an email to dev mailing list yet? or am I missing something already that happened?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91883 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91883/testReport)** for PR 21537 at commit [`a972e0e`](https://github.com/apache/spark/commit/a972e0ef694a9e39913f2ea859034cbc4d871f02).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91697 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91697/testReport)** for PR 21537 at commit [`89d0252`](https://github.com/apache/spark/commit/89d025225b557689389d16c207be8a25f5e82fa5).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196025077
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    +    case b: Blocks => Blocks(Seq(this) ++ b.blocks)
    --- End diff --
    
    nit: `this +: b.blocks`?


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202839264
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1024,26 +1033,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    --- End diff --
    
    This piece of code that creates a `BigDecimal` object is simply used as an argument to `multiply` method. I think we may not need to track it as an `ExprValue`. Actually I also think here we can just `inline` it.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202582231
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -720,31 +719,36 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private def writeMapToStringBuilder(
           kt: DataType,
           vt: DataType,
    -      map: String,
    -      buffer: String,
    -      ctx: CodegenContext): String = {
    +      map: ExprValue,
    +      buffer: ExprValue,
    +      ctx: CodegenContext): Block = {
     
         def dataToStringFunc(func: String, dataType: DataType) = {
           val funcName = ctx.freshName(func)
           val dataToStringCode = castToStringCode(dataType, ctx)
    +      val data = JavaCode.variable("data", dataType)
    +      val dataStr = JavaCode.variable("dataStr", StringType)
           ctx.addNewFunction(funcName,
    --- End diff --
    
    Ok. Sounds good. Will update later.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/133/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r197079333
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    --- End diff --
    
    as of now probably we don't have... @cloud-fan @kiszk what do you think?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @kiszk The initial prototype or proof of concept can be in any personal branch. When we merge it to the master branch, we still need to separate it from the current codegen and make it configurable. After the release, the users can choose which one to be used. When the new IR is stable, we can then consider deprecate the current one. This is majorly for product stability. We need to follow the similar principle for any big project. 
    
    @viirya @mgaido91 Let us first focus on the new IR design and prototype. 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93096/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged to master.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @gatorsmile I think this is just the partial adoption of what was proposed [here](https://github.com/apache/spark/pull/19813#issuecomment-354045400) and implemented in SPARK-24121 (https://github.com/apache/spark/pull/21193).
    
    Despite I agree with you that we should have created a design doc for this, I think now is a bit late for it. Indeed the base API is already there, since the design has mostly been done in SPARK-24121 (and not in the scope of this PR). What is missing now, though, is a throughout adoption. But there are already many PRs which based on that API: SPARK-22856, SPARK-23951. And the current codebase already partially adopts it.
    
    So I am not sure whether reverting this PR would be a solution: we should revert many if we want the change the current design.
    
    I think a design can be created anyway, at least in order to formalize what was discussed and agreed in the various PRs and have a single source of information. We can also do some modifications to the current design according to the comments which could come out discussing the design doc, but I see them more like further changes than reverting this, as it would mean reverting many things.
    
    The only last thing I'd suggest is that probably @viirya is the best one for creating the design doc, since the original proposal and implementation was done by him.
    
    Thanks.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91752/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202800594
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1024,26 +1033,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    --- End diff --
    
    It looks like a statement to create `BigDecimal` object instead of just a `BigDecimal` literal?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/4022/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2107/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91706 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91706/testReport)** for PR 21537 at commit [`89d0252`](https://github.com/apache/spark/commit/89d025225b557689389d16c207be8a25f5e82fa5).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91754 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91754/testReport)** for PR 21537 at commit [`531faf4`](https://github.com/apache/spark/commit/531faf4aad4c942efb826fe7ca2ba8a7f1e5cf3f).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #92681 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92681/testReport)** for PR 21537 at commit [`ce5aa08`](https://github.com/apache/spark/commit/ce5aa0841a76f74316ffabd00dc328b1b3d1fdc2).


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195307036
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, javaClass: Class[_]): VariableValue =
    +    JavaCode.variable(freshName(name), javaClass)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local boolean java variable.
    +   */
    +  def isNullFreshName(name: String): VariableValue = JavaCode.isNullVariable(freshName(name))
    --- End diff --
    
    Ok.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/4068/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r197245629
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    +    case b: Blocks => Blocks(Seq(this) ++ b.blocks)
    --- End diff --
    
    shall we do that PR first? I feel it's easier to review this PR after we clean up the `Block` framework.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93151 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93151/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91893/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    LGTM


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #92671 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92671/testReport)** for PR 21537 at commit [`ce5aa08`](https://github.com/apache/spark/commit/ce5aa0841a76f74316ffabd00dc328b1b3d1fdc2).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91822/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    This is bad. The design needs to be carefully reviewed before implementing it. Basically, we breaks the basic principles of software engineering. It is very strange to write the design doc after introducing such a fundamental API change. 
    
    I think we need more expertise in the existing compiler internal experts. That is why I proposed to let @kiszk to lead this. We are not inventing anything new in our codegen framework. 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Is there any comments we should address in this PR?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93096 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93096/testReport)** for PR 21537 at commit [`f1f2180`](https://github.com/apache/spark/commit/f1f218068bc1e4c147c14dbc56c874c4c7d7cc4b).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93141/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @HyukjinKwon Thanks! I've updated. Please let me know if they are good now.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #92671 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92671/testReport)** for PR 21537 at commit [`ce5aa08`](https://github.com/apache/spark/commit/ce5aa0841a76f74316ffabd00dc328b1b3d1fdc2).
     * This patch **fails SparkR unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91822 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91822/testReport)** for PR 21537 at commit [`b592e66`](https://github.com/apache/spark/commit/b592e66c030ba7c2d260c3be48c3b15139f40e5b).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    This is not related to the credit or not. I think we need to introduce an IR like what the compiler is doing instead of continuous improvement on the existing one, which is already very hacky and hard to debug and maintain. We are wasting the efforts and resources if we follow the current direction. 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/81/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Thanks for all involving in this discussion!
    
    Sorry that I was on a long flight and feels too tired to reply now. I just want to say for now, no matter what decision we made, to continue to improve existing framework or have a IR design, I will definitely actively join in.
    



---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202718932
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -825,43 +832,43 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToStringCode(from: DataType, ctx: CodegenContext): CastFunction = {
         from match {
           case BinaryType =>
    -        (c, evPrim, evNull) => s"$evPrim = UTF8String.fromBytes($c);"
    +        (c, evPrim, evNull) => code"$evPrim = UTF8String.fromBytes($c);"
           case DateType =>
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        (c, evPrim, evNull) => code"""$evPrim = UTF8String.fromString(
               org.apache.spark.sql.catalyst.util.DateTimeUtils.dateToString($c));"""
           case TimestampType =>
    -        val tz = ctx.addReferenceObj("timeZone", timeZone)
    -        (c, evPrim, evNull) => s"""$evPrim = UTF8String.fromString(
    +        val tz = JavaCode.global(ctx.addReferenceObj("timeZone", timeZone), timeZone.getClass)
    --- End diff --
    
    ditto, will `ctx.addReferenceObj` return JavaCode eventually?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    If we will continue on improving current codegen framework, I think it is good to have a design doc reviewed by the community.
    
    If we decide to have IR design and get rid of this string based framework, do we still need to have design doc for the current codegen improvement? Or we can focus on IR design doc?


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202800647
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -196,7 +221,7 @@ object Block {
             EmptyBlock
           } else {
             args.foreach {
    -          case _: ExprValue =>
    +          case _: ExprValue | _: Inline =>
    --- End diff --
    
    Moved.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93151/
    Test FAILed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195626960
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -155,6 +170,17 @@ object Block {
     
       val CODE_BLOCK_BUFFER_LENGTH: Int = 512
     
    +  /**
    +   * A custom string interpolator which inlines all types of input arguments into a string without
    --- End diff --
    
    I think part of this comment can be moved to `InlineBlock`.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #94782 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/94782/testReport)** for PR 21537 at commit [`508e091`](https://github.com/apache/spark/commit/508e091f53084deefc35001ce8d89455ca549e53).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93088/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r209464356
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1024,26 +1033,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    --- End diff --
    
    `JavaCode.expression` is used to create `ExprValue` we need to track it in a code block. We don't need to track this `BigDecimal` variable. Here we just interpolate it into next code block.



---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/3971/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Based on this PR, so many changes will be made in the codegen. The codegen is very fundamental to Spark SQL. I do not think we should merge this PR at this stage. To be more disciplined, we need a design doc for these API level changes in the codegen.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196024658
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    --- End diff --
    
    does this mean that if we have to consecutive `InlineBlock`s we are concatenating them without any space? Is this ok?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195051547
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    --- End diff --
    
    I think either we decide to postpone the introduction of this API to a followup PR or we can change its name now that we are introducing it...


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92671/
    Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Thanks @HyukjinKwon 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/3929/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/91744/
    Test FAILed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194703775
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1004,26 +1014,30 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): ExprValue =
    +    JavaCode.expression(
    +      s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()",
    --- End diff --
    
    is it safe to do this? aren't we loosing the reference to `$d`?


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r197352254
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1004,26 +1012,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    +    code"($d.toBigDecimal().bigDecimal().multiply($block)).longValue()"
    +  }
    +  private[this] def longToTimeStampCode(l: ExprValue): Block = code"$l * 1000000L"
    +  private[this] def timestampToIntegerCode(ts: ExprValue): Block =
    +    code"java.lang.Math.floor((double) $ts / 1000000L)"
    +  private[this] def timestampToDoubleCode(ts: ExprValue): Block =
    +    code"$ts / 1000000.0"
     
       private[this] def castToBooleanCode(from: DataType): CastFunction = from match {
         case StringType =>
    -      val stringUtils = StringUtils.getClass.getName.stripSuffix("$")
    +      val stringUtils = inline"${StringUtils.getClass.getName.stripSuffix("$")}"
    --- End diff --
    
    inline is just used as a wrapper for string, as we disallow silent string interpolation. We expand the content of an inline into string into a code block.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91744 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91744/testReport)** for PR 21537 at commit [`531faf4`](https://github.com/apache/spark/commit/531faf4aad4c942efb826fe7ca2ba8a7f1e5cf3f).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @HyukjinKwon I am worrying about the design of a mixture of representation s"" and code""? When the design is not good, it is hard to maintain it and add new code based on this. Let @cloud-fan to decide whether we should revert it or not.
    
    @mgaido91 The doc you posted is one of the problems the IR can resolve. However, we need a high-level and low-level design doc for building a new IR in codegen. 
    
    @kiszk Thanks for leading this effort! You are the best candidate to lead this in the community. 
    
    @viirya Thanks for your professional reply! Have a good rest. 
    
    A general suggestion. To avoid introducing the regressions, how about implementing a new one without changing the existing one? We can easily switch to the new one when it becomes stable. Thanks all for making our codegen better! 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/998/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196769133
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    --- End diff --
    
    I think we won't have too many cases of concatenating `InlineBlock`. You can see `InlineBlock` is mostly used to wrap a small piece of code like a java class name. I'm not sure if we need to add a newline here.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    cc @cloud-fan @hvanhovell @kiszk @mgaido91 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91883 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91883/testReport)** for PR 21537 at commit [`a972e0e`](https://github.com/apache/spark/commit/a972e0ef694a9e39913f2ea859034cbc4d871f02).


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r197245172
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1004,26 +1012,29 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): Block = {
    +    val block = code"new java.math.BigDecimal(1000000L)"
    +    code"($d.toBigDecimal().bigDecimal().multiply($block)).longValue()"
    +  }
    +  private[this] def longToTimeStampCode(l: ExprValue): Block = code"$l * 1000000L"
    +  private[this] def timestampToIntegerCode(ts: ExprValue): Block =
    +    code"java.lang.Math.floor((double) $ts / 1000000L)"
    +  private[this] def timestampToDoubleCode(ts: ExprValue): Block =
    +    code"$ts / 1000000.0"
     
       private[this] def castToBooleanCode(from: DataType): CastFunction = from match {
         case StringType =>
    -      val stringUtils = StringUtils.getClass.getName.stripSuffix("$")
    +      val stringUtils = inline"${StringUtils.getClass.getName.stripSuffix("$")}"
    --- End diff --
    
    what's the difference between inline and code?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93132/
    Test FAILed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195328074
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -720,31 +719,36 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private def writeMapToStringBuilder(
           kt: DataType,
           vt: DataType,
    -      map: String,
    -      buffer: String,
    -      ctx: CodegenContext): String = {
    +      map: ExprValue,
    +      buffer: ExprValue,
    +      ctx: CodegenContext): Block = {
     
         def dataToStringFunc(func: String, dataType: DataType) = {
           val funcName = ctx.freshName(func)
           val dataToStringCode = castToStringCode(dataType, ctx)
    +      val data = JavaCode.variable("data", dataType)
    +      val dataStr = JavaCode.variable("dataStr", StringType)
           ctx.addNewFunction(funcName,
    --- End diff --
    
    nit: probably we can return this as `inline`, so we don't have to put it everywhere we use it


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91706 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91706/testReport)** for PR 21537 at commit [`89d0252`](https://github.com/apache/spark/commit/89d025225b557689389d16c207be8a25f5e82fa5).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `  implicit class InlineHelper(val sc: StringContext) extends AnyVal `
      * `case class InlineBlock(block: String) extends Block `


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194946640
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -1004,26 +1014,30 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
       private[this] def castToIntervalCode(from: DataType): CastFunction = from match {
         case StringType =>
           (c, evPrim, evNull) =>
    -        s"""$evPrim = CalendarInterval.fromString($c.toString());
    +        code"""$evPrim = CalendarInterval.fromString($c.toString());
                if(${evPrim} == null) {
                  ${evNull} = true;
                }
              """.stripMargin
     
       }
     
    -  private[this] def decimalToTimestampCode(d: String): String =
    -    s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()"
    -  private[this] def longToTimeStampCode(l: String): String = s"$l * 1000000L"
    -  private[this] def timestampToIntegerCode(ts: String): String =
    -    s"java.lang.Math.floor((double) $ts / 1000000L)"
    -  private[this] def timestampToDoubleCode(ts: String): String = s"$ts / 1000000.0"
    +  private[this] def decimalToTimestampCode(d: ExprValue): ExprValue =
    +    JavaCode.expression(
    +      s"($d.toBigDecimal().bigDecimal().multiply(new java.math.BigDecimal(1000000L))).longValue()",
    --- End diff --
    
    hmm, here we should use `Block`. Fixed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    I think we can set up a place (mailling list or JIRA) to discuss the further thing about IR design, as suggested by @HyukjinKwon. This can be a co-work from interesting parties.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    I wouldn't revert this unless there are specific concerns about this. Do you see any bug by a mixture 
     of representation `s""` and `code""`? 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92681/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92167/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r202271473
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,18 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshVariable(name: String, dt: DataType): VariableValue =
    +    JavaCode.variable(freshName(name), dt)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    --- End diff --
    
    nit: `data type` -> `Java class`


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/3964/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194958976
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, javaClass: Class[_]): VariableValue =
    +    JavaCode.variable(freshName(name), javaClass)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local boolean java variable.
    +   */
    +  def isNullFreshName(name: String): VariableValue = JavaCode.isNullVariable(freshName(name))
    --- End diff --
    
    hmm, don't we want to do this in this PR? I can change it to `freshName(name, BooleanType)` together with the changes for other comments.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93200/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    retest this please.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #92668 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92668/testReport)** for PR 21537 at commit [`ce5aa08`](https://github.com/apache/spark/commit/ce5aa0841a76f74316ffabd00dc328b1b3d1fdc2).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195184136
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    --- End diff --
    
    how about we move it to `JavaCode` and follow the name convention there and call it `freshVariable`?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @viirya, mind if I ask to update the PR description? Looks proposed APIs were slightly changed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93179 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93179/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194908404
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, javaClass: Class[_]): VariableValue =
    +    JavaCode.variable(freshName(name), javaClass)
    +
    +  /**
    +   * Creates an `ExprValue` representing a local boolean java variable.
    +   */
    +  def isNullFreshName(name: String): VariableValue = JavaCode.isNullVariable(freshName(name))
    --- End diff --
    
    haha, indeed. At least there is only one parameter. Maybe we should just use `freshName(name, BooleanType)`.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r197065708
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    --- End diff --
    
    That said, I don't think we should have an usage like:
    ```
    val inline1 = InlineBlock(".....")
    val inline2 = inline1 + InlineBlock(".....")
    code"""
         | $inline2
         | ...
       """.stripMargin
    ```
    
    



---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    To Spark users, introducing AnalysisBarrier is a disaster. However, to the developers of Spark internal, this is just a bug. If you served the customers who are heavily using Spark, you will understand what I am talking about. It is even hard to debug when the Spark jobs are very complex. 
    
    Normally, we never commit/merge any PR that is useless, especially when the PR changes are not tiny. Reverting this PRs are also very painful. That is why Reynold took a few days to finish it. It is not a fun job for him to rewrite it.
    
    Based on the current work, I can expect there are hundreds of PRs that will be submitted for changing the codegen templates and polishing the current code. The reason why we did not merge this PR is that we are doubting this is the right thing to do. @rednaxelafx 
    
    I am not saying @viirya and @mgaido91 did a bad job to submit many PRs to improve the existing one. However, we need to think of the fundamental problems we are solving in the codegen. Instead of reinventing a compiler, how about letting the compiler internal expert (in our community, we have @kiszk) to lead the effort and offer a design for this. Coding and designing are different issues. If possible, we need to find the best person to drive it. If @viirya and @mgaido91 think they are familiar with compiler internal, I am also glad to see the designs.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93132 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93132/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91831 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91831/testReport)** for PR 21537 at commit [`b592e66`](https://github.com/apache/spark/commit/b592e66c030ba7c2d260c3be48c3b15139f40e5b).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution/3933/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/39/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195328479
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -155,6 +170,17 @@ object Block {
     
       val CODE_BLOCK_BUFFER_LENGTH: Int = 512
     
    +  /**
    +   * A custom string interpolator which inlines all types of input arguments into a string without
    --- End diff --
    
    nit: maybe this comment is better to be put to the `InlineBlock` class, do you agree?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Another example is the AnalysisBarrier, which becomes a disaster to Spark 2.3 release. Many blockers, correctness bugs, performance regressions are caused by that. Thus, I think we should revert this PR until we have a high-level design doc and roadmap for the codegen. For example, introducing IR. 


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195306721
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    --- End diff --
    
    oh I missed the ctx parameter thing, let's leave it.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93132 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93132/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/2201/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #92668 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92668/testReport)** for PR 21537 at commit [`ce5aa08`](https://github.com/apache/spark/commit/ce5aa0841a76f74316ffabd00dc328b1b3d1fdc2).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/74/
    Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196029083
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -256,6 +283,22 @@ object EmptyBlock extends Block with Serializable {
       override def + (other: Block): Block = other
     }
     
    +/**
    + * A block inlines all types of input arguments into a string without
    + * tracking any reference of `JavaCode` instances.
    + */
    +case class InlineBlock(block: String) extends Block {
    +  override val code: String = block
    +  override val exprValues: Set[ExprValue] = Set.empty
    +
    +  override def + (other: Block): Block = other match {
    +    case c: CodeBlock => Blocks(Seq(this, c))
    +    case i: InlineBlock => InlineBlock(block + i.block)
    +    case b: Blocks => Blocks(Seq(this) ++ b.blocks)
    --- End diff --
    
    After discussed with @cloud-fan, I think this abstraction `Blocks` is not necessary. It can be replaced with `CodeBlock`. I will submit a PR to do that.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    I don't see a notable risk here. That's just to avoid string interpolation, which makes less error-prone, which is discussed already and the code change is small.
    
    I hope we can move other discussions to other threads like JIRA or mailing list so that people can see. It's quite difficult to find such discussion to me actually.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196807818
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -113,6 +113,21 @@ object JavaCode {
       def isNullExpression(code: String): SimpleExprValue = {
         expression(code, BooleanType)
       }
    +
    +  /**
    +   * Create an `InlineBlock` for Java Class name.
    +   */
    +  def className(javaClass: Class[_]): InlineBlock = InlineBlock(javaClass.getName)
    --- End diff --
    
    what about `javaType` as the method below? They return the same thing, just with a different input, don't they?


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91697 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91697/testReport)** for PR 21537 at commit [`89d0252`](https://github.com/apache/spark/commit/89d025225b557689389d16c207be8a25f5e82fa5).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `  implicit class InlineHelper(val sc: StringContext) extends AnyVal `
      * `case class InlineBlock(block: String) extends Block `


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91754 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91754/testReport)** for PR 21537 at commit [`531faf4`](https://github.com/apache/spark/commit/531faf4aad4c942efb826fe7ca2ba8a7f1e5cf3f).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/1021/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/21537


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r194960933
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    --- End diff --
    
    Sounds good. Not sure if @cloud-fan wants me to change it in this PR or other https://github.com/apache/spark/pull/21537#discussion_r194841055. 


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93179 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93179/testReport)** for PR 21537 at commit [`807d8d4`](https://github.com/apache/spark/commit/807d8d44f950b8a588065b15bb7fa6a5db753075).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    @kiszk Please create a JIRA and we can post more ideas there. Thanks!


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    It's a good point that we should have a design doc for this codegen infrastructure improvement, since it's very critical to Spark. And we should have it reviewed by the community.
    
    There were some discussions on the PRs and JIRAs, but it didn't happen in the dev list. This is something we should do next.
    
    At this stage, I think it's too late to revert anything related to the codegen improvement. There are so many codegen templates get touched and I think reverting is riskier.
    
    But we should hold it now until the design doc is reviewed by the community in dev list.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r196808968
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/javaCode.scala ---
    @@ -113,6 +113,21 @@ object JavaCode {
       def isNullExpression(code: String): SimpleExprValue = {
         expression(code, BooleanType)
       }
    +
    +  /**
    +   * Create an `InlineBlock` for Java Class name.
    +   */
    +  def className(javaClass: Class[_]): InlineBlock = InlineBlock(javaClass.getName)
    --- End diff --
    
    Ok. Looks good to me.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #91893 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/91893/testReport)** for PR 21537 at commit [`a972e0e`](https://github.com/apache/spark/commit/a972e0ef694a9e39913f2ea859034cbc4d871f02).


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/126/
    Test PASSed.


---

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


[GitHub] spark pull request #21537: [SPARK-24505][SQL] Convert strings in codegen to ...

Posted by viirya <gi...@git.apache.org>.
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21537#discussion_r195284269
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -579,6 +579,22 @@ class CodegenContext {
         s"${fullName}_$id"
       }
     
    +  /**
    +   * Creates an `ExprValue` representing a local java variable of required data type.
    +   */
    +  def freshName(name: String, dt: DataType): VariableValue = JavaCode.variable(freshName(name), dt)
    --- End diff --
    
    Putting it in `CodeGenerator` is just for convenience that we can save a `ctx` parameter. I'm fine to let it in `JavaCode` too if you don't think it's verbose.


---

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


[GitHub] spark issue #21537: [SPARK-24505][SQL] Convert strings in codegen to blocks:...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21537
  
    **[Test build #93108 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93108/testReport)** for PR 21537 at commit [`f1f2180`](https://github.com/apache/spark/commit/f1f218068bc1e4c147c14dbc56c874c4c7d7cc4b).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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