Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,6 @@ case class JsonTuple(children: Seq[Expression])
parser.getCurrentToken match {
// if the user requests a string field it needs to be returned without enclosing
// quotes which is accomplished via JsonGenerator.writeRaw instead of JsonGenerator.write
case JsonToken.VALUE_STRING if parser.hasTextCharacters =>
// slight optimization to avoid allocating a String instance, though the characters
// still have to be decoded... Jackson doesn't have a way to access the raw bytes
generator.writeRaw(parser.getTextCharacters, parser.getTextOffset, parser.getTextLength)

case JsonToken.VALUE_STRING =>
// the normal String case, pass it through to the output without enclosing quotes
generator.writeRaw(parser.getText)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,14 @@ class JsonFunctionsSuite extends QueryTest with SharedSQLContext {
to_json(struct($"t"), Map("timestampFormat" -> "yyyy-MM-dd HH:mm:ss.SSSSSS")))
checkAnswer(df, Row(s"""{"t":"$s"}"""))
}

test("json_tuple - do not truncate results") {
val len = 2800
val str = Array.tabulate(len)(_ => "a").mkString
val json_tuple_result = Seq(s"""{"test":"$str"}""").toDF("json")
.withColumn("result", json_tuple('json, "test"))
.select('result)
.as[String].head.length
assert(json_tuple_result === len)
}
}