}
return paths;
}
private Path [] findFilteredPartitionPaths(ScanNode scanNode) throws IOException {
TableDesc table = scanNode.getTableDesc();
PartitionMethodDesc partitionDesc = scanNode.getTableDesc().getPartitionMethod();
Schema paritionValuesSchema = new Schema();
for (Column column : partitionDesc.getExpressionSchema().getColumns()) {
paritionValuesSchema.addColumn(column);
}
Set<EvalNode> indexablePredicateSet = Sets.newHashSet();
// if a query statement has a search condition, try to find indexable predicates
if (scanNode.hasQual()) {
EvalNode [] conjunctiveForms = AlgebraicUtil.toConjunctiveNormalFormArray(scanNode.getQual());
Set<EvalNode> remainExprs = Sets.newHashSet(conjunctiveForms);
// add qualifier to schema for qual
paritionValuesSchema.setQualifier(scanNode.getCanonicalName());
for (Column column : paritionValuesSchema.getColumns()) {
for (EvalNode simpleExpr : conjunctiveForms) {
if (checkIfIndexablePredicateOnTargetColumn(simpleExpr, column)) {
indexablePredicateSet.add(simpleExpr);
}
}
}
// Partitions which are not matched to the partition filter conditions are pruned immediately.
// So, the partition filter conditions are not necessary later, and they are removed from
// original search condition for simplicity and efficiency.
remainExprs.removeAll(indexablePredicateSet);
if (remainExprs.isEmpty()) {
scanNode.setQual(null);
} else {
scanNode.setQual(
AlgebraicUtil.createSingletonExprFromCNF(remainExprs.toArray(new EvalNode[remainExprs.size()])));
}
}
if (indexablePredicateSet.size() > 0) { // There are at least one indexable predicates
return findFilteredPaths(paritionValuesSchema,
indexablePredicateSet.toArray(new EvalNode[indexablePredicateSet.size()]), table.getPath());
} else { // otherwise, we will get all partition paths.
return findFilteredPaths(paritionValuesSchema, null, table.getPath());
}
}