@@ -22,6 +22,7 @@ import java.util.Comparator
2222import scala .collection .mutable
2323import scala .reflect .ClassTag
2424
25+ import org .apache .spark .SparkException .internalError
2526import org .apache .spark .sql .catalyst .InternalRow
2627import org .apache .spark .sql .catalyst .analysis .{TypeCheckResult , TypeCoercion , UnresolvedAttribute , UnresolvedSeed }
2728import 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