File tree Expand file tree Collapse file tree 2 files changed +8
-24
lines changed
catalyst/src/main/scala/org/apache/spark/sql/catalyst/json
core/src/test/scala/org/apache/spark/sql/execution/datasources/json Expand file tree Collapse file tree 2 files changed +8
-24
lines changed Original file line number Diff line number Diff line change @@ -126,12 +126,10 @@ class JacksonParser(
126126 case VALUE_STRING =>
127127 // Special case handling for NaN and Infinity.
128128 parser.getText match {
129- case " NaN" | " +NaN" | " -NaN" => Float .NaN
130- case " +INF" | " INF" | " +Infinity" | " Infinity" => Float .PositiveInfinity
131- case " -INF" | " -Infinity" => Float .NegativeInfinity
132- case other => Try (other.toFloat).getOrElse {
133- throw new RuntimeException (s " Cannot parse $other as FloatType. " )
134- }
129+ case " NaN" => Float .NaN
130+ case " Infinity" => Float .PositiveInfinity
131+ case " -Infinity" => Float .NegativeInfinity
132+ case other => throw new RuntimeException (s " Cannot parse $other as FloatType. " )
135133 }
136134 }
137135
@@ -143,12 +141,10 @@ class JacksonParser(
143141 case VALUE_STRING =>
144142 // Special case handling for NaN and Infinity.
145143 parser.getText match {
146- case " NaN" | " +NaN" | " -NaN" => Double .NaN
147- case " +INF" | " INF" | " +Infinity" | " Infinity" => Double .PositiveInfinity
148- case " -INF" | " -Infinity" => Double .NegativeInfinity
149- case other => Try (other.toDouble).getOrElse {
150- throw new RuntimeException (s " Cannot parse $other as DoubleType. " )
151- }
144+ case " NaN" => Double .NaN
145+ case " Infinity" => Double .PositiveInfinity
146+ case " -Infinity" => Double .NegativeInfinity
147+ case other => throw new RuntimeException (s " Cannot parse $other as DoubleType. " )
152148 }
153149 }
154150
Original file line number Diff line number Diff line change @@ -1992,25 +1992,13 @@ class JsonSuite extends QueryTest with SharedSQLContext with TestJsonData {
19921992
19931993 test(" SPARK-18772: Parse special floats correctly" ) {
19941994 val jsons = Seq (
1995- """ {"a": "+INF"}""" ,
1996- """ {"a": "INF"}""" ,
1997- """ {"a": "-INF"}""" ,
19981995 """ {"a": "NaN"}""" ,
1999- """ {"a": "+NaN"}""" ,
2000- """ {"a": "-NaN"}""" ,
20011996 """ {"a": "Infinity"}""" ,
2002- """ {"a": "+Infinity"}""" ,
20031997 """ {"a": "-Infinity"}""" )
20041998
20051999 // positive cases
20062000 val checks : Seq [Double => Boolean ] = Seq (
2007- _.isPosInfinity,
2008- _.isPosInfinity,
2009- _.isNegInfinity,
2010- _.isNaN,
20112001 _.isNaN,
2012- _.isNaN,
2013- _.isPosInfinity,
20142002 _.isPosInfinity,
20152003 _.isNegInfinity)
20162004
You can’t perform that action at this time.
0 commit comments