From 5f3bda6fe2def15a1960b0feab42b07950ce691f Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Thu, 17 Mar 2016 10:08:42 -0700 Subject: [SPARK-13838] [SQL] Clear variable code to prevent it to be re-evaluated in BoundAttribute JIRA: https://issues.apache.org/jira/browse/SPARK-13838 ## What changes were proposed in this pull request? We should also clear the variable code in `BoundReference.genCode` to prevent it to be evaluated twice, as we did in `evaluateVariables`. ## How was this patch tested? Existing tests. Author: Liang-Chi Hsieh Closes #11674 from viirya/avoid-reevaluate. --- .../org/apache/spark/sql/catalyst/expressions/BoundAttribute.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/BoundAttribute.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/BoundAttribute.scala index 0d249a118c..c1fd23f28d 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/BoundAttribute.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/BoundAttribute.scala @@ -65,7 +65,9 @@ case class BoundReference(ordinal: Int, dataType: DataType, nullable: Boolean) val oev = ctx.currentVars(ordinal) ev.isNull = oev.isNull ev.value = oev.value - oev.code + val code = oev.code + oev.code = "" + code } else if (nullable) { s""" boolean ${ev.isNull} = ${ctx.INPUT_ROW}.isNullAt($ordinal); -- cgit v1.2.3