Source:
public AbstractExpression visitInputRef(RexInputRef inputRef) { int exprInputIndx = inputRef.getIndex(); int inputIdx = exprInputIndx; RelDataType inputType = inputRef.getType(); final boolean isFromInnerTable = isFromInnerTable(exprInputIndx); final boolean resolvingNonJoinRef = m_numOuterFieldsForJoin < 0; final boolean resolvingOuter = ! isFromInnerTable && ! m_isInnerTable && m_numOuterFieldsForJoin > 0; final boolean resolvingInner = isFromInnerTable && m_isInnerTable && m_numOuterFieldsForJoin > 0; String columnName = null; String tableName = null; final int tableIndex = isFromInnerTable ? 1 : 0; if (resolvingNonJoinRef || resolvingOuter || resolvingInner) { if (resolvingInner) { exprInputIndx -= m_numOuterFieldsForJoin; } if (resolvingOuter || resolvingInner) { Preconditions.checkState(exprInputIndx < m_program.getProjectList().size()); final RexLocalRef inputLocalRef = m_program.getProjectList().get(exprInputIndx); inputIdx = inputLocalRef.getIndex(); inputType = inputLocalRef.getType(); RexNode expr = m_program.getExprList().get(inputIdx); if (expr.isA(SqlKind.CAST)) { expr = ((RexCall) expr).getOperands().get(0); } final AbstractExpression voltExpr = expr.accept(new RefExpressionConvertingVisitor( m_catTableName, m_catColumns, m_program, -1, false)); voltExpr.findAllTupleValueSubexpressions() .forEach(tve -> tve.setTableIndex(tableIndex)); return voltExpr; } if (m_catColumns != null && inputIdx < m_catColumns.size()) { columnName = m_catColumns.get(inputIdx).getTypeName(); } tableName = m_catTableName; } return visitInputRef(tableIndex, inputIdx, inputType, tableName, columnName); }

Target:
public AbstractExpression visitInputRef(RexInputRef inputRef) { int exprInputIndx = inputRef.getIndex(); int inputIdx = exprInputIndx; RelDataType inputType = inputRef.getType(); final boolean isFromInnerTable = isFromInnerTable(exprInputIndx); final boolean resolvingNonJoinRef = m_numOuterFieldsForJoin < 0; final boolean resolvingOuter = ! isFromInnerTable && ! m_isInnerTable && m_numOuterFieldsForJoin > 0; final boolean resolvingInner = isFromInnerTable && m_isInnerTable && m_numOuterFieldsForJoin > 0; String columnName = null; String tableName = null; final int tableIndex = isFromInnerTable ? 1 : 0; if (resolvingNonJoinRef || resolvingOuter || resolvingInner) { if (resolvingInner) { exprInputIndx -= m_numOuterFieldsForJoin; } if (resolvingOuter || resolvingInner) { Preconditions.checkState(exprInputIndx < m_program.getProjectList().size()); final RexLocalRef inputLocalRef = m_program.getProjectList().get(exprInputIndx); inputIdx = inputLocalRef.getIndex(); RexNode expr = m_program.getExprList().get(inputIdx); if (expr.isA(SqlKind.CAST)) { expr = ((RexCall) expr).getOperands().get(0); } final AbstractExpression voltExpr = expr.accept(new RefExpressionConvertingVisitor( m_catTableName, m_catColumns, m_program, -1, false)); voltExpr.findAllTupleValueSubexpressions() .forEach(tve -> tve.setTableIndex(tableIndex)); return voltExpr; } if (m_catColumns != null && inputIdx < m_catColumns.size()) { columnName = m_catColumns.get(inputIdx).getTypeName(); } tableName = m_catTableName; } return visitInputRef(tableIndex, inputIdx, inputType, tableName, columnName); }