MaxGekk commented on code in PR #38394:
URL: https://github.com/apache/spark/pull/38394#discussion_r1006432848
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TimeWindow.scala:
##########
@@ -114,18 +115,48 @@ case class TimeWindow(
val dataTypeCheck = super.checkInputDataTypes()
if (dataTypeCheck.isSuccess) {
if (windowDuration <= 0) {
- return TypeCheckFailure(s"The window duration ($windowDuration) must
be greater than 0.")
+ return DataTypeMismatch(
+ errorSubClass = "VALUE_OUT_OF_RANGE",
+ messageParameters = Map(
+ "exprName" -> toSQLId("window_duration"),
+ "valueRange" -> s"(0, ${Long.MaxValue}]",
+ "currentValue" -> toSQLValue(windowDuration, LongType)
+ )
+ )
}
if (slideDuration <= 0) {
- return TypeCheckFailure(s"The slide duration ($slideDuration) must be
greater than 0.")
+ return DataTypeMismatch(
+ errorSubClass = "VALUE_OUT_OF_RANGE",
+ messageParameters = Map(
+ "exprName" -> toSQLId("slide_duration"),
+ "valueRange" -> s"(0, ${Long.MaxValue}]",
+ "currentValue" -> toSQLValue(slideDuration, LongType)
+ )
+ )
}
if (slideDuration > windowDuration) {
- return TypeCheckFailure(s"The slide duration ($slideDuration) must be
less than or equal" +
- s" to the windowDuration ($windowDuration).")
+ return DataTypeMismatch(
+ errorSubClass = "PARAMETER_CONSTRAINT_VIOLATION",
+ messageParameters = Map(
+ "leftExprName" -> toSQLId("slide_duration"),
+ "leftExprValue" -> toSQLValue(slideDuration, LongType),
+ "constraint" -> "<=",
+ "rightExprName" -> toSQLId("window_duration"),
+ "rightExprValue" -> toSQLValue(windowDuration, LongType)
+ )
+ )
}
if (startTime.abs >= slideDuration) {
- return TypeCheckFailure(s"The absolute value of start time
($startTime) must be less " +
- s"than the slideDuration ($slideDuration).")
+ return DataTypeMismatch(
+ errorSubClass = "PARAMETER_CONSTRAINT_VIOLATION",
+ messageParameters = Map(
+ "leftExprName" -> toSQLId("start_time"),
Review Comment:
Precisely speaking, it should be `abs(start_time)`
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TimeWindow.scala:
##########
@@ -114,18 +115,48 @@ case class TimeWindow(
val dataTypeCheck = super.checkInputDataTypes()
if (dataTypeCheck.isSuccess) {
if (windowDuration <= 0) {
- return TypeCheckFailure(s"The window duration ($windowDuration) must
be greater than 0.")
+ return DataTypeMismatch(
+ errorSubClass = "VALUE_OUT_OF_RANGE",
+ messageParameters = Map(
+ "exprName" -> toSQLId("window_duration"),
+ "valueRange" -> s"(0, ${Long.MaxValue}]",
+ "currentValue" -> toSQLValue(windowDuration, LongType)
+ )
+ )
}
if (slideDuration <= 0) {
- return TypeCheckFailure(s"The slide duration ($slideDuration) must be
greater than 0.")
+ return DataTypeMismatch(
+ errorSubClass = "VALUE_OUT_OF_RANGE",
+ messageParameters = Map(
+ "exprName" -> toSQLId("slide_duration"),
+ "valueRange" -> s"(0, ${Long.MaxValue}]",
+ "currentValue" -> toSQLValue(slideDuration, LongType)
+ )
+ )
}
if (slideDuration > windowDuration) {
- return TypeCheckFailure(s"The slide duration ($slideDuration) must be
less than or equal" +
- s" to the windowDuration ($windowDuration).")
+ return DataTypeMismatch(
+ errorSubClass = "PARAMETER_CONSTRAINT_VIOLATION",
+ messageParameters = Map(
+ "leftExprName" -> toSQLId("slide_duration"),
+ "leftExprValue" -> toSQLValue(slideDuration, LongType),
+ "constraint" -> "<=",
+ "rightExprName" -> toSQLId("window_duration"),
+ "rightExprValue" -> toSQLValue(windowDuration, LongType)
+ )
+ )
}
if (startTime.abs >= slideDuration) {
- return TypeCheckFailure(s"The absolute value of start time
($startTime) must be less " +
- s"than the slideDuration ($slideDuration).")
+ return DataTypeMismatch(
+ errorSubClass = "PARAMETER_CONSTRAINT_VIOLATION",
+ messageParameters = Map(
+ "leftExprName" -> toSQLId("start_time"),
+ "leftExprValue" -> toSQLValue(startTime, LongType),
Review Comment:
Actually, `startTime.abs`
--
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]