Source:
private static AbstractPlanNode getIndexAccessPlanForTable(StmtTableScan tableScan, AccessPath path) { Index index = path.index; IndexScanPlanNode scanNode = new IndexScanPlanNode(tableScan, index); AbstractPlanNode resultNode = scanNode; scanNode.setSortDirection(path.sortDirection); for (AbstractExpression expr : path.indexExprs) { if (path.lookupType == IndexLookupType.GEO_CONTAINS) { scanNode.addSearchKeyExpression(expr); scanNode.addCompareNotDistinctFlag(false); continue; } AbstractExpression exprRightChild = expr.getRight(); assert(exprRightChild != null); if (expr.getExpressionType() == ExpressionType.COMPARE_IN) { resultNode = injectIndexedJoinWithMaterializedScan(exprRightChild, scanNode); MaterializedScanPlanNode matscan = (MaterializedScanPlanNode)resultNode.getChild(0); AbstractExpression elemExpr = matscan.getOutputExpression(); assert(elemExpr != null); replaceInListFilterWithEqualityFilter(path.endExprs, exprRightChild, elemExpr); exprRightChild = elemExpr; } if (exprRightChild instanceof AbstractSubqueryExpression) { assert(false); } scanNode.addSearchKeyExpression(exprRightChild); scanNode.addCompareNotDistinctFlag(expr.getExpressionType() == ExpressionType.COMPARE_NOTDISTINCT); } scanNode.setLookupType(path.lookupType); scanNode.setBindings(path.bindings); scanNode.setEndExpression(ExpressionUtil.combinePredicates(path.endExprs)); scanNode.setPredicate(path.otherExprs); scanNode.setWindowFunctionUsesIndex(path.m_windowFunctionUsesIndex); scanNode.setSortOrderFromIndexScan(path.sortDirection); scanNode.setWindowFunctionIsCompatibleWithOrderBy(path.m_stmtOrderByIsCompatible); scanNode.setFinalExpressionOrderFromIndexScan(path.m_finalExpressionOrder); scanNode.setInitialExpression(ExpressionUtil.combinePredicates(path.initialExpr)); scanNode.setSkipNullPredicate(); scanNode.setEliminatedPostFilters(path.eliminatedPostExprs); return resultNode; }

Target:
private static AbstractPlanNode getIndexAccessPlanForTable( StmtTableScan tableScan, AccessPath path) { Index index = path.index; IndexScanPlanNode scanNode = new IndexScanPlanNode(tableScan, index); AbstractPlanNode resultNode = scanNode; scanNode.setSortDirection(path.sortDirection); for (AbstractExpression expr : path.indexExprs) { if (path.lookupType == IndexLookupType.GEO_CONTAINS) { scanNode.addSearchKeyExpression(expr); scanNode.addCompareNotDistinctFlag(false); continue; } AbstractExpression exprRightChild = expr.getRight(); assert(exprRightChild != null); if (expr.getExpressionType() == ExpressionType.COMPARE_IN) { resultNode = injectIndexedJoinWithMaterializedScan(exprRightChild, scanNode); MaterializedScanPlanNode matscan = (MaterializedScanPlanNode)resultNode.getChild(0); AbstractExpression elemExpr = matscan.getOutputExpression(); assert(elemExpr != null); replaceInListFilterWithEqualityFilter(path.endExprs, exprRightChild, elemExpr); exprRightChild = elemExpr; } if (exprRightChild instanceof AbstractSubqueryExpression) { assert(false); } scanNode.addSearchKeyExpression(exprRightChild); scanNode.addCompareNotDistinctFlag(expr.getExpressionType() == ExpressionType.COMPARE_NOTDISTINCT); } scanNode.setLookupType(path.lookupType); scanNode.setBindings(path.bindings); scanNode.setEndExpression(ExpressionUtil.combinePredicates(path.endExprs)); scanNode.setPredicate(path.otherExprs); scanNode.setInitialExpression(ExpressionUtil.combinePredicates(path.initialExpr)); scanNode.setSkipNullPredicate(); scanNode.setEliminatedPostFilters(path.eliminatedPostExprs); if (scanNode instanceof IndexSortablePlanNode) { IndexUseForOrderBy indexUse = ((IndexSortablePlanNode)scanNode).indexUse(); indexUse.setWindowFunctionUsesIndex(path.m_windowFunctionUsesIndex); indexUse.setSortOrderFromIndexScan(path.sortDirection); indexUse.setWindowFunctionIsCompatibleWithOrderBy(path.m_stmtOrderByIsCompatible); indexUse.setFinalExpressionOrderFromIndexScan(path.m_finalExpressionOrder); } return resultNode; }