Skip to content

Commit 7434594

Browse files
authored
fix: Fix None.get in stringDecode when binary child cannot be converted (apache#2606)
1 parent 451d6b0 commit 7434594

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

spark/src/main/scala/org/apache/comet/serde/strings.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,13 @@ trait CommonStringExprs {
256256
// decode(col, 'utf-8') can be treated as a cast with "try" eval mode that puts nulls
257257
// for invalid strings.
258258
// Left child is the binary expression.
259-
CometCast.castToProto(
260-
expr,
261-
None,
262-
DataTypes.StringType,
263-
exprToProtoInternal(bin, inputs, binding).get,
264-
CometEvalMode.TRY)
259+
val binExpr = exprToProtoInternal(bin, inputs, binding)
260+
if (binExpr.isDefined) {
261+
CometCast.castToProto(expr, None, DataTypes.StringType, binExpr.get, CometEvalMode.TRY)
262+
} else {
263+
withInfo(expr, bin)
264+
None
265+
}
265266
case _ =>
266267
withInfo(expr, "Comet only supports decoding with 'utf-8'.")
267268
None

0 commit comments

Comments
 (0)