Skip to content

Commit

Permalink
fix resource leak in to_json (#9879)
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Grove <andygrove@nvidia.com>
  • Loading branch information
andygrove authored Nov 29, 2023
1 parent 7efcb81 commit 31aee63
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1124,13 +1124,15 @@ object GpuCast {
}
if (options.ignoreNullFieldsInStructs) {
// write the value
val attrValue = castToString(cv, inputSchema(fieldIndex).dataType, options)
if (needsQuoting) {
attrColumns += quote.incRefCount()
attrColumns += escapeJsonString(attrValue)
attrColumns += quote.incRefCount()
} else {
attrColumns += attrValue
withResource(castToString(cv, inputSchema(fieldIndex).dataType, options)) {
attrValue =>
if (needsQuoting) {
attrColumns += quote.incRefCount()
attrColumns += escapeJsonString(attrValue)
attrColumns += quote.incRefCount()
} else {
attrColumns += attrValue.incRefCount()
}
}
// now concatenate
val jsonAttr = withResource(Scalar.fromString("")) { emptyString =>
Expand Down

0 comments on commit 31aee63

Please sign in to comment.