asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [16/22] incubator-asterixdb git commit: ASTERIXDB-1228: Add MISSING into the data model.
Date Tue, 24 May 2016 01:31:34 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
new file mode 100644
index 0000000..e45c4cc
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+abstract public class AbstractStringTypeComputer extends AbstractResultTypeComputer {
+
+    @Override
+    protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+        if (type.getTypeTag() != ATypeTag.STRING) {
+            throw new AlgebricksException("The input type for input argument " + argIndex + "(" + type.getDisplayName()
+                    + ")" + " is not expected.");
+        }
+    }
+
+    @Override
+    protected abstract IAType getResultType(IAType... strippedInputTypes);
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractTripleStringTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractTripleStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractTripleStringTypeComputer.java
deleted file mode 100644
index a322ef9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractTripleStringTypeComputer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.ATypeTag;
-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.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-/**
- * @author Xiaoyu Ma
- */
-public abstract class AbstractTripleStringTypeComputer implements IResultTypeComputer {
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        if (fce.getArguments().size() < 3)
-            throw new AlgebricksException("Wrong Argument Number.");
-        ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
-        ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
-        ILogicalExpression arg2 = fce.getArguments().get(2).getValue();
-        IAType t0, t1, t2;
-        try {
-            t0 = (IAType) env.getType(arg0);
-            t1 = (IAType) env.getType(arg1);
-            t2 = (IAType) env.getType(arg2);
-        } catch (AlgebricksException e) {
-            throw new AlgebricksException(e);
-        }
-        if ((t0.getTypeTag() != ATypeTag.NULL && t0.getTypeTag() != ATypeTag.STRING)
-                || (t1.getTypeTag() != ATypeTag.NULL && t1.getTypeTag() != ATypeTag.STRING)
-                || (t2.getTypeTag() != ATypeTag.NULL && t2.getTypeTag() != ATypeTag.STRING)) {
-            throw new AlgebricksException("Expects String Type.");
-        }
-
-        return getResultType(t0, t1, t2);
-    }
-
-    public abstract IAType getResultType(IAType t0, IAType t1, IAType t2);
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryBooleanOrNullFunctionTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryBooleanOrNullFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryBooleanOrNullFunctionTypeComputer.java
deleted file mode 100644
index 3c5f1e7..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryBooleanOrNullFunctionTypeComputer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-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.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class BinaryBooleanOrNullFunctionTypeComputer implements IResultTypeComputer {
-
-    public static final BinaryBooleanOrNullFunctionTypeComputer INSTANCE = new BinaryBooleanOrNullFunctionTypeComputer();
-
-    private BinaryBooleanOrNullFunctionTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
-        ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
-        IAType t0, t1;
-        try {
-            t0 = (IAType) env.getType(arg0);
-            t1 = (IAType) env.getType(arg1);
-        } catch (AlgebricksException e) {
-            throw new AlgebricksException(e);
-        }
-        if (t0.getTypeTag() == ATypeTag.NULL && t1.getTypeTag() == ATypeTag.NULL) {
-            return BuiltinType.ANULL;
-        }
-        if (TypeHelper.canBeNull(t0) || TypeHelper.canBeNull(t1)) {
-            return AUnionType.createNullableType(BuiltinType.ABOOLEAN);
-        }
-        return BuiltinType.ABOOLEAN;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringBoolOrNullTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringBoolOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringBoolOrNullTypeComputer.java
deleted file mode 100644
index 6d46533..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringBoolOrNullTypeComputer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringBoolOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
-    public static final BinaryStringBoolOrNullTypeComputer INSTANCE = new BinaryStringBoolOrNullTypeComputer();
-
-    private BinaryStringBoolOrNullTypeComputer() {
-    }
-
-    @Override
-    public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
-        if (nullable) {
-            return AUnionType.createNullableType(BuiltinType.ABOOLEAN);
-        }
-        return BuiltinType.ABOOLEAN;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
deleted file mode 100644
index 55df1e3..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringStringOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
-
-    public static final BinaryStringStringOrNullTypeComputer INSTANCE = new BinaryStringStringOrNullTypeComputer();
-
-    private BinaryStringStringOrNullTypeComputer() {
-    }
-
-    @Override
-    public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
-        if (nullable) {
-            return AUnionType.createNullableType(BuiltinType.ASTRING);
-        }
-        return BuiltinType.ASTRING;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
new file mode 100644
index 0000000..fa944c6
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
@@ -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.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+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 BooleanFunctionTypeComputer extends AbstractResultTypeComputer {
+
+    public static final BooleanFunctionTypeComputer INSTANCE = new BooleanFunctionTypeComputer();
+
+    private BooleanFunctionTypeComputer() {
+    }
+
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        // Boolean type computer doesn't follow the null/missing-in/out semantics.
+        return TypeComputeUtils.resolveResultType(expression, env, (index, type) -> checkArgType(index, type),
+                types -> getResultType(types), false);
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        return BuiltinType.ABOOLEAN;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOnlyTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOnlyTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOnlyTypeComputer.java
new file mode 100644
index 0000000..27bf16c
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOnlyTypeComputer.java
@@ -0,0 +1,42 @@
+/*
+ * 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.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 BooleanOnlyTypeComputer implements IResultTypeComputer {
+
+    public static final BooleanOnlyTypeComputer INSTANCE = new BooleanOnlyTypeComputer();
+
+    private BooleanOnlyTypeComputer() {
+    }
+
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        return BuiltinType.ABOOLEAN;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java
index 2a65d60..fc4242d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java
@@ -20,7 +20,7 @@
 package org.apache.asterix.om.typecomputer.impl;
 
 import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -41,6 +41,6 @@ public class CastListResultTypeComputer implements IResultTypeComputer {
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         ScalarFunctionCallExpression funcExpr = (ScalarFunctionCallExpression) expression;
-        return TypeComputerUtilities.getRequiredType(funcExpr);
+        return TypeCastUtils.getRequiredType(funcExpr);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java
index 039b35f..e95571b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java
@@ -19,7 +19,7 @@
 package org.apache.asterix.om.typecomputer.impl;
 
 import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -35,6 +35,6 @@ public class CastRecordResultTypeComputer implements IResultTypeComputer {
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         ScalarFunctionCallExpression funcExpr = (ScalarFunctionCallExpression) expression;
-        return TypeComputerUtilities.getRequiredType(funcExpr);
+        return TypeCastUtils.getRequiredType(funcExpr);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
index a435f7a..cccc13f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
@@ -24,8 +24,11 @@ import java.util.Iterator;
 import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.constants.AsterixConstantValue;
 import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
 import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.IAType;
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -48,9 +51,10 @@ public class ClosedRecordConstructorResultType implements IResultTypeComputer {
         /**
          * if type has been top-down propagated, use the enforced type
          */
-        ARecordType type = (ARecordType) TypeComputerUtilities.getRequiredType(f);
-        if (type != null)
+        ARecordType type = (ARecordType) TypeCastUtils.getRequiredType(f);
+        if (type != null) {
             return type;
+        }
 
         int n = f.getArguments().size() / 2;
         String[] fieldNames = new String[n];
@@ -59,6 +63,16 @@ public class ClosedRecordConstructorResultType implements IResultTypeComputer {
         Iterator<Mutable<ILogicalExpression>> argIter = f.getArguments().iterator();
         while (argIter.hasNext()) {
             ILogicalExpression e1 = argIter.next().getValue();
+            ILogicalExpression e2 = argIter.next().getValue();
+            IAType e2Type = (IAType) env.getType(e2);
+            if (e2Type.getTypeTag() == ATypeTag.MISSING) {
+                // Converts missing to null for a closed field.
+                e2Type = BuiltinType.ANULL;
+            } else if (e2Type.getTypeTag() == ATypeTag.UNION) {
+                AUnionType unionType = (AUnionType) e2Type;
+                e2Type = AUnionType.createNullableType(unionType.getActualType());
+            }
+            fieldTypes[i] = e2Type;
             if (e1.getExpressionTag() == LogicalExpressionTag.CONSTANT) {
                 ConstantExpression nameExpr = (ConstantExpression) e1;
                 fieldNames[i] = ((AString) ((AsterixConstantValue) nameExpr.getValue()).getObject()).getStringValue();
@@ -66,8 +80,6 @@ public class ClosedRecordConstructorResultType implements IResultTypeComputer {
                 throw new AlgebricksException(
                         "Field name " + i + "(" + e1 + ") in call to closed-record-constructor is not a constant.");
             }
-            ILogicalExpression e2 = argIter.next().getValue();
-            fieldTypes[i] = (IAType) env.getType(e2);
             i++;
         }
         return new ARecordType(null, fieldNames, fieldTypes, false);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
new file mode 100644
index 0000000..ecdb1d0
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
@@ -0,0 +1,54 @@
+/*
+ * 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.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+public class CollectionMemberResultType extends AbstractResultTypeComputer {
+
+    public static final CollectionMemberResultType INSTANCE = new CollectionMemberResultType();
+
+    protected CollectionMemberResultType() {
+
+    }
+
+    @Override
+    protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+        if (type.getTypeTag() != ATypeTag.UNORDEREDLIST && type.getTypeTag() != ATypeTag.ORDEREDLIST) {
+            throw new AlgebricksException("The input type for input argument " + argIndex + "(" + type.getDisplayName()
+                    + ")" + " is not expected.");
+        }
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        IAType type = strippedInputTypes[0];
+        if (type.getTypeTag() == ATypeTag.ANY) {
+            return BuiltinType.ANY;
+        }
+        IAType itemType = ((AbstractCollectionType) type).getItemType();
+        return itemType;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java
index 753f9b7..9e93b71 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java
@@ -18,16 +18,10 @@
  */
 package org.apache.asterix.om.typecomputer.impl;
 
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AbstractCollectionType;
 import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-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.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 
 /**
  * This function is to make a sequence of records and a singleton collection of records
@@ -35,26 +29,13 @@ import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
  *
  * @author yingyib
  */
-public class CollectionToSequenceTypeComputer implements IResultTypeComputer {
+public class CollectionToSequenceTypeComputer extends AbstractResultTypeComputer {
 
     public static final CollectionToSequenceTypeComputer INSTANCE = new CollectionToSequenceTypeComputer();
 
     @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression func = (AbstractFunctionCallExpression) expression;
-        ILogicalExpression arg = func.getArguments().get(0).getValue();
-
-        IAType argType = (IAType) env.getType(arg);
-        if (TypeHelper.canBeNull(argType)) {
-            IAType nonOptionalType = TypeHelper.getNonOptionalType(argType);
-            if (nonOptionalType.getTypeTag() == ATypeTag.ORDEREDLIST
-                    || nonOptionalType.getTypeTag() == ATypeTag.UNORDEREDLIST) {
-                /** if the collection is null, that corresponds to an empty sequence */
-                argType = nonOptionalType;
-            }
-        }
-
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        IAType argType = strippedInputTypes[0];
         ATypeTag argTypeTag = argType.getTypeTag();
         if (argTypeTag == ATypeTag.ORDEREDLIST || argTypeTag == ATypeTag.UNORDEREDLIST) {
             /** if the input is a singleton list, return it's item type if any */

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java
index cd68827..d6fc75d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java
@@ -19,14 +19,9 @@
 
 package org.apache.asterix.om.typecomputer.impl;
 
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
 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.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 
 /**
  * The type computer for concat-not-null.
@@ -34,29 +29,21 @@ import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
  *
  * @author yingyib
  */
-public class ConcatNonNullTypeComputer implements IResultTypeComputer {
+public class ConcatNonNullTypeComputer extends AbstractResultTypeComputer {
 
     public static final ConcatNonNullTypeComputer INSTANCE = new ConcatNonNullTypeComputer();
 
     @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-        if (f.getArguments().size() < 1) {
-            return BuiltinType.ANULL;
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        boolean any = false;
+        IAType currentType = null;
+        for (IAType type : strippedInputTypes) {
+            if (currentType != null && !type.equals(currentType)) {
+                any = true;
+                break;
+            }
+            currentType = type;
         }
-
-        TypeCompatibilityChecker tcc = new TypeCompatibilityChecker();
-        for (int i = 0; i < f.getArguments().size(); i++) {
-            ILogicalExpression arg = f.getArguments().get(i).getValue();
-            IAType type = (IAType) env.getType(arg);
-            tcc.addPossibleType(type);
-        }
-
-        IAType result = tcc.getCompatibleType();
-        if (result == null) {
-            throw new AlgebricksException("The two branches of the if-else clause should return the same type.");
-        }
-        return result;
+        return any ? BuiltinType.ANY : currentType;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
index 68bb4e1..0cdbb27 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
@@ -55,7 +55,7 @@ public class FieldAccessByIndexResultType implements IResultTypeComputer {
             return null;
         }
         IAType type0 = (IAType) obj;
-        ARecordType t0 = NonTaggedFieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
+        ARecordType t0 = FieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
         if (t0 == null) {
             return BuiltinType.ANY;
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
new file mode 100644
index 0000000..2e43316
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
@@ -0,0 +1,100 @@
+/*
+ * 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.base.AString;
+import org.apache.asterix.om.constants.AsterixConstantValue;
+import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+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.base.LogicalExpressionTag;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractLogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class FieldAccessByNameResultType implements IResultTypeComputer {
+
+    public static final FieldAccessByNameResultType INSTANCE = new FieldAccessByNameResultType();
+
+    private FieldAccessByNameResultType() {
+    }
+
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
+        Object obj = env.getType(f.getArguments().get(0).getValue());
+
+        if (obj == null) {
+            return null;
+        }
+        IAType type0 = (IAType) obj;
+        ARecordType t0 = getRecordTypeFromType(type0, expression);
+        if (t0 == null) {
+            return BuiltinType.ANY;
+        }
+
+        AbstractLogicalExpression arg1 = (AbstractLogicalExpression) f.getArguments().get(1).getValue();
+        if (arg1.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
+            return null;
+        }
+
+        ConstantExpression ce = (ConstantExpression) arg1;
+        String typeName = ((AString) ((AsterixConstantValue) ce.getValue()).getObject()).getStringValue();
+        for (int i = 0; i < t0.getFieldNames().length; i++) {
+            if (t0.getFieldNames()[i].equals(typeName)) {
+                return t0.getFieldTypes()[i];
+            }
+        }
+        return BuiltinType.ANY;
+    }
+
+    static ARecordType getRecordTypeFromType(IAType type0, ILogicalExpression expression) throws AlgebricksException {
+        switch (type0.getTypeTag()) {
+            case RECORD:
+                return (ARecordType) type0;
+            case ANY:
+                return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
+            case UNION:
+                AUnionType u = (AUnionType) type0;
+                IAType t1 = u.getActualType();
+                if (t1.getTypeTag() == ATypeTag.RECORD) {
+                    return (ARecordType) t1;
+                } else if (t1.getTypeTag() == ATypeTag.ANY) {
+                    return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
+                } else {
+                    throw new AlgebricksException(
+                            "Unsupported type " + type0 + " for field access expression: " + expression);
+                }
+            default:
+                throw new AlgebricksException(
+                        "Unsupported type " + type0 + " for field access expression: " + expression);
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
index d8164b7..6e7dca8 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
@@ -54,7 +54,7 @@ public class FieldAccessNestedResultType implements IResultTypeComputer {
             return null;
         }
         IAType type0 = (IAType) obj;
-        ARecordType t0 = NonTaggedFieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
+        ARecordType t0 = FieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
         if (t0 == null) {
             return BuiltinType.ANY;
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java
index fe0d1ab..27e8a3d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java
@@ -20,7 +20,7 @@
 package org.apache.asterix.om.typecomputer.impl;
 
 import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -36,7 +36,7 @@ public class FlowRecordResultTypeComputer implements IResultTypeComputer {
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         ScalarFunctionCallExpression funcExpr = (ScalarFunctionCallExpression) expression;
-        IAType type = TypeComputerUtilities.getRequiredType(funcExpr);
+        IAType type = TypeCastUtils.getRequiredType(funcExpr);
         if (type == null) {
             type = (IAType) env.getType(funcExpr.getArguments().get(0).getValue());
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetItemResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetItemResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetItemResultType.java
deleted file mode 100644
index 97b8654..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetItemResultType.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.AbstractCollectionType;
-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.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class GetItemResultType implements IResultTypeComputer {
-
-    public static final GetItemResultType INSTANCE = new GetItemResultType();
-
-    private GetItemResultType() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-        Object type0;
-        try {
-            type0 = env.getType(f.getArguments().get(0).getValue());
-        } catch (AlgebricksException e) {
-            throw new AlgebricksException(e);
-        }
-        if (type0 == null) {
-            return null;
-        }
-        AbstractCollectionType t0 = (AbstractCollectionType) type0;
-        return t0.getItemType();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
index 46cd97a..1f8c95d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
@@ -18,16 +18,12 @@
  */
 package org.apache.asterix.om.typecomputer.impl;
 
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
 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 GetOverlappingInvervalTypeComputer implements IResultTypeComputer {
+public class GetOverlappingInvervalTypeComputer extends AbstractResultTypeComputer {
 
     public static final GetOverlappingInvervalTypeComputer INSTANCE = new GetOverlappingInvervalTypeComputer();
 
@@ -35,8 +31,8 @@ public class GetOverlappingInvervalTypeComputer implements IResultTypeComputer {
 
     }
 
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
         return AUnionType.createNullableType(BuiltinType.AINTERVAL, "IntervalOrNullResult");
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
index 8293e18..5d14716 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
@@ -47,7 +47,7 @@ public class InjectFailureTypeComputer implements IResultTypeComputer {
         IAType t1 = (IAType) env.getType(fce.getArguments().get(0).getValue());
         ATypeTag tag1 = t1.getTypeTag();
         if (NonTaggedFormatUtil.isOptional(t1))
-            tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
+            tag1 = ((AUnionType) t1).getActualType().getTypeTag();
 
         if (tag1 != ATypeTag.BOOLEAN)
             throw new AlgebricksException(errMsg2);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/LocalAvgTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/LocalAvgTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/LocalAvgTypeComputer.java
new file mode 100644
index 0000000..a5858d7
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/LocalAvgTypeComputer.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.ARecordType;
+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 LocalAvgTypeComputer implements IResultTypeComputer {
+
+    public static final LocalAvgTypeComputer INSTANCE = new LocalAvgTypeComputer();
+
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        return new ARecordType(null,
+                new String[] { "sum", "count" }, new IAType[] {
+                        AUnionType.createNullableType(BuiltinType.ADOUBLE, "OptionalDouble"), BuiltinType.AINT32 },
+                false);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
new file mode 100644
index 0000000..e484cb4
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
@@ -0,0 +1,63 @@
+/*
+ * 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.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class MinMaxAggTypeComputer extends AbstractResultTypeComputer {
+    private static final String ERR_MSG = "Aggregator is not implemented for ";
+
+    public static final MinMaxAggTypeComputer INSTANCE = new MinMaxAggTypeComputer();
+
+    private MinMaxAggTypeComputer() {
+    }
+
+    @Override
+    protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+        ATypeTag tag = type.getTypeTag();
+        switch (tag) {
+            case DOUBLE:
+            case FLOAT:
+            case INT64:
+            case INT32:
+            case INT16:
+            case INT8:
+            case STRING:
+            case DATE:
+            case TIME:
+            case DATETIME:
+            case YEARMONTHDURATION:
+            case DAYTIMEDURATION:
+            case ANY:
+                return;
+            default:
+                throw new NotImplementedException(ERR_MSG + tag);
+        }
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        return AUnionType.createNullableType(strippedInputTypes[0]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedCollectionMemberResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedCollectionMemberResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedCollectionMemberResultType.java
deleted file mode 100644
index 9eeeafa..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedCollectionMemberResultType.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.AbstractCollectionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-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.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedCollectionMemberResultType implements IResultTypeComputer {
-
-    public static final NonTaggedCollectionMemberResultType INSTANCE = new NonTaggedCollectionMemberResultType();
-
-    private NonTaggedCollectionMemberResultType() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-        IAType type = (IAType) env.getType(f.getArguments().get(0).getValue());
-        if (NonTaggedFormatUtil.isOptional(type)) {
-            type = ((AUnionType) type).getNullableType();
-        }
-        if (type.getTypeTag() == ATypeTag.ANY) {
-            return BuiltinType.ANY;
-        }
-        return ((AbstractCollectionType) type).getItemType();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedFieldAccessByNameResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedFieldAccessByNameResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedFieldAccessByNameResultType.java
deleted file mode 100644
index bc3792f..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedFieldAccessByNameResultType.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.base.AString;
-import org.apache.asterix.om.constants.AsterixConstantValue;
-import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.ATypeTag;
-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.base.LogicalExpressionTag;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractLogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedFieldAccessByNameResultType implements IResultTypeComputer {
-
-    public static final NonTaggedFieldAccessByNameResultType INSTANCE = new NonTaggedFieldAccessByNameResultType();
-
-    private NonTaggedFieldAccessByNameResultType() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-        Object obj = env.getType(f.getArguments().get(0).getValue());
-
-        if (obj == null) {
-            return null;
-        }
-        IAType type0 = (IAType) obj;
-        ARecordType t0 = getRecordTypeFromType(type0, expression);
-        if (t0 == null) {
-            return BuiltinType.ANY;
-        }
-
-        AbstractLogicalExpression arg1 = (AbstractLogicalExpression) f.getArguments().get(1).getValue();
-        if (arg1.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
-            return null; // BuiltinType.UNKNOWN;
-        }
-
-        ConstantExpression ce = (ConstantExpression) arg1;
-        String typeName = ((AString) ((AsterixConstantValue) ce.getValue()).getObject()).getStringValue();
-        for (int i = 0; i < t0.getFieldNames().length; i++) {
-            if (t0.getFieldNames()[i].equals(typeName)) {
-                return t0.getFieldTypes()[i];
-            }
-        }
-        return BuiltinType.ANY;
-    }
-
-    static ARecordType getRecordTypeFromType(IAType type0, ILogicalExpression expression) throws AlgebricksException {
-        switch (type0.getTypeTag()) {
-            case RECORD: {
-                return (ARecordType) type0;
-            }
-            case ANY: {
-                return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
-            }
-            case UNION: {
-                AUnionType u = (AUnionType) type0;
-                if (u.isNullableType()) {
-                    IAType t1 = u.getNullableType();
-                    if (t1.getTypeTag() == ATypeTag.RECORD) {
-                        return (ARecordType) t1;
-                    }
-                    if (t1.getTypeTag() == ATypeTag.ANY) {
-                        return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
-                    }
-                }
-            }
-            default: {
-                throw new AlgebricksException("Unsupported type " + type0 + " for field access expression: "
-                        + expression);
-            }
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
index 996ed9c..c2c1d1a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
@@ -18,20 +18,16 @@
  */
 package org.apache.asterix.om.typecomputer.impl;
 
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.AbstractCollectionType;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 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.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 
-public class NonTaggedGetItemResultType implements IResultTypeComputer {
+public class NonTaggedGetItemResultType extends AbstractResultTypeComputer {
 
     public static final NonTaggedGetItemResultType INSTANCE = new NonTaggedGetItemResultType();
 
@@ -39,19 +35,32 @@ public class NonTaggedGetItemResultType implements IResultTypeComputer {
     }
 
     @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-        IAType type = (IAType) env.getType(f.getArguments().get(0).getValue());
-        if (NonTaggedFormatUtil.isOptional(type))
-            type = ((AUnionType) type).getNullableType();
-        if (type.getTypeTag() == ATypeTag.ANY)
+    protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+        if (argIndex == 0) {
+            if (type.getTypeTag() != ATypeTag.UNORDEREDLIST && type.getTypeTag() != ATypeTag.ORDEREDLIST) {
+                throw new AlgebricksException("The input type for input argument " + argIndex + "("
+                        + type.getDisplayName() + ")" + " is not expected.");
+            }
+        } else {
+            if (!ATypeHierarchy.isCompatible(type.getTypeTag(), ATypeTag.INT32)) {
+                throw new AlgebricksException("The input type for input argument " + argIndex + "("
+                        + type.getDisplayName() + ")" + " is not expected.");
+            }
+        }
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        IAType type = strippedInputTypes[0];
+        if (type.getTypeTag() == ATypeTag.ANY) {
             return BuiltinType.ANY;
-        else {
-            if (((AOrderedListType) type).getItemType().getTypeTag() == ATypeTag.NULL)
-                return BuiltinType.ANULL;
-            return AUnionType.createNullableType(((AOrderedListType) type).getItemType(), "GetItemResult");
         }
+        IAType itemType = ((AbstractCollectionType) type).getItemType();
+        if (itemType.getTypeTag() == ATypeTag.ANY) {
+            return itemType;
+        }
+        // Could have out-of-bound access or null elements.
+        return AUnionType.createUnknownableType(itemType);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
deleted file mode 100644
index 5947b5f..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.ARecordType;
-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 NonTaggedLocalAvgTypeComputer implements IResultTypeComputer {
-
-    public static final NonTaggedLocalAvgTypeComputer INSTANCE = new NonTaggedLocalAvgTypeComputer();
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        return new ARecordType(null,
-                new String[] { "sum", "count" }, new IAType[] {
-                        AUnionType.createNullableType(BuiltinType.ADOUBLE, "OptionalDouble"), BuiltinType.AINT32 },
-                false);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
deleted file mode 100644
index 138bd8f..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedMinMaxAggTypeComputer implements IResultTypeComputer {
-    private static final String errMsg = "Aggregator is not implemented for ";
-
-    public static final NonTaggedMinMaxAggTypeComputer INSTANCE = new NonTaggedMinMaxAggTypeComputer();
-
-    private NonTaggedMinMaxAggTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
-        IAType t1 = (IAType) env.getType(arg1);
-        if (t1 == null) {
-            return null;
-        }
-
-        ATypeTag tag1;
-        if (NonTaggedFormatUtil.isOptional(t1)) {
-            tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
-        } else {
-            tag1 = t1.getTypeTag();
-        }
-
-        IAType type;
-
-        switch (tag1) {
-            case DOUBLE:
-                type = BuiltinType.ADOUBLE;
-                break;
-            case FLOAT:
-                type = BuiltinType.AFLOAT;
-                break;
-            case INT64:
-                type = BuiltinType.AINT64;
-                break;
-            case INT32:
-                type = BuiltinType.AINT32;
-                break;
-            case INT16:
-                type = BuiltinType.AINT16;
-                break;
-            case INT8:
-                type = BuiltinType.AINT8;
-                break;
-            case STRING:
-                type = BuiltinType.ASTRING;
-                break;
-            case DATE:
-                type = BuiltinType.ADATE;
-                break;
-            case TIME:
-                type = BuiltinType.ATIME;
-                break;
-            case DATETIME:
-                type = BuiltinType.ADATETIME;
-                break;
-            case YEARMONTHDURATION:
-                type = BuiltinType.AYEARMONTHDURATION;
-                break;
-            case DAYTIMEDURATION:
-                type = BuiltinType.ADAYTIMEDURATION;
-                break;
-            case ANY:
-                return BuiltinType.ANY;
-            default: {
-                throw new NotImplementedException(errMsg + tag1);
-            }
-        }
-        return AUnionType.createNullableType(type, "SumResult");
-    }
-}


Mime
View raw message