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

    https://github.com/apache/spark/pull/22154#discussion_r234385204
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CodeGeneratorWithInterpretedFallbackSuite.scala
 ---
    @@ -17,17 +17,33 @@
     
     package org.apache.spark.sql.catalyst.expressions
     
    +import java.util.concurrent.ExecutionException
    +
     import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.catalyst.expressions.codegen.{CodeAndComment, 
CodeGenerator}
     import org.apache.spark.sql.catalyst.plans.PlanTestBase
     import org.apache.spark.sql.internal.SQLConf
    -import org.apache.spark.sql.types.{IntegerType, LongType}
    +import org.apache.spark.sql.types.IntegerType
     
     class CodeGeneratorWithInterpretedFallbackSuite extends SparkFunSuite with 
PlanTestBase {
     
    -  test("UnsafeProjection with codegen factory mode") {
    -    val input = Seq(LongType, IntegerType)
    -      .zipWithIndex.map(x => BoundReference(x._2, x._1, true))
    +  object FailedCodegenProjection
    +      extends CodeGeneratorWithInterpretedFallback[Seq[Expression], 
UnsafeProjection] {
    +
    +    override protected def createCodeGeneratedObject(in: Seq[Expression]): 
UnsafeProjection = {
    +      val invalidCode = new CodeAndComment("invalid code", Map.empty)
    +      // We assume this compilation throws an exception
    --- End diff --
    
    The suggested change is only for making this test suite cleaner, right? In 
that case I'd +1 with the suggestion of being able to clearly check we're 
catching the exception we know we're throwing.
    Would you like to submit a PR for it?
    
    > rather than returning `null`
    The intent is never to actually reach the null-return, but always cause an 
exception to be thrown at `CodeGenerator.compile()` and abruptly return to the 
caller with the exception. To make the compiler happy you'll have to have some 
definite-returning statement to end the function, so a useless null-return 
would probably have to be there anyway (since the compiler can't tell you'll 
always be throwing an exception unless you do a throw inline)


---

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

Reply via email to