Dmitry Lychagin has submitted this change and it was merged. Change subject: [ASTERIXDB-2302][COMP] Incorrect result with non-enforced index ......................................................................
[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 <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Taewoo Kim <wangs...@gmail.com> --- M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java 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 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 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 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 A asterixdb/asterix-app/src/test/resources/runtimets/results/open-index-non-enforced/index-selection/btree-index-04/btree-index-04.4.adm M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml 7 files changed, 178 insertions(+), 8 deletions(-) Approvals: Anon. E. Moose #1000171: Taewoo Kim: Looks good to me, approved Jenkins: Verified; No violations found; ; Verified 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 @@ // 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 @@ // 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); 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; 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 +}); 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); 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 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 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"> -- To view, visit https://asterix-gerrit.ics.uci.edu/2425 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I236c4c92d82bc3292193b2eb0f9b771042b3ca1a Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Gerrit-Reviewer: Taewoo Kim <taew...@uci.edu> Gerrit-Reviewer: Taewoo Kim <wangs...@gmail.com>