Skip to content
Closed
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 @@ -377,6 +377,7 @@ abstract class UnaryExpression extends Expression {
""")
} else {
ev.copy(code = s"""
boolean ${ev.isNull} = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this, we explicitly define isNull = "false" below, how could ev.isNull be referenced later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloud-fan ideally it shouldn't be referenced but we recently discovered these incorrect patterns in the code (e.g., https://github.com/apache/spark/pull/14168/files#diff-39298b470865a4cbc67398a4ea11e767L290) where the non-nullable branches were not explicitly tested. This change was just a defensive measure for codegen to not break in those cases. Let me also add a comment here to reduce confusion.

${childGen.code}
${ctx.javaType(dataType)} ${ev.value} = ${ctx.defaultValue(dataType)};
$resultCode""", isNull = "false")
Expand Down Expand Up @@ -475,6 +476,7 @@ abstract class BinaryExpression extends Expression {
""")
} else {
ev.copy(code = s"""
boolean ${ev.isNull} = false;
${leftGen.code}
${rightGen.code}
${ctx.javaType(dataType)} ${ev.value} = ${ctx.defaultValue(dataType)};
Expand Down Expand Up @@ -617,6 +619,7 @@ abstract class TernaryExpression extends Expression {
$nullSafeEval""")
} else {
ev.copy(code = s"""
boolean ${ev.isNull} = false;
${leftGen.code}
${midGen.code}
${rightGen.code}
Expand Down