You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by dl...@apache.org on 2018/02/27 05:38:38 UTC

asterixdb git commit: [ASTERIXDB-2302][COMP] Incorrect result with non-enforced index

Repository: asterixdb
Updated Branches:
  refs/heads/master bf777cba9 -> b8bf7aa92


[ASTERIXDB-2302][COMP] Incorrect result with non-enforced index

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

Details:
- Incorrect result returned when a non-enforced index is created
  as integer type, but probed with double value

Change-Id: I236c4c92d82bc3292193b2eb0f9b771042b3ca1a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2425
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Taewoo Kim <wa...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/b8bf7aa9
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/b8bf7aa9
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/b8bf7aa9

Branch: refs/heads/master
Commit: b8bf7aa92786127a97d049a764ff76c28a92d94e
Parents: bf777cb
Author: Dmitry Lychagin <dm...@couchbase.com>
Authored: Mon Feb 26 16:38:32 2018 -0800
Committer: Dmitry Lychagin <dm...@couchbase.com>
Committed: Mon Feb 26 21:38:24 2018 -0800

----------------------------------------------------------------------
 .../optimizer/rules/am/AccessMethodUtils.java   |  5 +-
 .../btree-index-04/btree-index-04.1.ddl.sqlpp   | 33 ++++++++
 .../btree-index-04/btree-index-04.2.update.ddl  | 84 ++++++++++++++++++++
 .../btree-index-04/btree-index-04.3.ddl.sqlpp   | 22 +++++
 .../btree-index-04/btree-index-04.4.query.sqlpp | 25 ++++++
 .../btree-index-04/btree-index-04.4.adm         |  2 +
 .../resources/runtimets/testsuite_sqlpp.xml     | 15 ++--
 7 files changed, 178 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b8bf7aa9/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
index 9950e37..eafbdaf 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
@@ -499,8 +499,7 @@ public class AccessMethodUtils {
                 // In this case, we need to change the search parameter. Refer to the caller section for the detail.
                 realTypeConvertedToIntegerType =
                         isRealTypeConvertedToIntegerType(constantValueTag, indexedFieldTypeTag);
-                if (realTypeConvertedToIntegerType && !index.isEnforced() && !index.isOverridingKeyFieldTypes()) {
-                    // For the index on a closed-type field,
+                if (realTypeConvertedToIntegerType) {
                     // if a DOUBLE or FLOAT constant is converted to an INT type value,
                     // we need to check a corner case where two real values are located
                     // between an INT value. For example, the following query,
@@ -564,7 +563,7 @@ public class AccessMethodUtils {
                             // NEQ should not be a case.
                             throw new IllegalStateException();
                     }
-                } else if (!realTypeConvertedToIntegerType) {
+                } else {
                     // Type conversion only case: (e.g., INT -> BIGINT)
                     replacedConstantValue = getReplacedConstantValue(constantValue.getObject(), constantValueTag,
                             indexedFieldTypeTag, index.isEnforced(), TypeCastingMathFunctionType.NONE);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b8bf7aa9/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.1.ddl.sqlpp
new file mode 100644
index 0000000..f215764
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.1.ddl.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.
+ */
+/*
+* Description  : Index selection for non-enforced indexes
+* Expected Res : Success
+* Date         : 26 Feb 2018
+*/
+drop dataverse test if exists;
+create dataverse test;
+use test;
+
+create type TestOpenType as open {
+  c_id: int64
+};
+
+create dataset TestOpen(TestOpenType)
+primary key c_id;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b8bf7aa9/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.2.update.ddl
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.2.update.ddl b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.2.update.ddl
new file mode 100644
index 0000000..a910cf8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.2.update.ddl
@@ -0,0 +1,84 @@
+/*
+ * 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 TestOpen ({
+    "c_id": 1,
+    "c_x": 1,
+    "c_s": "hello",
+    "c_i64": 2,
+    "c_i8": 2,
+    "c_d": 2
+});
+insert into TestOpen ({
+    "c_id": 2,
+    "c_x": 2,
+    "c_s": 2,
+    "c_i64": "2",
+    "c_i8": 2.5,
+    "c_d": 3
+});
+insert into TestOpen ({
+    "c_id": 3,
+    "c_x": 3,
+    "c_s": "world",
+    "c_i64": 2,
+    "c_i8": 4,
+    "c_d": 3.125
+});
+insert into TestOpen ({
+    "c_id": 4,
+    "c_x": 4,
+    "c_s": null,
+    "c_i64": null,
+    "c_i8": 500,
+    "c_d": 3.25
+});
+insert into TestOpen ({
+    "c_id": 5,
+    "c_x": 5,
+    "c_s": "hello",
+    "c_i64": 2.25,
+    "c_i8": 10000.25,
+    "c_d": 3.5
+});
+insert into TestOpen ({
+    "c_id": 6,
+    "c_x": 6,
+    "c_s": false,
+    "c_i64": false,
+    "c_i8": 2e100,
+    "c_d": 2e100
+});
+insert into TestOpen ({
+    "c_id": 7,
+    "c_x": 7,
+    "c_s": "world",
+    "c_i64": 3
+});
+insert into TestOpen ({
+    "c_id": 8,
+    "c_x": 8
+});
+insert into TestOpen ({
+    "c_id": 9,
+    "c_x": 9,
+    "c_d": 3.25
+});

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b8bf7aa9/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.3.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.3.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.3.ddl.sqlpp
new file mode 100644
index 0000000..df03a1b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.3.ddl.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;
+
+create index idx_i64_on_d on TestOpen(c_d:int64);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b8bf7aa9/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.query.sqlpp
new file mode 100644
index 0000000..0e4837a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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 t.c_x
+from TestOpen t
+where t.c_d = 3.25
+order by t.c_x;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b8bf7aa9/asterixdb/asterix-app/src/test/resources/runtimets/results/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.adm
new file mode 100644
index 0000000..05d6df6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.adm
@@ -0,0 +1,2 @@
+4
+9
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/b8bf7aa9/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 96dbf01..4265163 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3966,11 +3966,16 @@
           <output-dir compare="Text">btree-index-03</output-dir>
         </compilation-unit>
       </test-case>
-    <test-case FilePath="open-index-non-enforced/correlated-index-selection">
-      <compilation-unit name="btree-index-01">
-        <output-dir compare="Text">btree-index-01</output-dir>
-      </compilation-unit>
-    </test-case>
+      <test-case FilePath="open-index-non-enforced/index-selection">
+        <compilation-unit name="btree-index-04">
+          <output-dir compare="Text">btree-index-04</output-dir>
+        </compilation-unit>
+      </test-case>
+      <test-case FilePath="open-index-non-enforced/correlated-index-selection">
+        <compilation-unit name="btree-index-01">
+          <output-dir compare="Text">btree-index-01</output-dir>
+        </compilation-unit>
+      </test-case>
     </test-group>
     <test-group name="open-index-non-enforced/index-join">
       <test-case FilePath="open-index-non-enforced/index-join">