Skip to content

Commit

Permalink
fix resource leak in to_json
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Grove <[email protected]>
  • Loading branch information
andygrove committed Nov 28, 2023
1 parent 26c9e37 commit 600a761
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 @@ -1113,13 +1113,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 600a761

Please sign in to comment.