Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
* flattened.
*/
public class MergeEqInFilterOptimizer implements FilterOptimizer {
// Optimize IN predicate with up to 10 values (operands include lhs)
// TODO: Make it configurable
private static final int IN_OPERANDS_THRESHOLD = 11;

@Override
public Expression optimize(Expression filterExpression, @Nullable Schema schema) {
Expand Down Expand Up @@ -92,9 +95,14 @@ private Expression optimize(Expression filterExpression) {
}
} else if (childOperator.equals(FilterKind.IN.name())) {
List<Expression> operands = childFunction.getOperands();
int numOperands = operands.size();
if (numOperands > IN_OPERANDS_THRESHOLD) {
// Skip merging IN predicate with too many values
newChildren.add(child);
continue;
}
Expression lhs = operands.get(0);
Set<Expression> inPredicateValuesSet = new HashSet<>();
int numOperands = operands.size();
for (int i = 1; i < numOperands; i++) {
inPredicateValuesSet.add(operands.get(i));
}
Expand Down Expand Up @@ -138,9 +146,13 @@ private Expression optimize(Expression filterExpression) {
return filterExpression;
} else if (operator.equals(FilterKind.IN.name())) {
List<Expression> operands = function.getOperands();
int numOperands = operands.size();
if (numOperands > IN_OPERANDS_THRESHOLD) {
// Skip merging IN predicate with too many values
return filterExpression;
}
Expression lhs = operands.get(0);
Set<Expression> values = new HashSet<>();
int numOperands = operands.size();
for (int i = 1; i < numOperands; i++) {
values.add(operands.get(i));
}
Expand Down