cloud-fan commented on code in PR #56746:
URL: https://github.com/apache/spark/pull/56746#discussion_r3749310823
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala:
##########
@@ -2053,16 +2053,22 @@ case class Slice(x: Expression, start: Expression,
length: Expression)
val lengthInt = lengthVal.asInstanceOf[Int]
val arr = xVal.asInstanceOf[ArrayData]
val startIndex = ArrayExpressionUtils.sliceStartIndex(startInt,
arr.numElements(), prettyName)
- if (lengthInt < 0) {
- throw
QueryExecutionErrors.unexpectedValueForLengthInFunctionError(prettyName,
lengthInt)
- }
+ // Resolve (and validate) the result length via the shared helper,
mirroring the codegen path.
+ // Besides rejecting a negative length, this clamps the length to the
elements remaining after
+ // `startIndex`. For an in-range `startIndex` that keeps `startIndex +
resLength` from
Review Comment:
The current relative clause makes `startIndex` the subject of `keeps`, so
the sentence is incomplete.
```suggestion
// `startIndex`. For an in-range `startIndex`, this clamp keeps
`startIndex + resLength` from
```
--
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]