Skip to content

Commit b8d44fa

Browse files
committed
Address PR comments
1 parent cd7dd84 commit b8d44fa

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import java.util.Comparator
2222
import scala.collection.mutable
2323
import scala.reflect.ClassTag
2424

25+
import org.apache.spark.SparkException.internalError
2526
import org.apache.spark.sql.catalyst.InternalRow
2627
import org.apache.spark.sql.catalyst.analysis.{TypeCheckResult, TypeCoercion, UnresolvedAttribute, UnresolvedSeed}
2728
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.DataTypeMismatch
@@ -3457,21 +3458,21 @@ object Sequence {
34573458
throw new ArithmeticException("Long overflow (Long.MinValue / -1)")
34583459
}
34593460
val len = if (stop == start) 1L else Math.addExact(1L, (delta / estimatedStep.toLong))
3460-
require(
3461-
len <= MAX_ROUNDED_ARRAY_LENGTH,
3462-
s"Too long sequence: $len. Should be <= $MAX_ROUNDED_ARRAY_LENGTH"
3463-
)
3461+
if (len > MAX_ROUNDED_ARRAY_LENGTH) {
3462+
throw new IllegalArgumentException(s"Too long sequence: $len. Should be <= " +
3463+
s"$MAX_ROUNDED_ARRAY_LENGTH")
3464+
}
34643465
len.toInt
34653466
} catch {
34663467
// We handle overflows in the previous try block by raising an appropriate exception.
34673468
case _: ArithmeticException =>
34683469
val safeLen =
34693470
BigInt(1) + (BigInt(stop.toLong) - BigInt(start.toLong)) / BigInt(estimatedStep.toLong)
3470-
require(
3471-
safeLen <= MAX_ROUNDED_ARRAY_LENGTH,
3472-
s"Too long sequence: $safeLen. Should be <= $MAX_ROUNDED_ARRAY_LENGTH"
3473-
)
3474-
throw new RuntimeException("Unreachable code reached.")
3471+
if (safeLen > MAX_ROUNDED_ARRAY_LENGTH) {
3472+
throw new IllegalArgumentException(s"Too long sequence: $safeLen. Should be <= " +
3473+
s"$MAX_ROUNDED_ARRAY_LENGTH")
3474+
}
3475+
throw internalError("Unreachable code reached.")
34753476
case e: Exception => throw e
34763477
}
34773478
}

0 commit comments

Comments
 (0)