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 2026/09/25 18:57:53 UTC
[L] Change in asterixdb[master]: [ASTERIXDB-3908][COMP] Merge redundant range bounds by value
From Ali Alsuliman <al...@gmail.com>:
Ali Alsuliman has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21896?usp=email )
Change subject: [ASTERIXDB-3908][COMP] Merge redundant range bounds by value
......................................................................
[ASTERIXDB-3908][COMP] Merge redundant range bounds by value
- user model changes: no
- storage format changes: no
- interface changes: no
Details: two range predicates on one B-tree key could merge into a bound
that was too tight or too loose. The tighter value took the other
predicate's inclusiveness, so d > 5 AND d >= 7 searched d > 7, and an
exclusive predicate replaced an inclusive bound without comparing the
values, so id >= 9 AND id > 7 searched id > 7. A primary-index search
drops the predicates it merges, so both returned wrong rows there.
The tighter value now keeps its own inclusiveness, and on equal values
the exclusive bound wins. Bounds that cannot be compared, such as two
non-constant ones, give up on the index as other unmergeable bounds
already did, instead of letting an exclusive one replace an inclusive
one.
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
Change-Id: I46a69f016ed50dbdb9c7b45f3451171f92f2f34e
---
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.01.ddl.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.02.update.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.adm
A asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.adm
M asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
32 files changed, 423 insertions(+), 85 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/96/21896/1
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
index ac523f3..7b1754c 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/BTreeAccessMethod.java
@@ -1180,83 +1180,31 @@
}
break;
}
- case HIGH_EXCLUSIVE: {
- if (highKeyLimits[keyPos] == null || (highKeyLimits[keyPos] != null && highKeyInclusive[keyPos])) {
- highKeyLimits[keyPos] = limit;
- highKeyExprs[keyPos] = searchKeyExpr;
- highKeyInclusive[keyPos] = false;
- } else {
- // Has already been set to the identical values. When optimizing join we may encounter the
- // same optimizable expression twice
- // (once from analyzing each side of the join)
- if (highKeyLimits[keyPos] == limit && highKeyInclusive[keyPos] == false
- && highKeyExprs[keyPos].equals(searchKeyExpr)) {
- break;
- }
- if (!rangeMerging(searchKeyExpr, highKeyExprs, highKeyLimits, limit, keyPos, true)) {
- couldntFigureOut = true;
- doneWithExprs = true;
- }
- }
- break;
- }
+ case HIGH_EXCLUSIVE:
case HIGH_INCLUSIVE: {
+ boolean inclusive = limit == LimitType.HIGH_INCLUSIVE;
if (highKeyLimits[keyPos] == null) {
highKeyLimits[keyPos] = limit;
highKeyExprs[keyPos] = searchKeyExpr;
- highKeyInclusive[keyPos] = true;
- } else {
- // Has already been set to the identical values. When optimizing join we may encounter the
- // same optimizable expression twice
- // (once from analyzing each side of the join)
- if (highKeyLimits[keyPos] == limit && highKeyInclusive[keyPos] == true
- && highKeyExprs[keyPos].equals(searchKeyExpr)) {
- break;
- }
- if (!rangeMerging(searchKeyExpr, highKeyExprs, highKeyLimits, limit, keyPos, true)) {
- couldntFigureOut = true;
- doneWithExprs = true;
- }
+ highKeyInclusive[keyPos] = inclusive;
+ } else if (!mergeBound(searchKeyExpr, limit, inclusive, highKeyExprs, highKeyLimits,
+ highKeyInclusive, keyPos, true)) {
+ couldntFigureOut = true;
+ doneWithExprs = true;
}
break;
}
- case LOW_EXCLUSIVE: {
- if (lowKeyLimits[keyPos] == null || (lowKeyLimits[keyPos] != null && lowKeyInclusive[keyPos])) {
- lowKeyLimits[keyPos] = limit;
- lowKeyExprs[keyPos] = searchKeyExpr;
- lowKeyInclusive[keyPos] = false;
- } else {
- // Has already been set to the identical values. When optimizing join we may encounter the
- // same optimizable expression twice
- // (once from analyzing each side of the join)
- if (lowKeyLimits[keyPos] == limit && lowKeyInclusive[keyPos] == false
- && lowKeyExprs[keyPos].equals(searchKeyExpr)) {
- break;
- }
- if (!rangeMerging(searchKeyExpr, lowKeyExprs, lowKeyLimits, limit, keyPos, false)) {
- couldntFigureOut = true;
- doneWithExprs = true;
- }
- }
- break;
- }
+ case LOW_EXCLUSIVE:
case LOW_INCLUSIVE: {
+ boolean inclusive = limit == LimitType.LOW_INCLUSIVE;
if (lowKeyLimits[keyPos] == null) {
lowKeyLimits[keyPos] = limit;
lowKeyExprs[keyPos] = searchKeyExpr;
- lowKeyInclusive[keyPos] = true;
- } else {
- // Has already been set to the identical values. When optimizing join we may encounter the
- // same optimizable expression twice
- // (once from analyzing each side of the join)
- if (lowKeyLimits[keyPos] == limit && lowKeyInclusive[keyPos] == true
- && lowKeyExprs[keyPos].equals(searchKeyExpr)) {
- break;
- }
- if (!rangeMerging(searchKeyExpr, lowKeyExprs, lowKeyLimits, limit, keyPos, false)) {
- couldntFigureOut = true;
- doneWithExprs = true;
- }
+ lowKeyInclusive[keyPos] = inclusive;
+ } else if (!mergeBound(searchKeyExpr, limit, inclusive, lowKeyExprs, lowKeyLimits, lowKeyInclusive,
+ keyPos, false)) {
+ couldntFigureOut = true;
+ doneWithExprs = true;
}
break;
}
@@ -1866,34 +1814,42 @@
return this.getName().compareTo(o.getName());
}
- private boolean rangeMerging(ILogicalExpression searchKeyExpr, ILogicalExpression[] keyExprs, LimitType[] keyLimits,
- LimitType limit, int keyPos, boolean highkey) {
- int cmp = compareConstants(searchKeyExpr, keyExprs[keyPos]);
- if (cmp != 0) {
- if (highkey && cmp < 0) {
- keyLimits[keyPos] = limit;
- keyExprs[keyPos] = searchKeyExpr;
- }
- if (!highkey && cmp > 0) {
- keyLimits[keyPos] = limit;
- keyExprs[keyPos] = searchKeyExpr;
- }
- return true;
+ /**
+ * Merges a range predicate into the bound already set at {@code keyPos}, which then keeps the tighter of the two
+ * together with its own inclusiveness.
+ *
+ * @return false if the two bounds cannot be compared, in which case the bound is left as it was
+ */
+ private static boolean mergeBound(ILogicalExpression searchKeyExpr, LimitType limit, boolean inclusive,
+ ILogicalExpression[] keyExprs, LimitType[] keyLimits, boolean[] keyInclusive, int keyPos, boolean highKey) {
+ Integer cmp = searchKeyExpr.equals(keyExprs[keyPos]) ? Integer.valueOf(0)
+ : compareConstants(searchKeyExpr, keyExprs[keyPos]);
+ if (cmp == null) {
+ return false;
}
- return false;
+ // On the same value, an exclusive bound is the tighter one.
+ if (cmp == 0 ? !inclusive : (cmp < 0) == highKey) {
+ keyLimits[keyPos] = limit;
+ keyExprs[keyPos] = searchKeyExpr;
+ keyInclusive[keyPos] = inclusive;
+ }
+ return true;
}
- private static int compareConstants(ILogicalExpression expr1, ILogicalExpression expr2) {
+ /**
+ * @return the sign of {@code expr1} compared with {@code expr2}, or null if they are not constants that compare
+ */
+ private static Integer compareConstants(ILogicalExpression expr1, ILogicalExpression expr2) {
if (expr1.getExpressionTag() != LogicalExpressionTag.CONSTANT
|| expr2.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
- return 0;
+ return null;
}
IAObject val1 = ((AsterixConstantValue) ((ConstantExpression) expr1).getValue()).getObject();
IAObject val2 = ((AsterixConstantValue) ((ConstantExpression) expr2).getValue()).getObject();
ATypeTag tag1 = val1.getType().getTypeTag();
ATypeTag tag2 = val2.getType().getTypeTag();
if (!ATypeHierarchy.isCompatible(tag1, tag2)) {
- return 0;
+ return null;
}
try {
byte[] bytes1 = serializeObject(val1);
@@ -1908,13 +1864,15 @@
switch (result) {
case LT:
return -1;
+ case EQ:
+ return 0;
case GT:
return 1;
default:
- return 0;
+ return null;
}
} catch (HyracksDataException e) {
- return 0;
+ return null;
}
}
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.01.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.01.ddl.sqlpp
new file mode 100644
index 0000000..acd3728
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.01.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: two range predicates on one key of a B-tree index, in both orders, which the search has to merge
+ * into one bound: the tighter value with its own inclusiveness.
+ * Expected Result: Success
+ */
+
+DROP DATAVERSE test IF EXISTS;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE TYPE T AS { id: bigint, d: bigint };
+CREATE DATASET ds(T) PRIMARY KEY id;
+CREATE INDEX idx_d ON ds(d);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.02.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.02.update.sqlpp
new file mode 100644
index 0000000..e32e33d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.02.update.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+INSERT INTO ds (SELECT VALUE {"id": i, "d": i % 20} FROM range(1, 200) i);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.query.sqlpp
new file mode 100644
index 0000000..60f1074
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.d > 5 AND d.d >= 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.query.sqlpp
new file mode 100644
index 0000000..af81691
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.d > 7 AND d.d >= 9;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.query.sqlpp
new file mode 100644
index 0000000..1d9ade7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.d < 10 AND d.d <= 8;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.query.sqlpp
new file mode 100644
index 0000000..94b9121
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.d < 7 AND d.d <= 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.query.sqlpp
new file mode 100644
index 0000000..ecad582
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id > 5 AND d.id >= 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.query.sqlpp
new file mode 100644
index 0000000..0aa55f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id >= 7 AND d.id > 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.query.sqlpp
new file mode 100644
index 0000000..b75609b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id >= 9 AND d.id > 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.query.sqlpp
new file mode 100644
index 0000000..7287366
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id > 7 AND d.id >= 9;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.query.sqlpp
new file mode 100644
index 0000000..1838525
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id < 10 AND d.id <= 8;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.query.sqlpp
new file mode 100644
index 0000000..d87b2c3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id <= 8 AND d.id < 10;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.query.sqlpp
new file mode 100644
index 0000000..cfb01ab
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id <= 5 AND d.id < 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.query.sqlpp
new file mode 100644
index 0000000..51021a9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id < 7 AND d.id <= 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.query.sqlpp
new file mode 100644
index 0000000..c42565a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id >= 7 AND d.id > 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.query.sqlpp
new file mode 100644
index 0000000..d4d0bad
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id > 7 AND d.id >= 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.adm
new file mode 100644
index 0000000..fd03ab2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.03.adm
@@ -0,0 +1 @@
+130
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.adm
new file mode 100644
index 0000000..bc6298e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.04.adm
@@ -0,0 +1 @@
+110
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.adm
new file mode 100644
index 0000000..d61f00d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.05.adm
@@ -0,0 +1 @@
+90
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.adm
new file mode 100644
index 0000000..abdfb05
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.06.adm
@@ -0,0 +1 @@
+60
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.adm
new file mode 100644
index 0000000..205a12b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.07.adm
@@ -0,0 +1 @@
+194
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.adm
new file mode 100644
index 0000000..205a12b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.08.adm
@@ -0,0 +1 @@
+194
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.adm
new file mode 100644
index 0000000..86a0307
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.09.adm
@@ -0,0 +1 @@
+192
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.adm
new file mode 100644
index 0000000..86a0307
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.10.adm
@@ -0,0 +1 @@
+192
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.adm
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.11.adm
@@ -0,0 +1 @@
+8
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.adm
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.12.adm
@@ -0,0 +1 @@
+8
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.adm
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.13.adm
@@ -0,0 +1 @@
+5
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.adm
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.14.adm
@@ -0,0 +1 @@
+5
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.adm
new file mode 100644
index 0000000..2455a46
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.15.adm
@@ -0,0 +1 @@
+193
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.adm
new file mode 100644
index 0000000..2455a46
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range/btree-index-redundant-range.16.adm
@@ -0,0 +1 @@
+193
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index 681f730..9479b69 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -6806,6 +6806,11 @@
</compilation-unit>
</test-case>
<test-case FilePath="index-selection">
+ <compilation-unit name="btree-index-redundant-range">
+ <output-dir compare="Text">btree-index-redundant-range</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="index-selection">
<compilation-unit name="heterogeneous-index-complex-types">
<output-dir compare="Text">heterogeneous-index-complex-types</output-dir>
</compilation-unit>
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21896?usp=email
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I46a69f016ed50dbdb9c7b45f3451171f92f2f34e
Gerrit-Change-Number: 21896
Gerrit-PatchSet: 1
Gerrit-Owner: Ali Alsuliman <al...@gmail.com>