Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/224#discussion_r11007623
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
 ---
    @@ -26,7 +26,186 @@ import org.apache.spark.sql.catalyst.types._
     /* Implicit conversions */
     import org.apache.spark.sql.catalyst.dsl.expressions._
     
    -class ExpressionEvaluationSuite extends FunSuite {
    +import org.apache.spark.sql.catalyst.types._
    +import org.apache.spark.sql.catalyst.dsl._
    +
    +
    +/**
    + * Root class of expression evaluation test
    + */
    +trait ExprEvalTest {
    +  type Execution = (Row => Row)
    +
    +  def engine: Execution
    +}
    +
    +case class InterpretExprEvalTest(exprs: Seq[Expression]) extends 
ExprEvalTest {
    +  override def engine: Execution = new Projection(exprs)
    +}
    +
    +class InterpretExpressionEvaluationSuite extends ExpressionEvaluationSuite 
{
    +  override def executor(exprs: Seq[Expression]) = 
InterpretExprEvalTest(exprs)
    +}
    +
    +trait ExpressionEvaluationSuite extends FunSuite {
    +  /**
    +   * The sub classes need to create the ExprEvalTest object 
    +   */
    +  def executor(exprs: Seq[Expression]): ExprEvalTest
    +  
    +  val data: Row = new GenericRow(Array(1, null, 1.0, true, 4, 5, null, 
"abcccd", "a%"))
    +
    +  // TODO add to DSL
    +  val c1 = BoundReference(0, AttributeReference("a", IntegerType)())
    +  val c2 = BoundReference(1, AttributeReference("b", IntegerType)())
    +  val c3 = BoundReference(2, AttributeReference("c", DoubleType)())
    +  val c4 = BoundReference(3, AttributeReference("d", BooleanType)())
    +  val c5 = BoundReference(4, AttributeReference("e", IntegerType)())
    +  val c6 = BoundReference(5, AttributeReference("f", IntegerType)())
    +  val c7 = BoundReference(6, AttributeReference("g", StringType)())
    +  val c8 = BoundReference(7, AttributeReference("h", StringType)())
    +  val c9 = BoundReference(8, AttributeReference("i", StringType)())
    +  
    +  /**
    +   * Compare each of the field if it equals the expected value.
    +   * 
    +   * expected is a sequence of (Any, Any), 
    +   * and the first element indicates:
    +   *   true:  the expected value is field is null
    +   *   false: the expected value is not null
    +   *   Exception Class: the expected exception class while computing the 
value 
    --- End diff --
    
    In the expression evaluation unit tests, some of the exceptions raised as 
expected, during the implementation, I was thinking to keep the Expressions 
creation / Expected Result / Computing independently in the simple framework 
design, because the expected exceptions are assumed to be defined dynamically 
by later, hence catching the exception first and then compare it with the 
expected one maybe more easier. 


---
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.
---

Reply via email to