File tree Expand file tree Collapse file tree
main/scala/org/apache/spark/sql/execution/datasources/json
test/scala/org/apache/spark/sql/execution/datasources/json Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,6 @@ object JSONOptions {
5959 allowNumericLeadingZeros =
6060 parameters.get(" allowNumericLeadingZeros" ).map(_.toBoolean).getOrElse(false ),
6161 allowNonNumericNumbers =
62- parameters.get(" allowNonNumericNumbers" ).map(_.toBoolean).getOrElse(true )
62+ parameters.get(" allowNonNumericNumbers" ).map(_.toBoolean).getOrElse(false )
6363 )
6464}
Original file line number Diff line number Diff line change @@ -100,18 +100,7 @@ object JacksonParser {
100100 parser.getFloatValue
101101
102102 case (VALUE_STRING , FloatType ) =>
103- // Special case handling for NaN and Infinity.
104- val value = parser.getText
105- val lowerCaseValue = value.toLowerCase()
106- if (lowerCaseValue.equals(" nan" ) ||
107- lowerCaseValue.equals(" infinity" ) ||
108- lowerCaseValue.equals(" -infinity" ) ||
109- lowerCaseValue.equals(" inf" ) ||
110- lowerCaseValue.equals(" -inf" )) {
111- value.toFloat
112- } else {
113- sys.error(s " Cannot parse $value as FloatType. " )
114- }
103+ parser.getFloatValue
115104
116105 case (VALUE_NUMBER_INT | VALUE_NUMBER_FLOAT , DoubleType ) =>
117106 parser.getDoubleValue
Original file line number Diff line number Diff line change @@ -93,17 +93,15 @@ class JsonParsingOptionsSuite extends QueryTest with SharedSQLContext {
9393 assert(df.first().getLong(0 ) == 18 )
9494 }
9595
96- // The following two tests are not really working - need to look into Jackson's
97- // JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS.
98- ignore(" allowNonNumericNumbers off" ) {
96+ test(" allowNonNumericNumbers off" ) {
9997 val str = """ {"age": NaN}"""
10098 val rdd = sqlContext.sparkContext.parallelize(Seq (str))
10199 val df = sqlContext.read.json(rdd)
102100
103101 assert(df.schema.head.name == " _corrupt_record" )
104102 }
105103
106- ignore (" allowNonNumericNumbers on" ) {
104+ test (" allowNonNumericNumbers on" ) {
107105 val str = """ {"age": NaN}"""
108106 val rdd = sqlContext.sparkContext.parallelize(Seq (str))
109107 val df = sqlContext.read.option(" allowNonNumericNumbers" , " true" ).json(rdd)
You can’t perform that action at this time.
0 commit comments