Github user adrian-wang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2344#discussion_r18704345
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
 ---
    @@ -220,20 +220,44 @@ trait HiveTypeCoercion {
           case a: BinaryArithmetic if a.right.dataType == StringType =>
             a.makeCopy(Array(a.left, Cast(a.right, DoubleType)))
     
    +      // we should cast all timestamp/date/string compare into string 
compare
    +      case p: BinaryPredicate if p.left.dataType == StringType
    +        && p.right.dataType == DateType =>
    +        p.makeCopy(Array(p.left, Cast(p.right, StringType)))
    +      case p: BinaryPredicate if p.left.dataType == DateType
    +        && p.right.dataType == StringType =>
    +        p.makeCopy(Array(Cast(p.left, StringType), p.right))
           case p: BinaryPredicate if p.left.dataType == StringType
             && p.right.dataType == TimestampType =>
    -        p.makeCopy(Array(Cast(p.left, TimestampType), p.right))
    +        p.makeCopy(Array(p.left, Cast(p.right, StringType)))
           case p: BinaryPredicate if p.left.dataType == TimestampType
             && p.right.dataType == StringType =>
    -        p.makeCopy(Array(p.left, Cast(p.right, TimestampType)))
    +        p.makeCopy(Array(Cast(p.left, StringType), p.right))
    +      case p: BinaryPredicate if p.left.dataType == TimestampType
    +        && p.right.dataType == DateType =>
    +        p.makeCopy(Array(Cast(p.left, StringType), Cast(p.right, 
StringType)))
    +      case p: BinaryPredicate if p.left.dataType == DateType
    +        && p.right.dataType == TimestampType =>
    +        p.makeCopy(Array(Cast(p.left, StringType), Cast(p.right, 
StringType)))
     
           case p: BinaryPredicate if p.left.dataType == StringType && 
p.right.dataType != StringType =>
             p.makeCopy(Array(Cast(p.left, DoubleType), p.right))
           case p: BinaryPredicate if p.left.dataType != StringType && 
p.right.dataType == StringType =>
             p.makeCopy(Array(p.left, Cast(p.right, DoubleType)))
     
    -      case i @ In(a,b) if a.dataType == TimestampType && 
b.forall(_.dataType == StringType) =>
    -        i.makeCopy(Array(a,b.map(Cast(_,TimestampType))))
    +      case i @ In(a, b) if a.dataType == DateType && b.forall(_.dataType 
== StringType) =>
    +        i.makeCopy(Array(Cast(a, StringType), b))
    +      case i @ In(a, b) if a.dataType == TimestampType && 
b.forall(_.dataType == StringType) =>
    +        i.makeCopy(Array(Cast(a, StringType), b))
    +      case i @ In(a, b) if a.dataType == DateType && b.forall(_.dataType 
== TimestampType) =>
    +        i.makeCopy(Array(Cast(a, StringType), b.map(Cast(_, StringType))))
    +      case i @ In(a, b) if a.dataType == TimestampType && 
b.forall(_.dataType == DateType) =>
    +        i.makeCopy(Array(Cast(a, StringType), b.map(Cast(_, StringType))))
    +      case i @ In(a, b) if a.dataType == DateType && b.forall(_.dataType 
== DateType) =>
    +        i.makeCopy(Array(Cast(a, StringType), b.map(Cast(_, StringType))))
    +      case i @ In(a, b) if a.dataType == TimestampType && 
b.forall(_.dataType == TimestampType) =>
    +        i.makeCopy(Array(Cast(a, StringType), b.map(Cast(_, StringType))))
    --- End diff --
    
    Using long value of `java.sql.Date` is way too far from Hive. I have 
discussed with @chenghao-intel and We think we can leave it as it is and fix 
the ordering and comparing in a separate PR.


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