Source:
protected boolean producesOneRowOutput () { if (m_tableAliasMap.size() != 1) { return false; } StmtTableScan scan = m_tableAliasMap.values().iterator().next(); Table table = getTableFromDB(scan.getTableName()); if (table == null) { return false; } CatalogMap<Index> indexes = table.getIndexes(); if (indexes == null || indexes.size() == 0) { return false; } HashMap<AbstractExpression, Set<AbstractExpression>> valueEquivalence = analyzeValueEquivalence(); if (valueEquivalence == null || valueEquivalence.isEmpty()) { return false; } Set <AbstractExpression> parameterizedConstantKeys = new HashSet<AbstractExpression>(); Set<AbstractExpression> valueEquivalenceKeys = valueEquivalence.keySet(); for (AbstractExpression key : valueEquivalenceKeys) { if (key instanceof TupleValueExpression) { Set<AbstractExpression> values = valueEquivalence.get(key); for (AbstractExpression value : values) { if ((value instanceof ParameterValueExpression) || (value instanceof ConstantValueExpression)) { TupleValueExpression tve = (TupleValueExpression) key; parameterizedConstantKeys.add(tve); } } } } for (Index index : indexes) { Set<AbstractExpression> indexExpressions = new HashSet<AbstractExpression>(); if (index != null && index.getUnique() && index.getExpressionsjson().isEmpty()) { CatalogMap<ColumnRef> indexColRefs = index.getColumns(); for (ColumnRef indexColRef:indexColRefs) { Column col = indexColRef.getColumn(); TupleValueExpression tve = new TupleValueExpression(scan.getTableName(), scan.getTableAlias(), col.getName(), col.getName(), col.getIndex()); indexExpressions.add(tve); } } if (!indexExpressions.isEmpty() && parameterizedConstantKeys.containsAll(indexExpressions)) { return true; } } return false; }

Target:
protected boolean producesOneRowOutput () { if (m_tableAliasMap.size() != 1) { return false; } StmtTableScan scan = m_tableAliasMap.values().iterator().next(); Table table = getTableFromDB(scan.getTableName()); if (table == null) { return false; } CatalogMap<Index> indexes = table.getIndexes(); if (indexes == null || indexes.size() == 0) { return false; } HashMap<AbstractExpression, Set<AbstractExpression>> valueEquivalence = analyzeValueEquivalence(); if (valueEquivalence.isEmpty()) { return false; } Set <AbstractExpression> parameterizedConstantKeys = new HashSet<AbstractExpression>(); Set<AbstractExpression> valueEquivalenceKeys = valueEquivalence.keySet(); for (AbstractExpression key : valueEquivalenceKeys) { if (key instanceof TupleValueExpression) { Set<AbstractExpression> values = valueEquivalence.get(key); for (AbstractExpression value : values) { if ((value instanceof ParameterValueExpression) || (value instanceof ConstantValueExpression)) { TupleValueExpression tve = (TupleValueExpression) key; parameterizedConstantKeys.add(tve); } } } } for (Index index : indexes) { if (!index.getUnique() || !index.getExpressionsjson().isEmpty()) { continue; } Set<AbstractExpression> indexExpressions = new HashSet<AbstractExpression>(); CatalogMap<ColumnRef> indexColRefs = index.getColumns(); for (ColumnRef indexColRef:indexColRefs) { Column col = indexColRef.getColumn(); TupleValueExpression tve = new TupleValueExpression(scan.getTableName(), scan.getTableAlias(), col.getName(), col.getName(), col.getIndex()); indexExpressions.add(tve); } if (parameterizedConstantKeys.containsAll(indexExpressions)) { return true; } } return false; }