Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/6988#discussion_r35324086
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala
---
@@ -246,4 +247,45 @@ class DateExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
}
}
+ test("datetime function current_date") {
+ val d0 = DateTimeUtils.millisToDays(System.currentTimeMillis())
+ val cd = CurrentDate().eval(EmptyRow).asInstanceOf[Int]
+ val d1 = DateTimeUtils.millisToDays(System.currentTimeMillis())
+ assert(d0 <= cd && cd <= d1 && d1 - d0 <= 1)
+ }
+
+ test("datetime function current_timestamp") {
+ val ct =
DateTimeUtils.toJavaTimestamp(CurrentTimestamp().eval(EmptyRow).asInstanceOf[Long])
+ val t1 = System.currentTimeMillis()
+ assert(math.abs(t1 - ct.getTime) < 5000)
+ }
+
+ test("function to_date") {
+ checkResult(ToDate(Literal("2015-07-22")), ToDate(Literal("2015-07-22
23:59:59")))
+ checkResult(
+ ToDate(Literal("2015-07-22")),
ToDate(Literal(Timestamp.valueOf("2015-07-22 23:59:59"))))
+ checkResult(ToDate(Literal("2015-07-22")), Date.valueOf("2015-07-22"))
+ }
+
+ test("function trunc") {
+ checkResult(
--- End diff --
Seems this will not trigger the codegen projections, you probably need to
use the `checkEvaluation` instead.
---
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]