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

    https://github.com/apache/spark/pull/13909#discussion_r88427617
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvalHelper.scala
 ---
    @@ -42,15 +42,55 @@ trait ExpressionEvalHelper extends 
GeneratorDrivenPropertyChecks {
         
InternalRow.fromSeq(values.map(CatalystTypeConverters.convertToCatalyst))
       }
     
    +  protected def convertToCatalystUnsafe(a: Any): Any = a match {
    +    case arr: Array[Boolean] => UnsafeArrayData.fromPrimitiveArray(arr)
    +    case arr: Array[Byte] => UnsafeArrayData.fromPrimitiveArray(arr)
    +    case arr: Array[Short] => UnsafeArrayData.fromPrimitiveArray(arr)
    +    case arr: Array[Int] => UnsafeArrayData.fromPrimitiveArray(arr)
    +    case arr: Array[Long] => UnsafeArrayData.fromPrimitiveArray(arr)
    +    case arr: Array[Float] => UnsafeArrayData.fromPrimitiveArray(arr)
    +    case arr: Array[Double] => UnsafeArrayData.fromPrimitiveArray(arr)
    +    case other => CatalystTypeConverters.convertToCatalyst(other)
    +  }
    +
       protected def checkEvaluation(
           expression: => Expression, expected: Any, inputRow: InternalRow = 
EmptyRow): Unit = {
         val serializer = new JavaSerializer(new SparkConf()).newInstance
         val expr: Expression = 
serializer.deserialize(serializer.serialize(expression))
    -    val catalystValue = CatalystTypeConverters.convertToCatalyst(expected)
    +    // No codegen version expects GenericArrayData
    +    val catalystValue = expected match {
    +      case arr: Array[Byte] if expression.dataType == BinaryType => arr
    +      case arr: Array[_] => new 
GenericArrayData(arr.map(CatalystTypeConverters.convertToCatalyst))
    --- End diff --
    
    I have just changed `Array[Any]` to `Array[_]` in 
`CatalystTypeConverters.convertToCatalyst` and remove line 63 in 
`ExpressionEvalHelper.scala`. Then, I ran some test cases.
    
    I realized `LiteralExpressionSuite."binary literals" is failed. Here is a 
part of the log.
    ```java
    Incorrect evaluation (codegen off): [], actual: [], expected: [B@3ef41c66
    ScalaTestFailureLocation: 
org.apache.spark.sql.catalyst.expressions.ExpressionEvalHelper$class at 
(ExpressionEvalHelper.scala:153)
    org.scalatest.exceptions.TestFailedException: Incorrect evaluation (codegen 
off): [], actual: [], expected: [B@3ef41c66
        at 
org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:495)
        at 
org.scalatest.FunSuite.newAssertionFailedException(FunSuite.scala:1555)
        at org.scalatest.Assertions$class.fail(Assertions.scala:1328)
        at org.scalatest.FunSuite.fail(FunSuite.scala:1555)
        at 
org.apache.spark.sql.catalyst.expressions.ExpressionEvalHelper$class.checkEvaluationWithoutCodegen(ExpressionEvalHelper.scala:153)
        at 
org.apache.spark.sql.catalyst.expressions.LiteralExpressionSuite.checkEvaluationWithoutCodegen(LiteralExpressionSuite.scala:30)
    ...
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to