Affected Version
Description
There's a topic in our kafka cluster, which contains messages in pretty JSON format as below. The newest 0.19 fails to parse these messages as JSON objects while 0.16 works fine.
JSON example
{
"byteCount":0,
"partition":0,
"recordAge":0,
"recordCount":0,
"replicationLatency":0,
"targetCluster":"dst",
"timestamp":1597045440490,
"topic":"test"
}
0.16


0.19


after changing Input Format from default Regex to Json, following error appears.

Reason
After diving into the code between 0.16 and 0.19, I found the problem is caused by JsonReader which was introduced in 0.17 by #8823
The new JsonReader inherits from TextReader which uses LineIterator to split the input string and return text LINE BY LINE instead of the whole text.
So for multiple-line json text, this implementation fails to parse the text as JSON object.
|
final LineIterator delegate = new LineIterator( |
How to fix
Maybe JsonReader should override the intermediateRowIterator function defined in TextReader to return an iterator with only one string object.
@jihoonson please check this bug if you're convenient :)
Affected Version
Description
There's a topic in our kafka cluster, which contains messages in pretty JSON format as below. The newest 0.19 fails to parse these messages as JSON objects while 0.16 works fine.
JSON example
0.16
0.19


after changing
Input Formatfrom defaultRegextoJson, following error appears.Reason
After diving into the code between 0.16 and 0.19, I found the problem is caused by
JsonReaderwhich was introduced in 0.17 by #8823The new
JsonReaderinherits fromTextReaderwhich usesLineIteratorto split the input string and return text LINE BY LINE instead of the whole text.So for multiple-line json text, this implementation fails to parse the text as JSON object.
druid/core/src/main/java/org/apache/druid/data/input/TextReader.java
Line 57 in e2487bc
How to fix
Maybe
JsonReadershould override theintermediateRowIteratorfunction defined inTextReaderto return an iterator with only one string object.@jihoonson please check this bug if you're convenient :)