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/04/19 14:15:30 UTC

[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

GitHub user viirya opened a pull request:

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

    [SPARK-23711][SQL][WIP] Add fallback logic for UnsafeProjection

    ## What changes were proposed in this pull request?
    
    This is WIP work for adding fallback to interpreted execution logic.
    
    ## How was this patch tested?
    
    TBD

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

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

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

    https://github.com/apache/spark/pull/21106.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 #21106
    
----
commit fe2a1cdd9002f14422c812d51041ed4f6d361cfc
Author: Liang-Chi Hsieh <vi...@...>
Date:   2018-04-19T14:07:22Z

    Add the base of fallback logic fo UnsafeProjection.

----


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/90319/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r187520079
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    --- End diff --
    
    any better name? How about `CodeGeneratorWithInterpretedFallback` and make it extends `CodeGenerator`?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/3001/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90965 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90965/testReport)** for PR 21106 at commit [`5527595`](https://github.com/apache/spark/commit/5527595b83b9cd394ba6d52e82711b777259f569).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2996/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    Any more comments on this? @hvanhovell @cloud-fan 


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90947 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90947/testReport)** for PR 21106 at commit [`ed525f6`](https://github.com/apache/spark/commit/ed525f688c272e382494020dcf99a1fe05393ad3).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r187786817
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    --- End diff --
    
    Ok. Reamed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90313 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90313/testReport)** for PR 21106 at commit [`06cc8cc`](https://github.com/apache/spark/commit/06cc8cc360024a2afe01478242144dee348b7a72).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3293/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r187954345
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/InterpretedUnsafeProjection.scala ---
    @@ -87,12 +87,11 @@ class InterpretedUnsafeProjection(expressions: Array[Expression]) extends Unsafe
     /**
      * Helper functions for creating an [[InterpretedUnsafeProjection]].
      */
    -object InterpretedUnsafeProjection extends UnsafeProjectionCreator {
    -
    +object InterpretedUnsafeProjection {
       /**
        * Returns an [[UnsafeProjection]] for given sequence of bound Expressions.
        */
    -  override protected def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    +  protected[sql] def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    --- End diff --
    
    Fogot to commit...


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r187613369
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    --- End diff --
    
    `GenerateUnsafeProjection` also extends `CodeGenerator`.
    
    Is there any class we want it to extend `CodegenObjectFactory` but not `CodeGenerator`?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90939 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90939/testReport)** for PR 21106 at commit [`ed525f6`](https://github.com/apache/spark/commit/ed525f688c272e382494020dcf99a1fe05393ad3).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90932 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90932/testReport)** for PR 21106 at commit [`ed525f6`](https://github.com/apache/spark/commit/ed525f688c272e382494020dcf99a1fe05393ad3).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    also cc @rednaxelafx


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r187897203
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/InterpretedUnsafeProjection.scala ---
    @@ -87,12 +87,11 @@ class InterpretedUnsafeProjection(expressions: Array[Expression]) extends Unsafe
     /**
      * Helper functions for creating an [[InterpretedUnsafeProjection]].
      */
    -object InterpretedUnsafeProjection extends UnsafeProjectionCreator {
    -
    +object InterpretedUnsafeProjection {
       /**
        * Returns an [[UnsafeProjection]] for given sequence of bound Expressions.
        */
    -  override protected def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    +  protected[sql] def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    --- End diff --
    
    Did you change it?


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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/21106#discussion_r188914060
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/UnsafeRowConverterSuite.scala ---
    @@ -24,25 +24,29 @@ import org.scalatest.Matchers
     
     import org.apache.spark.SparkFunSuite
     import org.apache.spark.sql.catalyst.InternalRow
    +import org.apache.spark.sql.catalyst.plans.PlanTestBase
     import org.apache.spark.sql.catalyst.util._
    +import org.apache.spark.sql.internal.SQLConf
     import org.apache.spark.sql.types.{IntegerType, LongType, _}
     import org.apache.spark.unsafe.array.ByteArrayMethods
     import org.apache.spark.unsafe.types.UTF8String
     
    -class UnsafeRowConverterSuite extends SparkFunSuite with Matchers {
    +class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestBase {
     
       private def roundedSize(size: Int) = ByteArrayMethods.roundNumberOfBytesToNearestWord(size)
     
    -  private def testWithFactory(
    -    name: String)(
    -    f: UnsafeProjectionCreator => Unit): Unit = {
    -    test(name) {
    -      f(UnsafeProjection)
    -      f(InterpretedUnsafeProjection)
    +  private def testBothCodegenAndInterpreted(name: String)(f: => Unit): Unit = {
    +    for (fallbackMode <- Seq("CODEGEN_ONLY", "NO_CODEGEN")) {
    --- End diff --
    
    ditto


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    @hvanhovell If you don't have other comment, I will follow @cloud-fan's suggestion to add a sql conf for it. Thanks.


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r187671317
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    --- End diff --
    
    ok let's keep the previous way to minimize code changes. How about just rename it to `CodeGeneratorWithInterpretedFallback`?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    thanks, merging to master!


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r186630383
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala ---
    @@ -686,6 +687,17 @@ object SQLConf {
         .intConf
         .createWithDefault(100)
     
    +  val CODEGEN_OBJECT_FALLBACK = buildConf("spark.sql.test.codegenObject.fallback")
    --- End diff --
    
    hmm, shall we use `CODEGEN_FACTORY_MODE` or `CODEGEN_FALLBACK_MODE`?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89578 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89578/testReport)** for PR 21106 at commit [`fe2a1cd`](https://github.com/apache/spark/commit/fe2a1cdd9002f14422c812d51041ed4f6d361cfc).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89882 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89882/testReport)** for PR 21106 at commit [`68213fb`](https://github.com/apache/spark/commit/68213fb76f1840ee08012ebbf14f10db969568aa).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `trait CodegenObjectFactoryBase[IN, OUT] `
      * `trait CodegenObjectFactory[IN, OUT] extends CodegenObjectFactoryBase[IN, OUT] `
      * `trait CodegenObjectFactoryWithoutFallback[IN, OUT] extends CodegenObjectFactoryBase[IN, OUT] `
      * `trait InterpretedCodegenObjectFactory[IN, OUT] extends CodegenObjectFactoryBase[IN, OUT] `


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90674 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90674/testReport)** for PR 21106 at commit [`f883c2b`](https://github.com/apache/spark/commit/f883c2b8f2b80b2d73e28d78fcaa6530143e0b66).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r187641350
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    --- End diff --
    
    Yes, no doubt `GenerateUnsafeProjection` extends `CodeGenerator`. It's the class doing generators of byte codes.
    
    Previously `UnsafeProjection` has its own interface `UnsafeProjectionCreator`, does not extends `CodeGenerator`. So currently I let it follow previous `UnsafeProjection`'s API.
    
    We can change it to implement `CodeGenerator` and also change the places using `UnsafeProjection`, if you think it is necessary.
    
    
    



---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r186652609
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala ---
    @@ -108,7 +108,31 @@ abstract class UnsafeProjection extends Projection {
       override def apply(row: InternalRow): UnsafeRow
     }
     
    -trait UnsafeProjectionCreator {
    +/**
    + * The factory object for `UnsafeProjection`.
    + */
    +object UnsafeProjection extends CodegenObjectFactory[Seq[Expression], UnsafeProjection] {
    --- End diff --
    
    If all subclasses of `CodegenObjectFactory` need `mode`, isn't we ask for it value at `createObject` better?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2964/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90783 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90783/testReport)** for PR 21106 at commit [`5a735af`](https://github.com/apache/spark/commit/5a735afd4de6b13fe7d8cef667ebcd291e438b4c).


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r187353305
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala ---
    @@ -108,7 +108,31 @@ abstract class UnsafeProjection extends Projection {
       override def apply(row: InternalRow): UnsafeRow
     }
     
    -trait UnsafeProjectionCreator {
    +/**
    + * The factory object for `UnsafeProjection`.
    + */
    +object UnsafeProjection extends CodegenObjectFactory[Seq[Expression], UnsafeProjection] {
    --- End diff --
    
    The problem of passing `mode` into class `UnsafeProjection` is, if we create the `UnsafeProjection` object and then change the SQL config, it can't be reflected in ``UnsafeProjection` object's behavior.
    
    If we don't let the config affect this behavior on production, then it should be fine. Then we don't actually need this parameter at most of time, because we only use it in tests. If so, this parameter seems useless. We just need to access `CodegenObjectFactoryMode.currentMode` when `createObject` is called.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90490 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90490/testReport)** for PR 21106 at commit [`4c04d14`](https://github.com/apache/spark/commit/4c04d140d59d3cf7f11b6eae91896124eeb48496).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3462/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90951 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90951/testReport)** for PR 21106 at commit [`c9ec817`](https://github.com/apache/spark/commit/c9ec81709fb277d6c902c6eaf9721be1a67e2698).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3322/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90319 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90319/testReport)** for PR 21106 at commit [`1f5cc17`](https://github.com/apache/spark/commit/1f5cc17741ef0feed5894fbafd21c36a44bc5373).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    I agree. It is what I saw when I've tried to change it locally. 


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r186305770
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,66 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    +
    +  // Creates wanted object. First trying codegen implementation. If any compile error happens,
    +  // fallbacks to interpreted version.
    +  def createObject(in: IN): OUT = {
    +    val fallbackMode = SQLConf.get.getConf(SQLConf.CODEGEN_OBJECT_FALLBACK)
    --- End diff --
    
    We can only access SQLConf on the driver. We can't know this config value inside `createObject` which can be called on executors. 
    
    To solve this, `UnsafeProjection` can't be an object as now, but a case class with a fallback mode parameter. So we can create this factory on driver. @cloud-fan @hvanhovell WDYT?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/3118/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/89604/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r182794729
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,63 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +object CodegenObjectFactory {
    --- End diff --
    
    Can we make this an abstract class in which we just need to implement hooks for the  code generated and interpreted versions, i.e.:
    ```scala
    object CodegenError {
      def unapply(throwable: Throwable): Option[Exception] = throwable match {
        case e: InternalCompilerException => Some(e)
        case e: CompileException => Some(e)
        case _ => None
      }
    }
    
    abstract class CodegenObjectFactory[IN, OUT] {
      def create(in: IN): OUT = try createCodeGeneratedObject(in) catch {
        case CodegenError(_) =>createInterpretedObject(in)
      }
    
      protected def createCodeGeneratedObject(in: IN): OUT
      protected def createInterpretedObject(in: IN): OUT
    }
    
    object UnsafeProjectionFactory extends CodegenObjectFactory[Seq[Expression], UnsafeProjection] {
      ...
    }
    ```


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    Yeah, let's move forward slowly. I am still pondering about the what the right abstraction here would look like; this looks promising though.
    
    Can you try to unify this class with `UnsafeProjectionCreator`?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90485 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90485/testReport)** for PR 21106 at commit [`1f5cc17`](https://github.com/apache/spark/commit/1f5cc17741ef0feed5894fbafd21c36a44bc5373).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89603 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89603/testReport)** for PR 21106 at commit [`36f90cf`](https://github.com/apache/spark/commit/36f90cfe0cacff8362dc9546432dbc6a0a391ba4).
     * This patch **fails PySpark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `abstract class CodegenObjectFactory[IN, OUT] `


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    `UnsafeKVExternalSorterSuite` should not create a task context with null properties, can you fix that?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/3123/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r186629233
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala ---
    @@ -686,6 +687,17 @@ object SQLConf {
         .intConf
         .createWithDefault(100)
     
    +  val CODEGEN_OBJECT_FALLBACK = buildConf("spark.sql.test.codegenObject.fallback")
    --- End diff --
    
    `CODEGEN_FACTORY_MODE` and `spark.sql.codegen.factoryMode`?
    



---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3251/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/90313/
    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 #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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

    https://github.com/apache/spark/pull/21106#discussion_r188616153
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodeGeneratorWithInterpretedFallback.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A codegen object generator which creates objects with codegen path first. Once any compile
    + * error happens, it can fallbacks to interpreted implementation. In tests, we can use a SQL config
    + * `SQLConf.CODEGEN_FACTORY_MODE` to control fallback behavior.
    + */
    +abstract class CodeGeneratorWithInterpretedFallback[IN, OUT] {
    +
    +  def createObject(in: IN): OUT = {
    +    // We are allowed to choose codegen-only or no-codegen modes if under tests.
    +    if (Utils.isTesting && CodegenObjectFactoryMode.currentMode != CodegenObjectFactoryMode.AUTO) {
    --- 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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

    https://github.com/apache/spark/pull/21106#discussion_r189818763
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/UnsafeRowConverterSuite.scala ---
    @@ -24,25 +24,30 @@ import org.scalatest.Matchers
     
     import org.apache.spark.SparkFunSuite
     import org.apache.spark.sql.catalyst.InternalRow
    +import org.apache.spark.sql.catalyst.plans.PlanTestBase
     import org.apache.spark.sql.catalyst.util._
    +import org.apache.spark.sql.internal.SQLConf
     import org.apache.spark.sql.types.{IntegerType, LongType, _}
     import org.apache.spark.unsafe.array.ByteArrayMethods
     import org.apache.spark.unsafe.types.UTF8String
     
    -class UnsafeRowConverterSuite extends SparkFunSuite with Matchers {
    +class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestBase {
     
       private def roundedSize(size: Int) = ByteArrayMethods.roundNumberOfBytesToNearestWord(size)
     
    -  private def testWithFactory(
    -    name: String)(
    -    f: UnsafeProjectionCreator => Unit): Unit = {
    -    test(name) {
    -      f(UnsafeProjection)
    -      f(InterpretedUnsafeProjection)
    +  private def testBothCodegenAndInterpreted(name: String)(f: => Unit): Unit = {
    +    val modes = Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, CodegenObjectFactoryMode.NO_CODEGEN)
    +    for (fallbackMode <- modes) {
    +      test(name + " with " + fallbackMode) {
    --- End diff --
    
    nit: `s"$name with $fallbackMode"`


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89882 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89882/testReport)** for PR 21106 at commit [`68213fb`](https://github.com/apache/spark/commit/68213fb76f1840ee08012ebbf14f10db969568aa).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r186630039
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_OBJECT_FALLBACK)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    +
    +  def createObject(in: IN): OUT = {
    +    // We are allowed to choose codegen-only or no-codegen modes if under tests.
    --- End diff --
    
    I'm rethinking about it. Do you think this conf is useful if there is a perf problem in codegen and users want to use interpreted version?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90277 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90277/testReport)** for PR 21106 at commit [`32e2766`](https://github.com/apache/spark/commit/32e27664d6ef626a1f2ece9af3eeeef46f6444c4).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90725 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90725/testReport)** for PR 21106 at commit [`8c56ae4`](https://github.com/apache/spark/commit/8c56ae450c2e8cb666bac26f0718e4f6c4ddf271).


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r187519505
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/InterpretedUnsafeProjection.scala ---
    @@ -87,12 +87,11 @@ class InterpretedUnsafeProjection(expressions: Array[Expression]) extends Unsafe
     /**
      * Helper functions for creating an [[InterpretedUnsafeProjection]].
      */
    -object InterpretedUnsafeProjection extends UnsafeProjectionCreator {
    -
    +object InterpretedUnsafeProjection {
       /**
        * Returns an [[UnsafeProjection]] for given sequence of bound Expressions.
        */
    -  override protected def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    +  protected[sql] def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    --- End diff --
    
    we are inside `object`, if we want to expose it, just mark it as `public`


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90313 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90313/testReport)** for PR 21106 at commit [`06cc8cc`](https://github.com/apache/spark/commit/06cc8cc360024a2afe01478242144dee348b7a72).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90319 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90319/testReport)** for PR 21106 at commit [`1f5cc17`](https://github.com/apache/spark/commit/1f5cc17741ef0feed5894fbafd21c36a44bc5373).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90278 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90278/testReport)** for PR 21106 at commit [`aeef468`](https://github.com/apache/spark/commit/aeef4684f6bbb957acf460db222792faf773e39a).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class CodegenObjectFactorySuite extends SparkFunSuite with PlanTestBase `


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    I took a deeper look, changing to case class needs a lot of changes, let's follow your previous approach.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3445/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90546 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90546/testReport)** for PR 21106 at commit [`67f8701`](https://github.com/apache/spark/commit/67f870133ab22a32e2af020a1b8893595dcef7cf).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90725 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90725/testReport)** for PR 21106 at commit [`8c56ae4`](https://github.com/apache/spark/commit/8c56ae450c2e8cb666bac26f0718e4f6c4ddf271).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90277 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90277/testReport)** for PR 21106 at commit [`32e2766`](https://github.com/apache/spark/commit/32e27664d6ef626a1f2ece9af3eeeef46f6444c4).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/3172/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r186706306
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala ---
    @@ -108,7 +108,31 @@ abstract class UnsafeProjection extends Projection {
       override def apply(row: InternalRow): UnsafeRow
     }
     
    -trait UnsafeProjectionCreator {
    +/**
    + * The factory object for `UnsafeProjection`.
    + */
    +object UnsafeProjection extends CodegenObjectFactory[Seq[Expression], UnsafeProjection] {
    --- End diff --
    
    I mean something like
    ```
    abstract class CodegenObjectFactory[IN, OUT] {
      def mode: CodegenObjectFactoryMode
    
      def createObject(in: IN): OUT = {
        if (mode == ...) ...
        ...
      }
    }
    ```


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89604 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89604/testReport)** for PR 21106 at commit [`36f90cf`](https://github.com/apache/spark/commit/36f90cfe0cacff8362dc9546432dbc6a0a391ba4).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89603 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89603/testReport)** for PR 21106 at commit [`36f90cf`](https://github.com/apache/spark/commit/36f90cfe0cacff8362dc9546432dbc6a0a391ba4).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2508/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2507/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    I think `UnsafeProjectionCreator` is only useful for tests, because in production we should always try codegen first, and fallback to interpretation if codegen fails. There is no need to disable the fallback(always codegen) or skip the codegen(always interpretation) in production.
    
    How about we provide a sql conf for test only, to be able to disable the fallback(always codegen) or skip the codegen(always interpretation)?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    Should this PR wait for https://github.com/apache/spark/pull/21299 so that accessing confs on executors can be made simpler?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90776 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90776/testReport)** for PR 21106 at commit [`5a735af`](https://github.com/apache/spark/commit/5a735afd4de6b13fe7d8cef667ebcd291e438b4c).


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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

    https://github.com/apache/spark/pull/21106#discussion_r188889216
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CodeGeneratorWithInterpretedFallbackSuite.scala ---
    @@ -0,0 +1,57 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.catalyst.plans.PlanTestBase
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.sql.types.{IntegerType, LongType}
    +
    +class CodeGeneratorWithInterpretedFallbackSuite extends SparkFunSuite with PlanTestBase {
    +
    +  // Given a factory object and corresponding input, checking if `SQLConf.CODEGEN_FACTORY_MODE`
    +  // can switch between codegen/interpreted implementation.
    +  private def testCodegenFactory[IN, OUT](factory: CodeGeneratorWithInterpretedFallback[IN, OUT],
    --- End diff --
    
    Ok.


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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/21106#discussion_r188872456
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/UnsafeRowConverterSuite.scala ---
    @@ -24,21 +24,27 @@ import org.scalatest.Matchers
     
     import org.apache.spark.SparkFunSuite
     import org.apache.spark.sql.catalyst.InternalRow
    +import org.apache.spark.sql.catalyst.plans.PlanTestBase
     import org.apache.spark.sql.catalyst.util._
    +import org.apache.spark.sql.internal.SQLConf
     import org.apache.spark.sql.types.{IntegerType, LongType, _}
     import org.apache.spark.unsafe.array.ByteArrayMethods
     import org.apache.spark.unsafe.types.UTF8String
     
    -class UnsafeRowConverterSuite extends SparkFunSuite with Matchers {
    +class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestBase {
     
       private def roundedSize(size: Int) = ByteArrayMethods.roundNumberOfBytesToNearestWord(size)
     
       private def testWithFactory(
    --- End diff --
    
    we can also clean this up
    ```
    def testBothCodegenAndInterpreted(name: String, f: => Unit): Unit = {
      for (fallbackMode <- Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, ...)) {
        test(name + " with " + fallbackMode) {
          withSQLConf ...
        }    
      }
    }
    ```


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90724 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90724/testReport)** for PR 21106 at commit [`716d88f`](https://github.com/apache/spark/commit/716d88f93f41ca3ac5bb035018745effea06e9de).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    mostly LGTM, though people may have better ideas about naming.
    
    cc @hvanhovell 


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r186632431
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_OBJECT_FALLBACK)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    +
    +  def createObject(in: IN): OUT = {
    +    // We are allowed to choose codegen-only or no-codegen modes if under tests.
    --- End diff --
    
    Hmm, possible. If users are aware of codegen objects like unsafe projection can be controlled too. Currently when we fallback from wholestage codegen to interpreted mode, we still use codegen unsafe projection if it doesn't fail compile.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90485 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90485/testReport)** for PR 21106 at commit [`1f5cc17`](https://github.com/apache/spark/commit/1f5cc17741ef0feed5894fbafd21c36a44bc5373).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90724 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90724/testReport)** for PR 21106 at commit [`716d88f`](https://github.com/apache/spark/commit/716d88f93f41ca3ac5bb035018745effea06e9de).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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/21106#discussion_r188872878
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CodeGeneratorWithInterpretedFallbackSuite.scala ---
    @@ -0,0 +1,57 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.catalyst.plans.PlanTestBase
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.sql.types.{IntegerType, LongType}
    +
    +class CodeGeneratorWithInterpretedFallbackSuite extends SparkFunSuite with PlanTestBase {
    +
    +  // Given a factory object and corresponding input, checking if `SQLConf.CODEGEN_FACTORY_MODE`
    +  // can switch between codegen/interpreted implementation.
    +  private def testCodegenFactory[IN, OUT](factory: CodeGeneratorWithInterpretedFallback[IN, OUT],
    --- End diff --
    
    this is a little over design. Since we only have one test case, can we just online this?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    @cloud-fan Fixed. Thanks.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90783 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90783/testReport)** for PR 21106 at commit [`5a735af`](https://github.com/apache/spark/commit/5a735afd4de6b13fe7d8cef667ebcd291e438b4c).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    I think it's very hard to unify the entry point(input type) for all the code generators. E.g. some use `Seq[Expression]` as input, some use `Seq[DataType]`.
    
    I'd like to make `CodegenObjectFactory` only define internal interfaces, and each implementation defines its own public interface by its need. E.g.
    
    ```
    object UnsafeProjectionCreator
        extends CodegenObjectFactory[(Seq[Expression], Boolean), UnsafeProjection] {
    
      protected def createCodeGeneratedObject(
          expressions: Seq[Expression],
          subexpressionEliminationEnabled: Boolean) = ...
    
      protected def createInterpretedObject(
          expressions: Seq[Expression],
          subexpressionEliminationEnabled: Boolean) = ...
    
      def create(expressions: Seq[Expression]) = ...
      def create(schema: StructType) = ...
    }
    
    ```


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2491/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    LGTM except some minor comments


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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/21106#discussion_r187986602
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodeGeneratorWithInterpretedFallback.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A codegen object generator which creates objects with codegen path first. Once any compile
    + * error happens, it can fallbacks to interpreted implementation. In tests, we can use a SQL config
    + * `SQLConf.CODEGEN_FACTORY_MODE` to control fallback behavior.
    + */
    +abstract class CodeGeneratorWithInterpretedFallback[IN, OUT] {
    +
    +  def createObject(in: IN): OUT = {
    +    // We are allowed to choose codegen-only or no-codegen modes if under tests.
    +    if (Utils.isTesting && CodegenObjectFactoryMode.currentMode != CodegenObjectFactoryMode.AUTO) {
    --- End diff --
    
    now it's better to call it fallback mode?


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r187528023
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    --- End diff --
    
    Why it needs `CodeGenerator`? I think this `CodeGeneratorWithInterpretedFallback` just delegate to various `CodeGenerator` (e.g., `GenerateUnsafeProjection`) to produce codegen object.


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r187528270
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/InterpretedUnsafeProjection.scala ---
    @@ -87,12 +87,11 @@ class InterpretedUnsafeProjection(expressions: Array[Expression]) extends Unsafe
     /**
      * Helper functions for creating an [[InterpretedUnsafeProjection]].
      */
    -object InterpretedUnsafeProjection extends UnsafeProjectionCreator {
    -
    +object InterpretedUnsafeProjection {
       /**
        * Returns an [[UnsafeProjection]] for given sequence of bound Expressions.
        */
    -  override protected def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    +  protected[sql] def createProjection(exprs: Seq[Expression]): UnsafeProjection = {
    --- End diff --
    
    Ok.


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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/21106#discussion_r188913856
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala ---
    @@ -196,39 +197,33 @@ trait ExpressionEvalHelper extends GeneratorDrivenPropertyChecks {
           expression: Expression,
           expected: Any,
           inputRow: InternalRow = EmptyRow): Unit = {
    -    checkEvaluationWithUnsafeProjection(expression, expected, inputRow, UnsafeProjection)
    -    checkEvaluationWithUnsafeProjection(expression, expected, inputRow, InterpretedUnsafeProjection)
    -  }
    -
    -  protected def checkEvaluationWithUnsafeProjection(
    -      expression: Expression,
    -      expected: Any,
    -      inputRow: InternalRow,
    -      factory: UnsafeProjectionCreator): Unit = {
    -    val unsafeRow = evaluateWithUnsafeProjection(expression, inputRow, factory)
    -    val input = if (inputRow == EmptyRow) "" else s", input: $inputRow"
    -
    -    if (expected == null) {
    -      if (!unsafeRow.isNullAt(0)) {
    -        val expectedRow = InternalRow(expected, expected)
    -        fail("Incorrect evaluation in unsafe mode: " +
    -          s"$expression, actual: $unsafeRow, expected: $expectedRow$input")
    -      }
    -    } else {
    -      val lit = InternalRow(expected, expected)
    -      val expectedRow =
    -        factory.create(Array(expression.dataType, expression.dataType)).apply(lit)
    -      if (unsafeRow != expectedRow) {
    -        fail("Incorrect evaluation in unsafe mode: " +
    -          s"$expression, actual: $unsafeRow, expected: $expectedRow$input")
    +    for (fallbackMode <- Seq("CODEGEN_ONLY", "NO_CODEGEN")) {
    --- End diff --
    
    let's not hardcode it, call `CodegenObjectFactoryMode.xxx` instead


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    Test FAILed.
    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/3292/
    Test FAILed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90776 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90776/testReport)** for PR 21106 at commit [`5a735af`](https://github.com/apache/spark/commit/5a735afd4de6b13fe7d8cef667ebcd291e438b4c).
     * 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2965/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r186631613
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala ---
    @@ -686,6 +687,17 @@ object SQLConf {
         .intConf
         .createWithDefault(100)
     
    +  val CODEGEN_OBJECT_FALLBACK = buildConf("spark.sql.test.codegenObject.fallback")
    --- End diff --
    
    `CODEGEN_FACTORY_MODE` seems more accurate to me. This doesn't control all codegen fallback.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    > I think we have a general problem with passing configs to code generators. For this PR, let's make it simple and only use the conf in tests. We are fine in tests because tests create these code generators in driver and we can access SQLConf directly.
    
    @cloud-fan Ok. Let's only use the config in test for now. So do you still think we should make `UnsafeProjection` as class and pass in `mode` like this?
    ```scala
    class UnsafeProjection(mode: CodegenObjectFactoryMode = CodegenObjectFactoryMode.currentMode)
    ```
    Currently `CodegenObjectFactory.createObject` will check `currentMode`.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2691/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90546 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90546/testReport)** for PR 21106 at commit [`67f8701`](https://github.com/apache/spark/commit/67f870133ab22a32e2af020a1b8893595dcef7cf).


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3452/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90671 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90671/testReport)** for PR 21106 at commit [`f883c2b`](https://github.com/apache/spark/commit/f883c2b8f2b80b2d73e28d78fcaa6530143e0b66).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3439/
    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 #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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/21106#discussion_r188871228
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala ---
    @@ -196,39 +197,35 @@ trait ExpressionEvalHelper extends GeneratorDrivenPropertyChecks {
           expression: Expression,
           expected: Any,
           inputRow: InternalRow = EmptyRow): Unit = {
    -    checkEvaluationWithUnsafeProjection(expression, expected, inputRow, UnsafeProjection)
    -    checkEvaluationWithUnsafeProjection(expression, expected, inputRow, InterpretedUnsafeProjection)
    -  }
    -
    -  protected def checkEvaluationWithUnsafeProjection(
    -      expression: Expression,
    -      expected: Any,
    -      inputRow: InternalRow,
    -      factory: UnsafeProjectionCreator): Unit = {
    -    val unsafeRow = evaluateWithUnsafeProjection(expression, inputRow, factory)
    -    val input = if (inputRow == EmptyRow) "" else s", input: $inputRow"
    -
    -    if (expected == null) {
    -      if (!unsafeRow.isNullAt(0)) {
    -        val expectedRow = InternalRow(expected, expected)
    -        fail("Incorrect evaluation in unsafe mode: " +
    -          s"$expression, actual: $unsafeRow, expected: $expectedRow$input")
    -      }
    -    } else {
    -      val lit = InternalRow(expected, expected)
    -      val expectedRow =
    -        factory.create(Array(expression.dataType, expression.dataType)).apply(lit)
    -      if (unsafeRow != expectedRow) {
    -        fail("Incorrect evaluation in unsafe mode: " +
    -          s"$expression, actual: $unsafeRow, expected: $expectedRow$input")
    +    for (fallbackMode <- Seq("CODEGEN_ONLY", "NO_CODEGEN")) {
    +      withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode) {
    +        val factory = UnsafeProjection
    +        val unsafeRow = evaluateWithUnsafeProjection(expression, inputRow, factory)
    +        val input = if (inputRow == EmptyRow) "" else s", input: $inputRow"
    +
    +        if (expected == null) {
    +          if (!unsafeRow.isNullAt(0)) {
    +            val expectedRow = InternalRow(expected, expected)
    +            fail("Incorrect evaluation in unsafe mode: " +
    +              s"$expression, actual: $unsafeRow, expected: $expectedRow$input")
    +          }
    +        } else {
    +          val lit = InternalRow(expected, expected)
    +          val expectedRow =
    +            factory.create(Array(expression.dataType, expression.dataType)).apply(lit)
    +          if (unsafeRow != expectedRow) {
    +            fail("Incorrect evaluation in unsafe mode: " +
    +              s"$expression, actual: $unsafeRow, expected: $expectedRow$input")
    +          }
    +        }
           }
         }
       }
     
       protected def evaluateWithUnsafeProjection(
           expression: Expression,
           inputRow: InternalRow = EmptyRow,
    -      factory: UnsafeProjectionCreator = UnsafeProjection): InternalRow = {
    +      factory: UnsafeProjection.type = UnsafeProjection): InternalRow = {
    --- End diff --
    
    does this really need to take the parameter?


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL] Add fallback generator for Uns...

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

    https://github.com/apache/spark/pull/21106#discussion_r189840863
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/UnsafeRowConverterSuite.scala ---
    @@ -24,25 +24,30 @@ import org.scalatest.Matchers
     
     import org.apache.spark.SparkFunSuite
     import org.apache.spark.sql.catalyst.InternalRow
    +import org.apache.spark.sql.catalyst.plans.PlanTestBase
     import org.apache.spark.sql.catalyst.util._
    +import org.apache.spark.sql.internal.SQLConf
     import org.apache.spark.sql.types.{IntegerType, LongType, _}
     import org.apache.spark.unsafe.array.ByteArrayMethods
     import org.apache.spark.unsafe.types.UTF8String
     
    -class UnsafeRowConverterSuite extends SparkFunSuite with Matchers {
    +class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestBase {
     
       private def roundedSize(size: Int) = ByteArrayMethods.roundNumberOfBytesToNearestWord(size)
     
    -  private def testWithFactory(
    -    name: String)(
    -    f: UnsafeProjectionCreator => Unit): Unit = {
    -    test(name) {
    -      f(UnsafeProjection)
    -      f(InterpretedUnsafeProjection)
    +  private def testBothCodegenAndInterpreted(name: String)(f: => Unit): Unit = {
    +    val modes = Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, CodegenObjectFactoryMode.NO_CODEGEN)
    +    for (fallbackMode <- modes) {
    +      test(name + " with " + fallbackMode) {
    --- 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    cc @hvanhovell 


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89615 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89615/testReport)** for PR 21106 at commit [`36f90cf`](https://github.com/apache/spark/commit/36f90cfe0cacff8362dc9546432dbc6a0a391ba4).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89604 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89604/testReport)** for PR 21106 at commit [`36f90cf`](https://github.com/apache/spark/commit/36f90cfe0cacff8362dc9546432dbc6a0a391ba4).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `abstract class CodegenObjectFactory[IN, OUT] `


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90490 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90490/testReport)** for PR 21106 at commit [`4c04d14`](https://github.com/apache/spark/commit/4c04d140d59d3cf7f11b6eae91896124eeb48496).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    A sql conf sounds good to me. @hvanhovell 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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90545 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90545/testReport)** for PR 21106 at commit [`129b6ac`](https://github.com/apache/spark/commit/129b6acc5a24c7ef48f94e407c91575645cd46b2).


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    @hvanhovell @cloud-fan A SQL config was added to control codegen/interpreted for test. Please let me know if you have any comment on current approach. Thanks.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    Test FAILed.
    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/3171/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r186995265
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_OBJECT_FALLBACK)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    + * implementations. This tries to create codegen object first, if any compile error happens,
    + * it fallbacks to interpreted version.
    + */
    +abstract class CodegenObjectFactory[IN, OUT] {
    +
    +  def createObject(in: IN): OUT = {
    +    // We are allowed to choose codegen-only or no-codegen modes if under tests.
    --- End diff --
    
    So do we want to have this conf for not only test but also production?


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    I think we have a general problem with passing configs to code generators. For this PR, let's make it simple and only use the conf in tests. We are fine in tests because tests create these code generators in driver and we can access `SQLConf` directly.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    @cloud-fan @rednaxelafx Accessing confs are now simpler. Please review this again. Thanks.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90545 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90545/testReport)** for PR 21106 at commit [`129b6ac`](https://github.com/apache/spark/commit/129b6acc5a24c7ef48f94e407c91575645cd46b2).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #90594 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/90594/testReport)** for PR 21106 at commit [`de88f88`](https://github.com/apache/spark/commit/de88f88be90c6248113311667ec57beea14768b3).
     * 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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3205/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r186580919
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_OBJECT_FALLBACK)
    +      CodegenObjectFactoryMode.withName(config)
    --- End diff --
    
    This SQL config can only be used for unit test against codegen and interpreted unsafe projection.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3254/
    Test PASSed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

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


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    **[Test build #89615 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/89615/testReport)** for PR 21106 at commit [`36f90cf`](https://github.com/apache/spark/commit/36f90cfe0cacff8362dc9546432dbc6a0a391ba4).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `abstract class CodegenObjectFactory[IN, OUT] `


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    @hvanhovell Any more comments on the current design? If not, I will apply this to all places that we create unsafe projection.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    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/3453/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r186629667
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala ---
    @@ -108,7 +108,31 @@ abstract class UnsafeProjection extends Projection {
       override def apply(row: InternalRow): UnsafeRow
     }
     
    -trait UnsafeProjectionCreator {
    +/**
    + * The factory object for `UnsafeProjection`.
    + */
    +object UnsafeProjection extends CodegenObjectFactory[Seq[Expression], UnsafeProjection] {
    --- End diff --
    
    seems to make it a class is a good idea, we can set default valule like
    ```
    class UnsafeProjection(mode: CodegenObjectFactoryMode = CodegenObjectFactoryMode.currentMode)
    ```


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL] Add fallback generator for UnsafeProj...

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

    https://github.com/apache/spark/pull/21106
  
    Test FAILed.
    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/3327/
    Test FAILed.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    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/2516/
    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 #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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/21106#discussion_r187897086
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodeGeneratorWithInterpretedFallback.scala ---
    @@ -0,0 +1,80 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.util.Utils
    +
    +/**
    + * Catches compile error during code generation.
    + */
    +object CodegenError {
    +  def unapply(throwable: Throwable): Option[Exception] = throwable match {
    +    case e: InternalCompilerException => Some(e)
    +    case e: CompileException => Some(e)
    +    case _ => None
    +  }
    +}
    +
    +/**
    + * Defines values for `SQLConf` config of fallback mode. Use for test only.
    + */
    +object CodegenObjectFactoryMode extends Enumeration {
    +  val AUTO, CODEGEN_ONLY, NO_CODEGEN = Value
    +
    +  def currentMode: CodegenObjectFactoryMode.Value = {
    +    // If we weren't on task execution, accesses that config.
    +    if (TaskContext.get == null) {
    +      val config = SQLConf.get.getConf(SQLConf.CODEGEN_FACTORY_MODE)
    +      CodegenObjectFactoryMode.withName(config)
    +    } else {
    +      CodegenObjectFactoryMode.AUTO
    +    }
    +  }
    +}
    +
    +/**
    + * A factory which can be used to create objects that have both codegen and interpreted
    --- End diff --
    
    the comment also needs update.


---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

    https://github.com/apache/spark/pull/21106
  
    I tried to unify this class with `UnsafeProjectionCreator`. So there is no more `UnsafeProjectionCreator` trait.
    
    Without the trait `UnsafeProjectionCreator`, one problem is we can't easily test both against `UnsafeProjection` and `InterpretedUnsafeProjection` objects with the same interface of `UnsafeProjectionCreator` (e.g., `UnsafeRowConverterSuite`).
    
    For test, I think we still need to test codegen and interpreted unsafe projection implementations individually as `UnsafeRowConverterSuite` does.



---

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


[GitHub] spark issue #21106: [SPARK-23711][SQL][WIP] Add fallback logic for UnsafePro...

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

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


---

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


[GitHub] spark pull request #21106: [SPARK-23711][SQL][WIP] Add fallback logic for Un...

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

    https://github.com/apache/spark/pull/21106#discussion_r182918616
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CodegenObjectFactory.scala ---
    @@ -0,0 +1,63 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.codehaus.commons.compiler.CompileException
    +import org.codehaus.janino.InternalCompilerException
    +
    +object CodegenObjectFactory {
    --- End diff --
    
    This looks good to me, except that I think `UnsafeProjectionCreator` should still support `UnsafeProjectionCreator`'s APIs. So we can replace all usage of `UnsafeProjection` with `UnsafeProjectionCreator`.


---

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