1515 * limitations under the License.
1616 */
1717
18- package org .apache .spark .sql .execution . datasources .json
18+ package org .apache .spark .sql .catalyst .json
1919
2020import java .io .ByteArrayOutputStream
2121
@@ -28,19 +28,22 @@ import org.apache.spark.internal.Logging
2828import org .apache .spark .sql .catalyst .InternalRow
2929import org .apache .spark .sql .catalyst .expressions ._
3030import org .apache .spark .sql .catalyst .util ._
31- import org .apache .spark .sql .execution .datasources .ParseModes .{DROP_MALFORMED_MODE , PERMISSIVE_MODE }
32- import org .apache .spark .sql .execution .datasources .json .JacksonUtils .nextUntil
3331import org .apache .spark .sql .types ._
3432import org .apache .spark .unsafe .types .UTF8String
3533import org .apache .spark .util .Utils
3634
37- private [json ] class SparkSQLJsonProcessingException (msg : String ) extends RuntimeException (msg)
35+ private [sql ] class SparkSQLJsonProcessingException (msg : String ) extends RuntimeException (msg)
3836
37+ /**
38+ * Constructs a parser for a given schema that translates a json string to an [[InternalRow ]].
39+ */
3940class JacksonParser (
4041 schema : StructType ,
4142 columnNameOfCorruptRecord : String ,
4243 options : JSONOptions ) extends Logging {
4344
45+ import JacksonUtils ._
46+ import ParseModes ._
4447 import com .fasterxml .jackson .core .JsonToken ._
4548
4649 // A `ValueConverter` is responsible for converting a value from `JsonParser`
@@ -65,7 +68,7 @@ class JacksonParser(
6568 private def failedRecord (record : String ): Seq [InternalRow ] = {
6669 // create a row even if no corrupt record column is present
6770 if (options.failFast) {
68- throw new RuntimeException (s " Malformed line in FAILFAST mode: $record" )
71+ throw new SparkSQLJsonProcessingException (s " Malformed line in FAILFAST mode: $record" )
6972 }
7073 if (options.dropMalformed) {
7174 if (! isWarningPrintedForMalformedRecord) {
0 commit comments