Skip to content

Commit 53926cc

Browse files
committed
Address comments.
1 parent 81c9b6e commit 53926cc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ abstract class Expression extends TreeNode[Expression] {
118118
private def reduceCodeSize(ctx: CodegenContext, eval: ExprCode): Unit = {
119119
// TODO: support whole stage codegen too
120120
if (eval.code.trim.length > 1024 && ctx.INPUT_ROW != null && ctx.currentVars == null) {
121-
val setIsNull = if ("false" != s"${eval.isNull}" && "true" != s"${eval.isNull}") {
121+
val setIsNull = if (!eval.isNull.isInstanceOf[LiteralValue]) {
122122
val globalIsNull = ctx.addMutableState(ctx.JAVA_BOOLEAN, "globalIsNull")
123123
val localIsNull = eval.isNull
124124
eval.isNull = GlobalValue(globalIsNull)

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullExpressions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ case class IsNull(child: Expression) extends UnaryExpression with Predicate {
322322

323323
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
324324
val eval = child.genCode(ctx)
325-
val value = if ("true" == s"${eval.isNull}" || "false" == s"${eval.isNull}") {
325+
val value = if (eval.isNull.isInstanceOf[LiteralValue]) {
326326
LiteralValue(eval.isNull)
327327
} else {
328328
VariableValue(eval.isNull)
@@ -353,9 +353,9 @@ case class IsNotNull(child: Expression) extends UnaryExpression with Predicate {
353353

354354
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
355355
val eval = child.genCode(ctx)
356-
val value = if ("true" == s"${eval.isNull}") {
356+
val value = if (eval.isNull == LiteralValue("true")) {
357357
LiteralValue("false")
358-
} else if ("false" == s"${eval.isNull}") {
358+
} else if (eval.isNull == LiteralValue("false")) {
359359
LiteralValue("true")
360360
} else {
361361
StatementValue(s"(!(${eval.isNull}))")

0 commit comments

Comments
 (0)