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/03/02 00:56:35 UTC

asterixdb git commit: [ASTERIXDB-2307][COMP] Incorrect result with quantified expression

Repository: asterixdb
Updated Branches:
  refs/heads/master 098360634 -> c166adc34


[ASTERIXDB-2307][COMP] Incorrect result with quantified expression

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

Details:
- Fixed incorrect result with EVERY quantified expression
  when its condition returns NULL/MISSING

Change-Id: I9e282071c87a9551829c31af43909970d307e417
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2441
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: 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/c166adc3
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/c166adc3
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/c166adc3

Branch: refs/heads/master
Commit: c166adc3464d9afe45b2b3cfaea27227dee07767
Parents: 0983606
Author: Dmitry Lychagin <dm...@couchbase.com>
Authored: Thu Mar 1 12:09:36 2018 -0800
Committer: Dmitry Lychagin <dm...@couchbase.com>
Committed: Thu Mar 1 16:56:16 2018 -0800

----------------------------------------------------------------------
 .../LangExpressionToPlanTranslator.java         | 14 ++++--
 .../query-ASTERIXDB-2307.1.ddl.sqlpp            | 29 ++++++++++++
 .../query-ASTERIXDB-2307.2.update.sqlpp         | 48 ++++++++++++++++++++
 .../query-ASTERIXDB-2307.3.query.sqlpp          | 26 +++++++++++
 .../query-ASTERIXDB-2307.4.query.sqlpp          | 28 ++++++++++++
 .../query-ASTERIXDB-2307.3.adm                  |  1 +
 .../query-ASTERIXDB-2307.4.adm                  |  1 +
 .../resources/runtimets/testsuite_sqlpp.xml     |  5 ++
 8 files changed, 149 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
index 8b072c7..2b7adc1 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
@@ -84,6 +84,7 @@ import org.apache.asterix.metadata.entities.Function;
 import org.apache.asterix.metadata.entities.InternalDatasetDetails;
 import org.apache.asterix.metadata.functions.ExternalFunctionCompilerUtil;
 import org.apache.asterix.metadata.utils.DatasetUtil;
+import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.base.AInt64;
 import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.constants.AsterixConstantValue;
@@ -1087,10 +1088,17 @@ class LangExpressionToPlanTranslator
             fAgg = BuiltinFunctions.makeAggregateFunctionExpression(BuiltinFunctions.NON_EMPTY_STREAM,
                     new ArrayList<>());
         } else { // EVERY
-            List<Mutable<ILogicalExpression>> satExprList = new ArrayList<>(1);
-            satExprList.add(new MutableObject<>(eo2.first));
+            List<Mutable<ILogicalExpression>> ifMissingOrNullArgs = new ArrayList<>(2);
+            ifMissingOrNullArgs.add(new MutableObject<>(eo2.first));
+            ifMissingOrNullArgs
+                    .add(new MutableObject<>(new ConstantExpression(new AsterixConstantValue(ABoolean.FALSE))));
+
+            List<Mutable<ILogicalExpression>> notArgs = new ArrayList<>(1);
+            notArgs.add(new MutableObject<>(new ScalarFunctionCallExpression(
+                    FunctionUtil.getFunctionInfo(BuiltinFunctions.IF_MISSING_OR_NULL), ifMissingOrNullArgs)));
+
             s = new SelectOperator(new MutableObject<>(new ScalarFunctionCallExpression(
-                    FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.NOT), satExprList)), false, null);
+                    FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.NOT), notArgs)), false, null);
             s.getInputs().add(eo2.second);
             fAgg = BuiltinFunctions.makeAggregateFunctionExpression(BuiltinFunctions.EMPTY_STREAM, new ArrayList<>());
         }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.1.ddl.sqlpp
new file mode 100644
index 0000000..bded8c0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.1.ddl.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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 CustomerType as open {
+  custid : string
+};
+
+create  dataset customers(CustomerType) primary key custid;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.2.update.sqlpp
new file mode 100644
index 0000000..ba002ef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.2.update.sqlpp
@@ -0,0 +1,48 @@
+/*
+ * 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 customers
+select value t
+from  [
+  { "custid": "C1",
+    "name": "James",
+    "rating": 750
+  },
+  { "custid": "C2",
+    "name": "Mary",
+    "rating": 690
+  },
+  { "custid": "C3",
+    "name": "John"
+  },
+  { "custid": "C4",
+    "name": "Patricia",
+    "rating": null
+  },
+  { "custid": "C5",
+    "name": "Robert",
+    "rating": 750
+  },
+  { "custid": "C6",
+    "name": "Jennifer",
+    "rating": 640
+  }
+] as t

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.query.sqlpp
new file mode 100644
index 0000000..1d1cda1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.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 VALUE COUNT(c1.name)
+FROM customers AS c1
+WHERE EVERY r IN
+   (SELECT VALUE c2.rating FROM customers AS c2)
+SATISFIES c1.rating >= r
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.query.sqlpp
new file mode 100644
index 0000000..2f17401
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.query.sqlpp
@@ -0,0 +1,28 @@
+/*
+ * 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(c1.name)
+FROM customers AS c1
+WHERE EVERY r IN
+   (SELECT VALUE c2.rating
+    FROM customers AS c2
+    WHERE c2.rating IS NOT UNKNOWN)
+SATISFIES c1.rating >= r;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.adm
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.3.adm
@@ -0,0 +1 @@
+0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.adm
new file mode 100644
index 0000000..d8263ee
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/quantifiers/query-ASTERIXDB-2307/query-ASTERIXDB-2307.4.adm
@@ -0,0 +1 @@
+2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c166adc3/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 9fc0b4b..09fc832 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -5412,6 +5412,11 @@
         <output-dir compare="Text">query-ASTERIXDB-1674</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="quantifiers">
+        <compilation-unit name="query-ASTERIXDB-2307">
+        <output-dir compare="Text">query-ASTERIXDB-2307</output-dir>
+      </compilation-unit>
+    </test-case>
     <!--
         <test-case FilePath="quantifiers">
           <compilation-unit name="everysat_02">