@@ -1310,8 +1310,8 @@ class CodegenContext extends Logging {
13101310 val (inputVars, _) = getLocalInputVariableValues(this , stats.expr, subExprEliminationExprs)
13111311 val (initialized, isNull, value) = (stats.initialized.get, stats.isNull.get, stats.value.get)
13121312 val validParamLength = isValidParamLength(calculateParamLengthFromExprValues(inputVars))
1313- if (! stats.addedFunction && validParamLength) {
1314- // Generate the code for this expression tree and wrap it in a function.
1313+ if (! stats.addedFunction && validParamLength) {
1314+ // Wrap the expression code in a function.
13151315 val argList =
13161316 inputVars.map(v => s " ${CodeGenerator .typeName(v.javaType)} ${v.variableName}" )
13171317 val fn =
@@ -1329,8 +1329,11 @@ class CodegenContext extends Logging {
13291329 stats.params = Some (inputVars.map(_.javaType))
13301330 stats.addedFunction = true
13311331 }
1332- // input vars changed, e.g. some input vars now are GlobalValue.
1333- if (inputVars.map(_.javaType) != stats.params.get) {
1332+ if (! classFunctions.values.map(_.keys).flatten.toSet.contains(stats.funcName.get)) {
1333+ // The CodegenContext has changed, all the corresponding variables will also not be available
1334+ eval
1335+ } else if (inputVars.map(_.javaType) != stats.params.get) {
1336+ // input vars changed, e.g. some input vars now are GlobalValue.
13341337 eval
13351338 } else {
13361339 val code =
@@ -1345,7 +1348,7 @@ class CodegenContext extends Logging {
13451348 | $isNull = ${eval.isNull};
13461349 | $value = ${eval.value};
13471350 |}
1348- """ .stripMargin
1351+ """ .stripMargin
13491352 }
13501353 ExprCode (code, isNull, value)
13511354 }
0 commit comments