dongjoon-hyun commented on a change in pull request #25220: [SPARK-28459][SQL]
Add `make_timestamp` function
URL: https://github.com/apache/spark/pull/25220#discussion_r308008776
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala
##########
@@ -928,4 +928,35 @@ class DateExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
checkEvaluation(MakeDate(Literal(2019), Literal(13), Literal(19)), null)
checkEvaluation(MakeDate(Literal(2019), Literal(7), Literal(32)), null)
}
+
+ test("creating values of TimestampType via make_timestamp") {
+ val makeTimestampExpr = MakeTimestamp(
+ Literal(2013), Literal(7), Literal(15), Literal(8), Literal(15),
Literal(23.5),
+ Some(Literal(ZoneId.systemDefault().getId)))
+ val expected = Timestamp.valueOf("2013-7-15 8:15:23.5")
+ checkEvaluation(makeTimestampExpr, expected)
+ checkEvaluation(makeTimestampExpr.copy(timezone = None), expected)
+
+ checkEvaluation(makeTimestampExpr.copy(year = Literal.create(null,
IntegerType)), null)
+ checkEvaluation(makeTimestampExpr.copy(year = Literal(Int.MaxValue)), null)
+
+ checkEvaluation(makeTimestampExpr.copy(month = Literal.create(null,
IntegerType)), null)
+ checkEvaluation(makeTimestampExpr.copy(month = Literal(13)), null)
+
+ checkEvaluation(makeTimestampExpr.copy(day = Literal.create(null,
IntegerType)), null)
+ checkEvaluation(makeTimestampExpr.copy(day = Literal(32)), null)
+
+ checkEvaluation(makeTimestampExpr.copy(hour = Literal.create(null,
IntegerType)), null)
+ checkEvaluation(makeTimestampExpr.copy(hour = Literal(25)), null)
+
+ checkEvaluation(makeTimestampExpr.copy(min = Literal.create(null,
IntegerType)), null)
+ checkEvaluation(makeTimestampExpr.copy(min = Literal(65)), null)
+
+ checkEvaluation(makeTimestampExpr.copy(sec = Literal.create(null,
DoubleType)), null)
+ checkEvaluation(makeTimestampExpr.copy(sec = Literal(70.5)), null)
Review comment:
This test case should be updated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]