Github user chuxi commented on the pull request:

    https://github.com/apache/spark/pull/2084#issuecomment-53189498
  
    I think CAST is the better choice(Compared with the NO CAST method). It is 
implemented in the 
    
    case class Cast(child: Expression, dataType: DataType) extends 
UnaryExpression
    
    with a lot of dataTypes, including timestampType
    
    Besides, if you want to implement "modify Comparable expression evaluation 
so the the explicit casting is not necessary", you need to tell apart a String 
whether it is a TimeStamp format. And then modify the last line code:
    
    ```
    protected lazy val literal: Parser[Literal] =
        numericLit ^^ {
          case i if i.toLong > Int.MaxValue => Literal(i.toLong)
          case i => Literal(i.toInt)
        } |
        NULL ^^^ Literal(null, NullType) |
        floatLit ^^ {case f => Literal(f.toDouble) } |
        stringLit ^^ {case s => Literal(s, StringType) }
    ```
    
    Literal supports TimeStamp too.
    
    stringLit ^^ { case s => try try Timestamp.valueOf(s) catch { Literal(s, 
StringType) }


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