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

    https://github.com/apache/spark/pull/16476#discussion_r95060436
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ConditionalExpressionSuite.scala
 ---
    @@ -137,4 +139,48 @@ class ConditionalExpressionSuite extends SparkFunSuite 
with ExpressionEvalHelper
         checkEvaluation(CaseKeyWhen(c6, Seq(c5, c2, c4, c3)), null, row)
         checkEvaluation(CaseKeyWhen(literalNull, Seq(c2, c5, c1, c6)), null, 
row)
       }
    +
    +  test("case field") {
    +    val str1 = Literal("花花世界")
    +    val str2 = Literal("a")
    +    val str3 = Literal("b")
    +    val str4 = Literal("")
    +    val str5 = Literal("999")
    +    val strNull = Literal.create(null, StringType)
    +
    +    val bool1 = Literal(true)
    +    val bool2 = Literal(false)
    +
    +    val int1 = Literal(1)
    +    val int2 = Literal(2)
    +    val int3 = Literal(3)
    +    val int4 = Literal(999)
    +    val intNull = Literal.create(null, IntegerType)
    +
    +    val double1 = Literal(1.221)
    +    val double2 = Literal(1.222)
    +    val double3 = Literal(1.224)
    +
    +    val timeStamp1 = Literal(new Timestamp(2016, 12, 27, 14, 22, 1, 1))
    +    val timeStamp2 = Literal(new Timestamp(1988, 6, 3, 1, 1, 1, 1))
    +    val timeStamp3 = Literal(new Timestamp(1990, 6, 5, 1, 1, 1, 1))
    +
    +    val date1 = Literal(new Date(1949, 1, 1))
    +    val date2 = Literal(new Date(1979, 1, 1))
    +    val date3 = Literal(new Date(1989, 1, 1))
    +
    +    checkEvaluation(Field(Seq(str1, str2, str3, str1)), 3)
    +    checkEvaluation(Field(Seq(str2, str2, str2, str1)), 1)
    +    checkEvaluation(Field(Seq(str4, str4, str4, str1)), 1)
    +    checkEvaluation(Field(Seq(bool1, bool2, bool1, bool1)), 2)
    +    checkEvaluation(Field(Seq(int1, int2, int3, int1)), 3)
    +    checkEvaluation(Field(Seq(double2, double3, double1, double2)), 3)
    +    checkEvaluation(Field(Seq(timeStamp1, timeStamp2, timeStamp3, 
timeStamp1)), 3)
    +    checkEvaluation(Field(Seq(date1, date1, date2, date3)), 1)
    +    checkEvaluation(Field(Seq(int4, double3, str5, bool1, date1, 
timeStamp2, int4)), 6)
    +    checkEvaluation(Field(Seq(str5, str1, str2, str4)), 0)
    +    checkEvaluation(Field(Seq(int4, double3, str5, bool1, date1, 
timeStamp2, int3)), 0)
    +    checkEvaluation(Field(Seq(int1, strNull, intNull, bool1, date1, 
timeStamp2, int3)), 0)
    --- End diff --
    
    Line 180 is to test multi types of parameters;
    Line 181 is to test not found case;
    Line 182 is to test not found case when parameters are of multi types;
    Line 183 is to test null in parameter which has >=1 index
    I think maybe we should refer to Hive's field? In Hive, when not all 
arguments are numbers && not all arguments are strings, they are not compared 
as double.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to