asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yingyi Bu (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: ASTERIXDB-1689: fix type computers for type functions.
Date Wed, 12 Oct 2016 05:58:32 GMT
Yingyi Bu has submitted this change and it was merged.

Change subject: ASTERIXDB-1689: fix type computers for type functions.
......................................................................


ASTERIXDB-1689: fix type computers for type functions.

Change-Id: Ic8a0cf1b44a4b4542e63b8abd6774dcc68839d2c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1268
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
---
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.adm
M asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
M asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
M asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
A asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOrMissingTypeComputer.java
M asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
7 files changed, 82 insertions(+), 16 deletions(-)

Approvals:
  Till Westmann: Looks good to me, approved
  Jenkins: Verified; No violations found



diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.query.sqlpp
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.query.sqlpp
new file mode 100644
index 0000000..51d6df8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.query.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.
+ */
+
+SELECT compare
+FROM [ {"a":1} ] t
+LET compare = (t.b is null);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.adm
b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.adm
new file mode 100644
index 0000000..6578fd5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/query-ASTERIXDB-1689/query-ASTERIXDB-1689.1.adm
@@ -0,0 +1 @@
+{  }
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 48fa1cd..ada8989 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4014,6 +4014,11 @@
         <output-dir compare="Text">is</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="null-missing">
+      <compilation-unit name="query-ASTERIXDB-1689">
+        <output-dir compare="Text">query-ASTERIXDB-1689</output-dir>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="numeric">
     <test-case FilePath="numeric">
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
index ca7c0b0..d247350 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
@@ -172,14 +172,6 @@
         addNullOrMissingField(fid, value.getByteArray(), value.getStartOffset());
     }
 
-    public void addField(int fid, byte[] value) {
-        closedPartOffsets[fid] = closedPartOutputStream.size();
-        // We assume the tag is not included (closed field)
-        closedPartOutputStream.write(value, 0, value.length);
-        numberOfClosedFields++;
-        addNullOrMissingField(fid, value, 0);
-    }
-
     private void addNullOrMissingField(int fid, byte[] data, int offset) {
         if (containsOptionalField) {
             byte nullByte = (byte) (1 << (7 - 2 * (fid % 4)));
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
index 80f13d6..873ea9e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -55,6 +55,7 @@
 import org.apache.asterix.om.typecomputer.impl.AnyTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.BooleanFunctionTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.BooleanOnlyTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.BooleanOrMissingTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.CastTypeComputer;
 import org.apache.asterix.om.typecomputer.impl.ClosedRecordConstructorResultType;
 import org.apache.asterix.om.typecomputer.impl.CollectionMemberResultType;
@@ -801,15 +802,15 @@
 
         // first, take care of Algebricks builtin functions
         addFunction(IS_MISSING, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(IS_NULL, BooleanOnlyTypeComputer.INSTANCE, true);
         addFunction(IS_UNKOWN, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(IS_SYSTEM_NULL, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(IS_BOOLEAN, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(IS_NUMBER, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(IS_STRING, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(IS_ARRAY, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(IS_OBJECT, BooleanOnlyTypeComputer.INSTANCE, true);
-        addFunction(NOT, BooleanFunctionTypeComputer.INSTANCE, true);
+        addFunction(IS_NULL, BooleanOrMissingTypeComputer.INSTANCE, true);
+        addFunction(IS_SYSTEM_NULL, ABooleanTypeComputer.INSTANCE, true);
+        addFunction(IS_BOOLEAN, ABooleanTypeComputer.INSTANCE, true);
+        addFunction(IS_NUMBER, ABooleanTypeComputer.INSTANCE, true);
+        addFunction(IS_STRING, ABooleanTypeComputer.INSTANCE, true);
+        addFunction(IS_ARRAY, ABooleanTypeComputer.INSTANCE, true);
+        addFunction(IS_OBJECT, ABooleanTypeComputer.INSTANCE, true);
+        addFunction(NOT, ABooleanTypeComputer.INSTANCE, true);
 
         addPrivateFunction(EQ, BooleanFunctionTypeComputer.INSTANCE, true);
         addPrivateFunction(LE, BooleanFunctionTypeComputer.INSTANCE, true);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOrMissingTypeComputer.java
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOrMissingTypeComputer.java
new file mode 100644
index 0000000..982971a
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOrMissingTypeComputer.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class BooleanOrMissingTypeComputer implements IResultTypeComputer {
+
+    public static final BooleanOrMissingTypeComputer INSTANCE = new BooleanOrMissingTypeComputer();
+
+    private BooleanOrMissingTypeComputer() {
+    }
+
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        return AUnionType.createMissableType(BuiltinType.ABOOLEAN);
+    }
+
+}
diff --git a/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
b/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
index 760fd18..f48aa7c 100644
--- a/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
+++ b/asterixdb/asterix-om/src/test/java/org/apache/asterix/om/typecomputer/TypeComputerTest.java
@@ -61,6 +61,7 @@
         exceptionalTypeComputers.add("AMissingTypeComputer");
         exceptionalTypeComputers.add("NullableDoubleTypeComputer");
         exceptionalTypeComputers.add("RecordMergeTypeComputer");
+        exceptionalTypeComputers.add("BooleanOrMissingTypeComputer");
 
         // Tests all usual type computers.
         Reflections reflections = new Reflections("org.apache.asterix.om.typecomputer", new
SubTypesScanner(false));

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1268
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic8a0cf1b44a4b4542e63b8abd6774dcc68839d2c
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Yingyi Bu <buyingyi@gmail.com>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <tillw@apache.org>
Gerrit-Reviewer: Yingyi Bu <buyingyi@gmail.com>

Mime
View raw message