MaxGekk commented on a change in pull request #32311:
URL: https://github.com/apache/spark/pull/32311#discussion_r619780862
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionExpressionsSuite.scala
##########
@@ -934,12 +1071,25 @@ class CollectionExpressionsSuite extends SparkFunSuite
with ExpressionEvalHelper
EmptyRow,
s"sequence boundaries: 0 to 2678400000000 by -${28 * MICROS_PER_DAY}")
+ checkExceptionInExpression[IllegalArgumentException](
+ new Sequence(
+ Literal(Date.valueOf("1970-01-01")),
+ Literal(Date.valueOf("1970-02-01")),
+ Literal(Period.ofMonths(-1))),
+ EmptyRow,
+ s"sequence boundaries: 0 to 2678400000000 by -${28 * MICROS_PER_DAY}")
Review comment:
ok. I see.
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -2723,28 +2745,94 @@ object Sequence {
}
}
+ private class PeriodSequenceImpl[T: ClassTag]
+ (dt: IntegralType, scale: Long, fromLong: Long => T, zoneId: ZoneId)
+ (implicit num: Integral[T]) extends InternalSequenceBase(dt, scale,
fromLong, zoneId) {
Review comment:
ok. Let's use `timestampAddInterval` since we don't have an example that
could demonstrate any issues caused by `timestampAddInterval()`.
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -2484,8 +2484,8 @@ case class Flatten(child: Expression) extends
UnaryExpression with NullIntoleran
The start and stop expressions must resolve to the same type.
If start and stop expressions resolve to the 'date' or 'timestamp' type
- then the step expression must resolve to the 'interval' type, otherwise
to the same type
- as the start and stop expressions.
+ then the step expression must resolve to the 'interval' or 'year-month'
or 'day-time' type,
Review comment:
nit:
'year-month' -> 'year-month interval'
'day-time' -> 'day-time interval'
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala
##########
@@ -2561,29 +2568,50 @@ case class Sequence(
TypeCheckResult.TypeCheckSuccess
} else {
TypeCheckResult.TypeCheckFailure(
- s"$prettyName only supports integral, timestamp or date types")
+ s"""
+ |$prettyName uses the wrong parameter type. The parameter type must
conform to:
+ |1. The start and stop expressions must resolve to the same type.
+ |2. If start and stop expressions resolve to the 'date' or
'timestamp' type
+ |then the step expression must resolve to the 'interval' or
'year-month' or
Review comment:
Could you call `YearMonthIntervalType.typeName`
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]