Skip to content

Commit 0c2e77b

Browse files
committed
Address comment
Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 3c44b4b commit 0c2e77b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/OpenSearchDedupPushdownRule.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ protected OpenSearchDedupPushdownRule(Config config) {
3535
@Override
3636
public void onMatch(RelOptRuleCall call) {
3737
final LogicalProject finalOutput = call.rel(0);
38+
// TODO Used when number of duplication is more than 1
3839
final LogicalFilter numOfDedupFilter = call.rel(1);
3940
final LogicalProject projectWithWindow = call.rel(2);
4041
final CalciteLogicalIndexScan scan = call.rel(3);
41-
if (!validFilter(numOfDedupFilter)) {
42-
return;
43-
}
4442
List<RexWindow> windows = PlanUtils.getRexWindowFromProject(projectWithWindow);
4543
if (windows.isEmpty() || windows.stream().anyMatch(w -> w.partitionKeys.size() > 1)) {
4644
// TODO leverage inner_hits for multiple partition keys
@@ -60,7 +58,9 @@ public void onMatch(RelOptRuleCall call) {
6058
}
6159

6260
private static boolean validFilter(LogicalFilter filter) {
63-
// The condition kind is LESS_THAN_OR_EQUAL, safe to convert to RexCall
61+
if (filter.getCondition().getKind() != SqlKind.LESS_THAN_OR_EQUAL) {
62+
return false;
63+
}
6464
List<RexNode> operandsOfCondition = ((RexCall) filter.getCondition()).getOperands();
6565
RexNode leftOperand = operandsOfCondition.getFirst();
6666
if (!(leftOperand instanceof RexInputRef ref)) {
@@ -114,10 +114,7 @@ public interface Config extends RelRule.Config {
114114
.oneInput(
115115
b1 ->
116116
b1.operand(LogicalFilter.class)
117-
.predicate(
118-
f ->
119-
f.getCondition().getKind()
120-
== SqlKind.LESS_THAN_OR_EQUAL)
117+
.predicate(OpenSearchDedupPushdownRule::validFilter)
121118
.oneInput(
122119
b2 ->
123120
b2.operand(LogicalProject.class)

0 commit comments

Comments
 (0)