[NO ISSUE][COMP] Option to disable DisjunctivePredicateToJoinRule
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Added compiler option "rewrite_or_as_join" that
disables DisjunctivePredicateToJoinRule
set rewrite_or_as_join "false";
Default value is 'true' (the rule is enabled)
Change-Id: Ifbde19b7371a351d13ac2b05efa70a42eddbae7b
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3468
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/DisjunctivePredicateToJoinRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/DisjunctivePredicateToJoinRule.java
index 952c12b..7bfe6a4 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/DisjunctivePredicateToJoinRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/DisjunctivePredicateToJoinRule.java
@@ -54,11 +54,23 @@
import org.apache.hyracks.api.exceptions.SourceLocation;
public class DisjunctivePredicateToJoinRule implements IAlgebraicRewriteRule {
+ // Disable this rule if this option is set to 'false'
+ public static final String REWRITE_OR_AS_JOIN_OPTION = "rewrite_or_as_join";
+ private static final boolean REWRITE_OR_AS_JOIN_OPTION_DEFAULT = true;
+
+ private Boolean isRuleEnabled;
@Override
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
throws AlgebricksException {
MetadataProvider metadataProvider = (MetadataProvider) context.getMetadataProvider();
+ if (isRuleEnabled == null) {
+ isRuleEnabled =
+ metadataProvider.getBooleanProperty(REWRITE_OR_AS_JOIN_OPTION, REWRITE_OR_AS_JOIN_OPTION_DEFAULT);
+ }
+ if (!isRuleEnabled) {
+ return false;
+ }
if (metadataProvider.isBlockingOperatorDisabled()) {
return false;
}
@@ -207,5 +219,4 @@
FunctionIdentifier fi) {
return asFunctionCallExpression(ex.getValue(), fi);
}
-
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
index d971c1d..3ab908b 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
@@ -71,6 +71,7 @@
import org.apache.asterix.om.base.IAObject;
import org.apache.asterix.optimizer.base.AsterixOptimizationContext;
import org.apache.asterix.optimizer.base.FuzzyUtils;
+import org.apache.asterix.optimizer.rules.DisjunctivePredicateToJoinRule;
import org.apache.asterix.optimizer.rules.am.AbstractIntroduceAccessMethodRule;
import org.apache.asterix.runtime.job.listener.JobEventListenerFactory;
import org.apache.asterix.translator.CompiledStatements.ICompiledDmlStatement;
@@ -137,7 +138,8 @@
FuzzyUtils.SIM_THRESHOLD_PROP_NAME, StartFeedStatement.WAIT_FOR_COMPLETION,
FeedActivityDetails.FEED_POLICY_NAME, FeedActivityDetails.COLLECT_LOCATIONS,
SqlppQueryRewriter.INLINE_WITH_OPTION, SqlppExpressionToPlanTranslator.REWRITE_IN_AS_OR_OPTION,
- "hash_merge", "output-record-type", AbstractIntroduceAccessMethodRule.NO_INDEX_ONLY_PLAN_OPTION);
+ "hash_merge", "output-record-type", AbstractIntroduceAccessMethodRule.NO_INDEX_ONLY_PLAN_OPTION,
+ DisjunctivePredicateToJoinRule.REWRITE_OR_AS_JOIN_OPTION);
private final IRewriterFactory rewriterFactory;
private final IAstPrintVisitorFactory astPrintVisitorFactory;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-1.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-1.sqlpp
new file mode 100644
index 0000000..3d10793
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-1.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+ id : string,
+ idx : string,
+ `no-idx` : string
+};
+
+create dataset TestSet(TestType) primary key id;
+
+create index TestSetIndex on TestSet (idx) type btree;
+
+select element x
+from TestSet as x
+where ((x.id = 'one') or (x.id = 'two') or (x.id = 'two'))
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-2.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-2.sqlpp
new file mode 100644
index 0000000..80572e4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-2.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+ id : string,
+ idx : string,
+ `no-idx` : string
+};
+
+create dataset TestSet(TestType) primary key id;
+
+create index TestSetIndex on TestSet (idx) type btree;
+
+select element x
+from TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two') or (x.idx = 'two'))
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-3.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-3.sqlpp
new file mode 100644
index 0000000..fbe6266
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-3.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+
+create type test.TestType as
+{
+ id : string,
+ idx : string,
+ `no-idx` : string
+};
+
+create dataset TestSet(TestType) primary key id;
+
+create index TestSetIndex on TestSet (idx) type btree;
+
+select element x
+from TestSet as x
+where ((x.`no-idx` = 'one') or (x.`no-idx` = 'two') or (x.`no-idx` = 'two'))
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-4.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-4.sqlpp
new file mode 100644
index 0000000..d6fd74e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-4.sqlpp
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+set rewrite_or_as_join "false";
+
+create type test.TestType as
+{
+ id : string,
+ idx : string,
+ `no-idx` : string
+};
+
+create dataset TestSet(TestType) primary key id;
+
+create index TestSetIndex on TestSet (idx) type btree;
+
+select element x
+from TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two') or (x.idx = 'two'))
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-5.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-5.sqlpp
new file mode 100644
index 0000000..639b7c1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-5.sqlpp
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+set rewrite_or_as_join "false";
+
+create type test.TestType as
+{
+ id : string,
+ idx : string,
+ `no-idx` : string
+};
+
+create dataset TestSet(TestType) primary key id;
+
+create index TestSetIndex on TestSet (idx) type btree;
+
+select element x
+from TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two') or (x.idx = 'two'))
+limit 2
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-1.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-1.plan
new file mode 100644
index 0000000..634082d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-1.plan
@@ -0,0 +1,10 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- BTREE_SEARCH |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STABLE_SORT [$$20(ASC)] |PARTITIONED|
+ -- HASH_PARTITION_EXCHANGE [$$20] |PARTITIONED|
+ -- UNNEST |UNPARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |UNPARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-2.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-2.plan
new file mode 100644
index 0000000..7c71263
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-2.plan
@@ -0,0 +1,16 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- BTREE_SEARCH |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STABLE_SORT [$$22(ASC)] |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- BTREE_SEARCH |PARTITIONED|
+ -- BROADCAST_EXCHANGE |PARTITIONED|
+ -- UNNEST |UNPARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |UNPARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-3.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-3.plan
new file mode 100644
index 0000000..e160f3c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-3.plan
@@ -0,0 +1,15 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- HYBRID_HASH_JOIN [$$18][$$20] |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ -- BROADCAST_EXCHANGE |PARTITIONED|
+ -- UNNEST |UNPARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |UNPARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-4.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-4.plan
new file mode 100644
index 0000000..823079c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-4.plan
@@ -0,0 +1,11 @@
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- STREAM_SELECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-5.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-5.plan
new file mode 100644
index 0000000..343d920
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-5.plan
@@ -0,0 +1,12 @@
+-- DISTRIBUTE_RESULT |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- STREAM_LIMIT |UNPARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- SORT_MERGE_EXCHANGE [$$19(ASC) ] |PARTITIONED|
+ -- STREAM_LIMIT |PARTITIONED|
+ -- STREAM_PROJECT |PARTITIONED|
+ -- ASSIGN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- DATASOURCE_SCAN |PARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.query.sqlpp
index 2120ebc..a446597 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.query.sqlpp
@@ -19,8 +19,8 @@
use test;
-
select element x
from TestSet as x
where ((x.id = 'one') or (x.id = 'two') or (x.id = 'two'))
+order by x.id
;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.query.sqlpp
new file mode 100644
index 0000000..add645e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * 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 element x
+from TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two') or (x.idx = 'two'))
+order by x.id
+;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.query.sqlpp
new file mode 100644
index 0000000..1d36443
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.query.sqlpp
@@ -0,0 +1,26 @@
+/*
+ * 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 element x
+from TestSet as x
+where ((x.`no-idx` = 'one') or (x.`no-idx` = 'two') or (x.`no-idx` = 'two'))
+order by x.id
+;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.query.sqlpp
new file mode 100644
index 0000000..1c84456
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.query.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+/*
+ * Disable disjunctive predicate to join rewriting
+ */
+
+use test;
+
+set rewrite_or_as_join "false";
+
+select element x
+from TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two') or (x.idx = 'two'))
+order by x.id
+;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.query.sqlpp
new file mode 100644
index 0000000..5ac846c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.query.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+/*
+ * Disable disjunctive predicate to join rewriting (with LIMIT clause)
+ */
+
+use test;
+
+set rewrite_or_as_join "false";
+
+select element x
+from TestSet as x
+where ((x.idx = 'one') or (x.idx = 'two') or (x.idx = 'two'))
+order by x.id
+limit 2
+;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.adm
similarity index 100%
copy from asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm
copy to asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.adm
similarity index 100%
copy from asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm
copy to asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.adm
similarity index 100%
copy from asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm
copy to asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.adm
similarity index 100%
copy from asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.1.adm
copy to asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.ast
index 9f0ab9e..d8cf84b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.3.ast
@@ -37,3 +37,10 @@
LiteralExpr [STRING] [two]
]
]
+Orderby
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=id
+ ]
+ ASC
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.ast
new file mode 100644
index 0000000..99293e3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.4.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=$x ]
+]
+FROM [ FunctionCall asterix.dataset@1[
+ LiteralExpr [STRING] [test.TestSet]
+ ]
+ AS Variable [ Name=$x ]
+]
+Where
+ OperatorExpr [
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [one]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ ]
+Orderby
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=id
+ ]
+ ASC
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.ast
new file mode 100644
index 0000000..fc7a792
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.5.ast
@@ -0,0 +1,46 @@
+DataverseUse test
+Query:
+SELECT ELEMENT [
+Variable [ Name=$x ]
+]
+FROM [ FunctionCall asterix.dataset@1[
+ LiteralExpr [STRING] [test.TestSet]
+ ]
+ AS Variable [ Name=$x ]
+]
+Where
+ OperatorExpr [
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=no-idx
+ ]
+ =
+ LiteralExpr [STRING] [one]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=no-idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=no-idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ ]
+Orderby
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=id
+ ]
+ ASC
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.ast
new file mode 100644
index 0000000..9a28dcd
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.6.ast
@@ -0,0 +1,47 @@
+DataverseUse test
+Set rewrite_or_as_join=false
+Query:
+SELECT ELEMENT [
+Variable [ Name=$x ]
+]
+FROM [ FunctionCall asterix.dataset@1[
+ LiteralExpr [STRING] [test.TestSet]
+ ]
+ AS Variable [ Name=$x ]
+]
+Where
+ OperatorExpr [
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [one]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ ]
+Orderby
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=id
+ ]
+ ASC
+
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.ast
new file mode 100644
index 0000000..19f8074
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/index-selection/disjunctive-predicate-1/disjunctive-predicate-1.7.ast
@@ -0,0 +1,49 @@
+DataverseUse test
+Set rewrite_or_as_join=false
+Query:
+SELECT ELEMENT [
+Variable [ Name=$x ]
+]
+FROM [ FunctionCall asterix.dataset@1[
+ LiteralExpr [STRING] [test.TestSet]
+ ]
+ AS Variable [ Name=$x ]
+]
+Where
+ OperatorExpr [
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [one]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ or
+ OperatorExpr [
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=idx
+ ]
+ =
+ LiteralExpr [STRING] [two]
+ ]
+ ]
+Orderby
+ FieldAccessor [
+ Variable [ Name=$x ]
+ Field=id
+ ]
+ ASC
+
+Limit
+ LiteralExpr [LONG] [2]