You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by AsterixDB Code Review <do...@asterix-gerrit.ics.uci.edu> on 2024/09/20 19:19:02 UTC
Change in asterixdb[goldfish]: wip: incorrectly removing expressions from and clause in column filters
From Peeyush Gupta <pe...@couchbase.com>:
Peeyush Gupta has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18909 )
Change subject: wip: incorrectly removing expressions from and clause in column filters
......................................................................
wip: incorrectly removing expressions from and clause in column filters
Change-Id: I797acdbb90bd28bbe2a07f654ca6f15f835db0d7
---
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/AbstractFilterPushdownProcessor.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnFilterPushdownProcessor.java
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnRangeFilterPushdownProcessor.java
3 files changed, 30 insertions(+), 15 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/09/18909/1
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/AbstractFilterPushdownProcessor.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/AbstractFilterPushdownProcessor.java
index a150a10..6134d63 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/AbstractFilterPushdownProcessor.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/AbstractFilterPushdownProcessor.java
@@ -120,7 +120,8 @@
* @param expression compare expression
* @return true if the pushdown should continue, false otherwise
*/
- protected abstract boolean handleCompare(AbstractFunctionCallExpression expression) throws AlgebricksException;
+ protected abstract boolean handleCompare(AbstractFunctionCallExpression expression, int depth)
+ throws AlgebricksException;
/**
* Handle a value access path expression
@@ -253,7 +254,7 @@
// Prepare for pushdown
preparePushdown(useDescriptor, scanDefineDescriptor);
- if (pushdownFilterExpression(inlinedExpr)) {
+ if (pushdownFilterExpression(inlinedExpr, 0)) {
putFilterInformation(scanDefineDescriptor, inlinedExpr);
changed = true;
}
@@ -261,41 +262,46 @@
return changed;
}
- protected final boolean pushdownFilterExpression(ILogicalExpression expression) throws AlgebricksException {
+ protected final boolean pushdownFilterExpression(ILogicalExpression expression, int depth)
+ throws AlgebricksException {
boolean pushdown = false;
if (isConstant(expression)) {
IAObject constantValue = getConstant(expression);
// Only non-derived types are allowed
pushdown = !constantValue.getType().getTypeTag().isDerivedType();
} else if (isAnd(expression)) {
- pushdown = handleAnd((AbstractFunctionCallExpression) expression);
+ pushdown = handleAnd((AbstractFunctionCallExpression) expression, depth);
} else if (isCompare(expression)) {
- pushdown = handleCompare((AbstractFunctionCallExpression) expression);
+ pushdown = handleCompare((AbstractFunctionCallExpression) expression, depth);
} else if (isFilterPath(expression)) {
pushdown = handlePath((AbstractFunctionCallExpression) expression);
} else if (expression.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
// All functions including OR
- pushdown = handleFunction((AbstractFunctionCallExpression) expression);
+ pushdown = handleFunction((AbstractFunctionCallExpression) expression, depth);
}
// PK variable should have (pushdown = false) as we should not involve the PK (at least currently)
return pushdown;
}
- private boolean handleAnd(AbstractFunctionCallExpression expression) throws AlgebricksException {
+ private boolean handleAnd(AbstractFunctionCallExpression expression, int depth) throws AlgebricksException {
List<Mutable<ILogicalExpression>> args = expression.getArguments();
Iterator<Mutable<ILogicalExpression>> argIter = args.iterator();
while (argIter.hasNext()) {
ILogicalExpression arg = argIter.next().getValue();
// Allow for partial pushdown of AND operands
- if (!pushdownFilterExpression(arg)) {
- // Remove the expression that cannot be pushed down
- argIter.remove();
+ if (!pushdownFilterExpression(arg, depth + 1)) {
+ if (depth == 0) {
+ // Remove the expression that cannot be pushed down
+ argIter.remove();
+ } else {
+ return false;
+ }
}
}
return !args.isEmpty();
}
- private boolean handleFunction(AbstractFunctionCallExpression expression) throws AlgebricksException {
+ private boolean handleFunction(AbstractFunctionCallExpression expression, int depth) throws AlgebricksException {
if (!expression.getFunctionInfo().isFunctional() || isNotPushable(expression)) {
return false;
}
@@ -303,7 +309,7 @@
for (Mutable<ILogicalExpression> argRef : expression.getArguments()) {
ILogicalExpression arg = argRef.getValue();
// Either all arguments are pushable or none
- if (!pushdownFilterExpression(arg)) {
+ if (!pushdownFilterExpression(arg, depth + 1)) {
return false;
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnFilterPushdownProcessor.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnFilterPushdownProcessor.java
index 64c3cf8..9cec55e 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnFilterPushdownProcessor.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnFilterPushdownProcessor.java
@@ -107,7 +107,7 @@
}
@Override
- protected boolean handleCompare(AbstractFunctionCallExpression expression) throws AlgebricksException {
+ protected boolean handleCompare(AbstractFunctionCallExpression expression, int depth) throws AlgebricksException {
List<Mutable<ILogicalExpression>> args = expression.getArguments();
Mutable<ILogicalExpression> leftRef = args.get(0);
@@ -116,7 +116,7 @@
ILogicalExpression left = leftRef.getValue();
ILogicalExpression right = rightRef.getValue();
- return pushdownFilterExpression(left) && pushdownFilterExpression(right);
+ return pushdownFilterExpression(left, depth + 1) && pushdownFilterExpression(right, depth + 1);
}
@Override
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnRangeFilterPushdownProcessor.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnRangeFilterPushdownProcessor.java
index e61a18f..75a7608 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnRangeFilterPushdownProcessor.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/pushdown/processor/ColumnRangeFilterPushdownProcessor.java
@@ -83,7 +83,7 @@
}
@Override
- protected boolean handleCompare(AbstractFunctionCallExpression expression) throws AlgebricksException {
+ protected boolean handleCompare(AbstractFunctionCallExpression expression, int depth) throws AlgebricksException {
List<Mutable<ILogicalExpression>> args = expression.getArguments();
Mutable<ILogicalExpression> leftRef = args.get(0);
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18909
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-Project: asterixdb
Gerrit-Branch: goldfish
Gerrit-Change-Id: I797acdbb90bd28bbe2a07f654ca6f15f835db0d7
Gerrit-Change-Number: 18909
Gerrit-PatchSet: 1
Gerrit-Owner: Peeyush Gupta <pe...@couchbase.com>
Gerrit-MessageType: newchange