File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -339,18 +339,13 @@ class SqlParser extends AbstractSparkSQLParser {
339339 | floatLit ^^ { f => Literal (f.toDouble) }
340340 )
341341
342- private val longMax = BigDecimal (s " ${Long .MaxValue }" )
343- private val longMin = BigDecimal (s " ${Long .MinValue }" )
344- private val intMax = BigDecimal (s " ${Int .MaxValue }" )
345- private val intMin = BigDecimal (s " ${Int .MinValue }" )
346-
347342 private def toNarrowestIntegerType (value : String ) = {
348343 val bigIntValue = BigDecimal (value)
349344
350345 bigIntValue match {
351- case v if v < longMin || v > longMax => v
352- case v if v < intMin || v > intMax => v.toLong
353- case v => v.toInt
346+ case v if bigIntValue.isValidInt => v.toIntExact
347+ case v if bigIntValue.isValidLong => v.toLongExact
348+ case v => v
354349 }
355350 }
356351
You can’t perform that action at this time.
0 commit comments