From 24e75a22ade1f37363bb5211db3f02bcf6cff315 Mon Sep 17 00:00:00 2001 From: Haoyang Li Date: Fri, 6 Dec 2024 13:23:52 +0800 Subject: [PATCH] save a temp columnvector Signed-off-by: Haoyang Li --- .../org/apache/spark/sql/rapids/stringFunctions.scala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/stringFunctions.scala b/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/stringFunctions.scala index 17372e4a568..10960cbe2ad 100644 --- a/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/stringFunctions.scala +++ b/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/stringFunctions.scala @@ -1247,11 +1247,9 @@ case class GpuContainsAny(input: Expression, targets: Seq[UTF8String]) val boolCvs = withResource(ColumnVector.fromUTF8Strings(targetsBytes: _*)) { targetsCv => input.getBase.stringContains(targetsCv) } - withResource(boolCvs) { _ => - val falseCv = withResource(Scalar.fromBool(false)) { falseScalar => - ColumnVector.fromScalar(falseScalar, input.getRowCount.toInt) - } - boolCvs.foldLeft(falseCv)((l, r) => withResource(l) { _ => l.or(r)}) + withResource(boolCvs.tail) { _ => + // boolCvs.head and intermediate values are closed within the withResource in the lambda + boolCvs.tail.foldLeft(boolCvs.head)((l, r) => withResource(l) { _ => l.or(r)}) } } }