cloud-fan commented on a change in pull request #33115:
URL: https://github.com/apache/spark/pull/33115#discussion_r659813841
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/types/AbstractDataType.scala
##########
@@ -217,3 +217,14 @@ private[sql] abstract class FractionalType extends
NumericType {
private[sql] val fractional: Fractional[InternalType]
private[sql] val asIntegral: Integral[InternalType]
}
+
+private[sql] object AnyTimestampType extends AbstractDataType with
Serializable {
Review comment:
Can we use a type collection like `TypeCollection.NumericAndInterval`?
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/types/AbstractDataType.scala
##########
@@ -217,3 +217,14 @@ private[sql] abstract class FractionalType extends
NumericType {
private[sql] val fractional: Fractional[InternalType]
private[sql] val asIntegral: Integral[InternalType]
}
+
+private[sql] object AnyTimestampType extends AbstractDataType with
Serializable {
Review comment:
Are we going to use `AnyTimestampType` everywhere and remove
`AllTimestampTypes`?
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
##########
@@ -386,8 +386,8 @@ class Analyzer(override val catalogManager: CatalogManager)
DatetimeSub(l, r, DateAddInterval(l, UnaryMinus(r, f), ansiEnabled
= f))
case (_, CalendarIntervalType | _: DayTimeIntervalType) =>
Cast(DatetimeSub(l, r, TimeAdd(l, UnaryMinus(r, f))), l.dataType)
- case (TimestampType, _) => SubtractTimestamps(l, r)
- case (_, TimestampType) => SubtractTimestamps(l, r)
+ case (TimestampType | TimestampWithoutTZType, _) =>
SubtractTimestamps(l, r)
Review comment:
Can this be `case (AnyTimestampType(), _)`?
##########
File path: sql/core/src/test/resources/sql-tests/inputs/datetime.sql
##########
@@ -78,6 +78,16 @@ select timestamp'2019-10-06 10:11:12.345678' -
date'2020-01-01';
select timestamp'2019-10-06 10:11:12.345678' - null;
select null - timestamp'2019-10-06 10:11:12.345678';
+-- subtract timestamps without time zone
+select date'2020-01-01' - to_timestamp_ntz('2019-10-06 10:11:12.345678');
+select to_timestamp_ntz('2019-10-06 10:11:12.345678') - date'2020-01-01';
+select to_timestamp_ntz('2019-10-06 10:11:12.345678') - null;
+select null - to_timestamp_ntz('2019-10-06 10:11:12.345678');
+select to_timestamp_ntz('2019-10-07 10:11:12.345678') -
to_timestamp_ntz('2019-10-06 10:11:12.345677');
+select to_timestamp_ntz('2019-10-06 10:11:12.345677') -
to_timestamp_ntz('2019-10-07 10:11:12.345678');
+select to_timestamp_ntz('2019-10-07 10:11:12.345678') - timestamp'2019-10-06
10:11:12.345678';
+select timestamp'2019-10-06 10:11:12.345678' - to_timestamp_ntz('2019-10-07
10:11:12.345678');
Review comment:
let's use `to_timestamp` in the test, in case we make `timestamp'xxx'`
return TIMESTAMP NTZ later.
--
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]