Github user mgaido91 commented on a diff in the pull request:
https://github.com/apache/spark/pull/18731#discussion_r130294946
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala
---
@@ -347,13 +347,18 @@ class JacksonParser(
Utils.tryWithResource(createParser(factory, record)) { parser =>
// a null first token is equivalent to testing for
input.trim.isEmpty
// but it works on any token stream and not just strings
- parser.nextToken() match {
- case null => Nil
- case _ => rootConverter.apply(parser) match {
- case null => throw new RuntimeException("Root converter
returned null")
- case rows => rows
+ var endLoop = false
+ val allRows =
scala.collection.mutable.ArrayBuffer.empty[InternalRow]
+ while (!endLoop) {
+ Option(parser.nextToken()) match {
+ case Some(_) => rootConverter.apply(parser) match {
+ case null => throw new RuntimeException("Root converter
returned null")
+ case rows => allRows ++= rows
+ }
+ case None => endLoop = true
}
}
+ allRows
}
} catch {
case e @ (_: RuntimeException | _: JsonProcessingException) =>
--- End diff --
Thanks for your review.
You are definitely right about it, but I am not sure how to deal with these
cases. What I mean is that if we have one JSON per line, for instance, you know
that each line is either a valid JSON or not, because you know that at the end
of the line the JSON must have been ended. In this case, instead, we don't have
a delimiter. The only way we have to say that a JSON is finished is to parse it
properly. Otherwise we don't know where a document finishes and the next one
begins, because we have no "delimiter" for the end of the JSON.
Do you have any suggestion about how we should deal with this? I mean, do
you have any idea about which should be the right "split policy" to apply to
choose when a document ends?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]