>From Ali Alsuliman <[email protected]>:

Ali Alsuliman has submitted this change. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20990?usp=email )

Change subject: [ASTERIXDB-3748][COMP] Initialize chosen indexes
......................................................................

[ASTERIXDB-3748][COMP] Initialize chosen indexes

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
When analyzed access methods is initialized, initialize
the chosen indexes also for the current new iteration.

Ext-ref: MB-71166

Change-Id: I7103f39e2c2e5a45b2fb60b6cff015f0da035ce1
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20990
Tested-by: Ali Alsuliman <[email protected]>
Integration-Tests: Ali Alsuliman <[email protected]>
Reviewed-by: Ali Alsuliman <[email protected]>
---
M 
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/metadata_only_02/metadata_only_02.4.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/misc/metadata_only_02/metadata_only_02.4.adm
3 files changed, 57 insertions(+), 0 deletions(-)

Approvals:
  Ali Alsuliman: Looks good to me, approved; Verified; Verified




diff --git 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
index dbb164a..638d6d9 100644
--- 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
+++ 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceSelectAccessMethodRule.java
@@ -504,6 +504,10 @@
             // whether an available index can be applicable or not.
             if (!checkApplicableOnly && continueCheck) {
                 analyzedAMs = new TreeMap<>();
+                // we need to clear the chosenIndexes as well, if we do not
+                // in nested queries we might get to a situation where we
+                // have chosenIndexes from the previous check.
+                chosenIndexes = new ArrayList<>();
             }

             if (continueCheck && 
context.getPhysicalOptimizationConfig().isArrayIndexEnabled()
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/metadata_only_02/metadata_only_02.4.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/metadata_only_02/metadata_only_02.4.query.sqlpp
new file mode 100644
index 0000000..7661da5
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/metadata_only_02/metadata_only_02.4.query.sqlpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/*
+ * The query tests fix for ASTERIXDB-3038
+ */
+
+SET `rewrite_or_as_join` "false";
+
+select syn.DataverseName, syn.SynonymName
+from Metadata.`Synonym` as syn
+where syn.ObjectDataverseName in
+  ["test1", "test2"]
+and syn.ObjectName in (
+  select value ds.DatasetName
+  from Metadata.`Dataset` as ds
+  where ds.DataverseName in
+    ["test1", "test2"]
+  and ds.DatasetName in
+    ["ds1", "ds2"])
+  or syn.ObjectName in (
+    select value syn1.SynonymName
+    from Metadata.`Synonym` as syn1
+    where syn1.SynonymName in
+      ["syn1", "syn2"]
+    and syn1.ObjectName in (
+      select value ds1.DatasetName
+      from Metadata.`Dataset` as ds1
+      where ds1.DataverseName in
+        ["test1", "test2"]
+      and ds1.DatasetName in
+        ["ds1", "ds2"]
+    )
+  )
+order by syn.DataverseName, syn.SynonymName;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/metadata_only_02/metadata_only_02.4.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/metadata_only_02/metadata_only_02.4.adm
new file mode 100644
index 0000000..743bb8a
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/metadata_only_02/metadata_only_02.4.adm
@@ -0,0 +1,2 @@
+{ "DataverseName": "test1", "SynonymName": "syn1" }
+{ "DataverseName": "test2", "SynonymName": "syn2" }
\ No newline at end of file

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20990?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: asterixdb
Gerrit-Branch: phoenix
Gerrit-Change-Id: I7103f39e2c2e5a45b2fb60b6cff015f0da035ce1
Gerrit-Change-Number: 20990
Gerrit-PatchSet: 9
Gerrit-Owner: Shahrzad Shirazi <[email protected]>
Gerrit-Reviewer: Ali Alsuliman <[email protected]>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <[email protected]>

Reply via email to