PHILO-HE commented on code in PR #8737:
URL: https://github.com/apache/incubator-gluten/pull/8737#discussion_r2094768503
##########
gluten-ut/spark32/src/test/scala/org/apache/spark/sql/catalyst/expressions/GlutenCastSuite.scala:
##########
@@ -270,6 +270,26 @@ class GlutenCastSuite extends CastSuite with
GlutenTestsTrait {
checkEvaluation(cast(Literal.create(null, IntegerType), ShortType), null)
}
+ test("cast from boolean to timestamp") {
+ val originalDefaultTz = TimeZone.getDefault
+ try {
+ withSQLConf(
+ SQLConf.SESSION_LOCAL_TIMEZONE.key -> UTC_OPT.get
+ ) {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
+ checkEvaluation(
+ cast(true, TimestampType, UTC_OPT),
+ Timestamp.valueOf("1970-01-01 00:00:00.000001"))
+
+ checkEvaluation(
+ cast(false, TimestampType, UTC_OPT),
+ Timestamp.valueOf("1970-01-01 00:00:00"))
Review Comment:
new Timestamp(0)
##########
gluten-ut/spark32/src/test/scala/org/apache/spark/sql/catalyst/expressions/GlutenCastSuite.scala:
##########
@@ -270,6 +270,26 @@ class GlutenCastSuite extends CastSuite with
GlutenTestsTrait {
checkEvaluation(cast(Literal.create(null, IntegerType), ShortType), null)
}
+ test("cast from boolean to timestamp") {
+ val originalDefaultTz = TimeZone.getDefault
+ try {
+ withSQLConf(
+ SQLConf.SESSION_LOCAL_TIMEZONE.key -> UTC_OPT.get
+ ) {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
+ checkEvaluation(
+ cast(true, TimestampType, UTC_OPT),
+ Timestamp.valueOf("1970-01-01 00:00:00.000001"))
Review Comment:
Can we just use `new Timestamp(1)`? Then, no need to parse timestamp from
string and we can remove the above timezone setting:
`SQLConf.SESSION_LOCAL_TIMEZONE.key -> UTC_OPT.get
TimeZone.setDefault(TimeZone.getTimeZone("UTC"))`
Cast bool to timestamp doesn't need timezone.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]