You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by bu...@apache.org on 2016/05/24 01:31:33 UTC

[15/22] incubator-asterixdb git commit: ASTERIXDB-1228: Add MISSING into the data model.

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
deleted file mode 100644
index c0c595d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
+++ /dev/null
@@ -1,343 +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 NonTaggedNumericAddSubMulDivTypeComputer implements IResultTypeComputer {
-
-    private static final String errMsg = "Arithmetic operations are not implemented for ";
-
-    public static final NonTaggedNumericAddSubMulDivTypeComputer INSTANCE = new NonTaggedNumericAddSubMulDivTypeComputer();
-
-    private NonTaggedNumericAddSubMulDivTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
-        ILogicalExpression arg2 = fce.getArguments().get(1).getValue();
-        IAType t1;
-        IAType t2;
-        try {
-            t1 = (IAType) env.getType(arg1);
-            t2 = (IAType) env.getType(arg2);
-        } catch (AlgebricksException e) {
-            throw new AlgebricksException(e);
-        }
-        if (t1 == null || t2 == null) {
-            return null;
-        }
-
-        ATypeTag tag1, tag2;
-        if (NonTaggedFormatUtil.isOptional(t1))
-            tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
-        else
-            tag1 = t1.getTypeTag();
-
-        if (NonTaggedFormatUtil.isOptional(t2))
-            tag2 = ((AUnionType) t2).getNullableType().getTypeTag();
-        else
-            tag2 = t2.getTypeTag();
-
-        if (tag1 == ATypeTag.NULL || tag2 == ATypeTag.NULL) {
-            return BuiltinType.ANULL;
-        }
-
-        IAType type;
-
-        switch (tag1) {
-            case DOUBLE: {
-                switch (tag2) {
-                    case INT8:
-                    case INT16:
-                    case INT32:
-                    case INT64:
-                    case FLOAT:
-                    case DOUBLE:
-                        type = BuiltinType.ADOUBLE;
-                        break;
-                    case ANY:
-                        return BuiltinType.ANY;
-                    default: {
-                        throw new NotImplementedException(errMsg + t2.getTypeName());
-                    }
-                }
-                break;
-            }
-            case FLOAT: {
-                switch (tag2) {
-                    case INT8:
-                    case INT16:
-                    case INT32:
-                    case INT64:
-                    case FLOAT:
-                        type = BuiltinType.AFLOAT;
-                        break;
-                    case DOUBLE:
-                        type = BuiltinType.ADOUBLE;
-                        break;
-                    case ANY:
-                        return BuiltinType.ANY;
-                    default: {
-                        throw new NotImplementedException(errMsg + t2.getTypeName());
-                    }
-                }
-                break;
-            }
-            case INT64: {
-                switch (tag2) {
-                    case INT8:
-                    case INT16:
-                    case INT32:
-                    case INT64:
-                        type = BuiltinType.AINT64;
-                        break;
-                    case FLOAT:
-                        type = BuiltinType.AFLOAT;
-                        break;
-                    case DOUBLE:
-                        type = BuiltinType.ADOUBLE;
-                        break;
-                    case ANY:
-                        return BuiltinType.ANY;
-                    default: {
-                        throw new NotImplementedException(errMsg + t2.getTypeName());
-                    }
-                }
-                break;
-            }
-            case INT32: {
-                switch (tag2) {
-                    case INT8:
-                    case INT16:
-                    case INT32:
-                        type = BuiltinType.AINT32;
-                        break;
-                    case INT64:
-                        type = BuiltinType.AINT64;
-                        break;
-                    case FLOAT:
-                        type = BuiltinType.AFLOAT;
-                        break;
-                    case DOUBLE:
-                        type = BuiltinType.ADOUBLE;
-                        break;
-                    case ANY:
-                        return BuiltinType.ANY;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case INT16: {
-                switch (tag2) {
-                    case INT8:
-                    case INT16:
-                        type = BuiltinType.AINT16;
-                        break;
-                    case INT32:
-                        type = BuiltinType.AINT32;
-                        break;
-                    case INT64:
-                        type = BuiltinType.AINT64;
-                        break;
-                    case FLOAT:
-                        type = BuiltinType.AFLOAT;
-                        break;
-                    case DOUBLE:
-                        type = BuiltinType.ADOUBLE;
-                        break;
-                    case ANY:
-                        return BuiltinType.ANY;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case INT8: {
-                switch (tag2) {
-                    case INT8:
-                        type = BuiltinType.AINT8;
-                        break;
-                    case INT16:
-                        type = BuiltinType.AINT16;
-                        break;
-                    case INT32:
-                        type = BuiltinType.AINT32;
-                        break;
-                    case INT64:
-                        type = BuiltinType.AINT64;
-                        break;
-                    case FLOAT:
-                        type = BuiltinType.AFLOAT;
-                        break;
-                    case DOUBLE:
-                        type = BuiltinType.ADOUBLE;
-                        break;
-                    case ANY:
-                        return BuiltinType.ANY;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case ANY: {
-                switch (tag2) {
-                    case INT8:
-                    case INT16:
-                    case INT32:
-                    case INT64:
-                    case FLOAT:
-                    case ANY:
-                    case DOUBLE:
-                        return BuiltinType.ANY;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-            }
-            case DATE: {
-                switch (tag2) {
-                    case DATE:
-                        type = BuiltinType.ADURATION;
-                        break;
-                    case YEARMONTHDURATION:
-                    case DAYTIMEDURATION:
-                    case DURATION:
-                        type = BuiltinType.ADATE;
-                        break;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case TIME: {
-                switch (tag2) {
-                    case TIME:
-                        type = BuiltinType.ADURATION;
-                        break;
-                    case YEARMONTHDURATION:
-                    case DAYTIMEDURATION:
-                    case DURATION:
-                        type = BuiltinType.ATIME;
-                        break;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case DATETIME: {
-                switch (tag2) {
-                    case DATETIME:
-                        type = BuiltinType.ADURATION;
-                        break;
-                    case YEARMONTHDURATION:
-                    case DAYTIMEDURATION:
-                    case DURATION:
-                        type = BuiltinType.ADATETIME;
-                        break;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case DURATION: {
-                switch (tag2) {
-                    case DATE:
-                        type = BuiltinType.ADATE;
-                        break;
-                    case TIME:
-                        type = BuiltinType.ATIME;
-                        break;
-                    case DATETIME:
-                        type = BuiltinType.ADATETIME;
-                        break;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case YEARMONTHDURATION: {
-                switch (tag2) {
-                    case DATE:
-                        type = BuiltinType.ADATE;
-                        break;
-                    case TIME:
-                        type = BuiltinType.ATIME;
-                        break;
-                    case DATETIME:
-                        type = BuiltinType.ADATETIME;
-                        break;
-                    case YEARMONTHDURATION:
-                        type = BuiltinType.AYEARMONTHDURATION;
-                        break;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            case DAYTIMEDURATION: {
-                switch (tag2) {
-                    case DATE:
-                        type = BuiltinType.ADATE;
-                        break;
-                    case TIME:
-                        type = BuiltinType.ATIME;
-                        break;
-                    case DATETIME:
-                        type = BuiltinType.ADATETIME;
-                        break;
-                    case DAYTIMEDURATION:
-                        type = BuiltinType.ADAYTIMEDURATION;
-                        break;
-                    default: {
-                        throw new NotImplementedException(errMsg + tag2);
-                    }
-                }
-                break;
-            }
-            default: {
-                throw new NotImplementedException(errMsg + tag1);
-            }
-        }
-        return AUnionType.createNullableType(type, "ArithemitcResult");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
deleted file mode 100644
index 1642293..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
+++ /dev/null
@@ -1,88 +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 NonTaggedNumericAggTypeComputer implements IResultTypeComputer {
-
-    private static final String errMsg = "Aggregator is not implemented for ";
-
-    public static final NonTaggedNumericAggTypeComputer INSTANCE = new NonTaggedNumericAggTypeComputer();
-
-    private NonTaggedNumericAggTypeComputer() {
-    }
-
-    @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 ANY:
-                return BuiltinType.ANY;
-            default: {
-                throw new NotImplementedException(errMsg + tag1);
-            }
-        }
-        return AUnionType.createNullableType(type, "SumResult");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericRoundHalfToEven2TypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericRoundHalfToEven2TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericRoundHalfToEven2TypeComputer.java
deleted file mode 100644
index aed28c9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericRoundHalfToEven2TypeComputer.java
+++ /dev/null
@@ -1,115 +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.
- */
-/*
- * Numeric round half to even
- * Author : Xiaoyu Ma@UC Irvine
- * 01/30/2012
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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 NonTaggedNumericRoundHalfToEven2TypeComputer implements IResultTypeComputer {
-
-    public static final NonTaggedNumericRoundHalfToEven2TypeComputer INSTANCE = new NonTaggedNumericRoundHalfToEven2TypeComputer();
-
-    private NonTaggedNumericRoundHalfToEven2TypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        if (fce.getArguments().size() < 2)
-            throw new AlgebricksException("Argument number invalid.");
-
-        ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
-        ILogicalExpression arg2 = fce.getArguments().get(1).getValue();
-
-        IAType t1 = (IAType) env.getType(arg1);
-        IAType t2 = (IAType) env.getType(arg2);
-
-        List<IAType> unionList = new ArrayList<IAType>();
-        unionList.add(BuiltinType.ANULL);
-
-        ATypeTag tag1, tag2;
-        if (NonTaggedFormatUtil.isOptional(t1))
-            tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
-        else
-            tag1 = t1.getTypeTag();
-
-        if (NonTaggedFormatUtil.isOptional(t2))
-            tag2 = ((AUnionType) t2).getNullableType().getTypeTag();
-        else
-            tag2 = t2.getTypeTag();
-
-        switch (tag2) {
-            case INT8:
-            case INT16:
-            case INT32:
-            case INT64:
-                break;
-            default:
-                throw new AlgebricksException("Argument $precision cannot be type " + t2.getTypeName());
-        }
-
-        IAType type;
-        switch (tag1) {
-            case INT8:
-                type = BuiltinType.AINT8;
-                break;
-            case INT16:
-                type = BuiltinType.AINT16;
-                break;
-            case INT32:
-                type = BuiltinType.AINT32;
-                break;
-            case INT64:
-                type = BuiltinType.AINT64;
-                break;
-            case FLOAT:
-                type = BuiltinType.AFLOAT;
-                break;
-            case DOUBLE:
-                type = BuiltinType.ADOUBLE;
-                break;
-            case NULL:
-                return BuiltinType.ANULL;
-            default: {
-                throw new NotImplementedException("Arithmetic operations are not implemented for " + t1.getTypeName());
-            }
-        }
-
-        return AUnionType.createNullableType(type, "NumericFuncionsResult");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericUnaryFunctionTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericUnaryFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericUnaryFunctionTypeComputer.java
deleted file mode 100644
index 40e13ac..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericUnaryFunctionTypeComputer.java
+++ /dev/null
@@ -1,92 +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.
- */
-/*
- * Numeric Unary Functions like abs
- * Author : Xiaoyu Ma@UC Irvine
- * 01/30/2012
- */
-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.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 NonTaggedNumericUnaryFunctionTypeComputer implements IResultTypeComputer {
-
-    private static final String errMsg = "Arithmetic operations are not implemented for ";
-    public static final NonTaggedNumericUnaryFunctionTypeComputer INSTANCE = new NonTaggedNumericUnaryFunctionTypeComputer();
-
-    private NonTaggedNumericUnaryFunctionTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        if (fce.getArguments().isEmpty())
-            throw new AlgebricksException("Wrong Argument Number.");
-
-        ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
-
-        IAType t = (IAType) env.getType(arg1);
-
-        if (NonTaggedFormatUtil.isOptional(t)) {
-            return (IAType) env.getType(arg1);
-        }
-
-        IAType type;
-        switch (t.getTypeTag()) {
-            case INT8:
-                type = BuiltinType.AINT8;
-                break;
-            case INT16:
-                type = BuiltinType.AINT16;
-                break;
-            case INT32:
-                type = BuiltinType.AINT32;
-                break;
-            case INT64:
-                type = BuiltinType.AINT64;
-                break;
-            case FLOAT:
-                type = BuiltinType.AFLOAT;
-                break;
-            case DOUBLE:
-                type = BuiltinType.ADOUBLE;
-                break;
-            case NULL:
-                return BuiltinType.ANULL;
-            case ANY:
-                return BuiltinType.ANY;
-            default: {
-                throw new NotImplementedException(errMsg + t.getTypeName());
-            }
-        }
-
-        return AUnionType.createNullableType(type, "NumericUnaryFuncionsResult");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedSwitchCaseComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedSwitchCaseComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedSwitchCaseComputer.java
deleted file mode 100644
index cef24c4..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedSwitchCaseComputer.java
+++ /dev/null
@@ -1,67 +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.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 NonTaggedSwitchCaseComputer implements IResultTypeComputer {
-
-    private static final String errMsg1 = "switch case should have at least 3 parameters ";
-    private static final String errMsg2 = "every case expression should have the same return type";
-    private static final String errMsg3 = "swith conditon type should be compatible with each case type";
-
-    public static IResultTypeComputer INSTANCE = new NonTaggedSwitchCaseComputer();
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        if (fce.getArguments().size() < 3)
-            throw new AlgebricksException(errMsg1);
-
-        TypeCompatibilityChecker tcc = new TypeCompatibilityChecker();
-        for (int i = 2; i < fce.getArguments().size(); i += 2) {
-            IAType ti = (IAType) env.getType(fce.getArguments().get(i).getValue());
-            tcc.addPossibleType(ti);
-        }
-        IAType valueType = tcc.getCompatibleType();
-        if (valueType == null) {
-            throw new AlgebricksException(errMsg2);
-        }
-
-        IAType switchType = (IAType) env.getType(fce.getArguments().get(0).getValue());
-        tcc.reset();
-        tcc.addPossibleType(switchType);
-        for (int i = 1; i < fce.getArguments().size(); i += 2) {
-            IAType ti = (IAType) env.getType(fce.getArguments().get(i).getValue());
-            tcc.addPossibleType(ti);
-        }
-        IAType caseType = tcc.getCompatibleType();
-        if (caseType == null) {
-            throw new AlgebricksException(errMsg3);
-        }
-        return valueType;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedUnaryMinusTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedUnaryMinusTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedUnaryMinusTypeComputer.java
deleted file mode 100644
index 446953a..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedUnaryMinusTypeComputer.java
+++ /dev/null
@@ -1,48 +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.AUnionType;
-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 NonTaggedUnaryMinusTypeComputer implements IResultTypeComputer {
-
-    public static final NonTaggedUnaryMinusTypeComputer INSTANCE = new NonTaggedUnaryMinusTypeComputer();
-
-    private NonTaggedUnaryMinusTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
-        IAType envType = (IAType) env.getType(arg1);
-        if (NonTaggedFormatUtil.isOptional(envType))
-            return envType;
-        return AUnionType.createNullableType(envType, "UnaryMinusResult");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotMissingTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotMissingTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotMissingTypeComputer.java
new file mode 100644
index 0000000..68444c4
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotMissingTypeComputer.java
@@ -0,0 +1,77 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+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.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;
+
+/**
+ * This class is the type computer for not-missing function.
+ * If the input type is not a union, we just return it.
+ * If the input type is a union,
+ * case 1: we return a new union without missing if the new union still has more than one types;
+ * case 2: we return the non-missing item type in the original union if there are only missing
+ * and it in the original union.
+ */
+public class NotMissingTypeComputer implements IResultTypeComputer {
+
+    public static final NotMissingTypeComputer INSTANCE = new NotMissingTypeComputer();
+
+    @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 (type.getTypeTag() != ATypeTag.UNION) {
+            // directly return the input type if it is not a union
+            return type;
+        }
+
+        AUnionType unionType = (AUnionType) type;
+        List<IAType> items = new ArrayList<>();
+        // copy the item types
+        items.addAll(unionType.getUnionList());
+
+        // remove missing
+        for (int i = items.size() - 1; i >= 0; i--) {
+            IAType itemType = items.get(i);
+            if (itemType.getTypeTag() == ATypeTag.MISSING) {
+                items.remove(i);
+            }
+        }
+        if (items.size() == 1) {
+            //only one type is left
+            return items.get(0);
+        } else {
+            //more than two types are left
+            return new AUnionType(items, unionType.getTypeName());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotNullTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotNullTypeComputer.java
deleted file mode 100644
index 0fd169c..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotNullTypeComputer.java
+++ /dev/null
@@ -1,76 +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 java.util.ArrayList;
-import java.util.List;
-
-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.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;
-
-/**
- * This class is the type computer for not-null function.
- * If the input type is not a union, we just return it.
- * If the input type is a union,
- * case 1: we return a new union without null if the new union still has more than one types;
- * case 2: we return the non-null item type in the original union if there are only null and it in the original union.
- */
-public class NotNullTypeComputer implements IResultTypeComputer {
-
-    public static final NotNullTypeComputer INSTANCE = new NotNullTypeComputer();
-
-    @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 (type.getTypeTag() != ATypeTag.UNION) {
-            // directly return the input type if it is not a union
-            return type;
-        }
-
-        AUnionType unionType = (AUnionType) type;
-        List<IAType> items = new ArrayList<IAType>();
-        // copy the item types
-        items.addAll(unionType.getUnionList());
-
-        // remove null
-        for (int i = items.size() - 1; i >= 0; i--) {
-            IAType itemType = items.get(i);
-            if (itemType.getTypeTag() == ATypeTag.NULL) {
-                items.remove(i);
-            }
-        }
-        if (items.size() == 1) {
-            //only one type is left
-            return items.get(0);
-        } else {
-            //more than two types are left
-            return new AUnionType(items, unionType.getTypeName());
-        }
-    }
-}

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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
new file mode 100644
index 0000000..f9223e4
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
@@ -0,0 +1,305 @@
+/*
+ * 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.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class NumericAddSubMulDivTypeComputer extends AbstractResultTypeComputer {
+
+    private static final String ERR_MSG = "Arithmetic operations are not implemented for ";
+
+    public static final NumericAddSubMulDivTypeComputer INSTANCE = new NumericAddSubMulDivTypeComputer();
+
+    private NumericAddSubMulDivTypeComputer() {
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        IAType t1 = strippedInputTypes[0];
+        IAType t2 = strippedInputTypes[1];
+        ATypeTag tag1 = t1.getTypeTag();
+        ATypeTag tag2 = t2.getTypeTag();
+
+        IAType type;
+        switch (tag1) {
+            case DOUBLE:
+                switch (tag2) {
+                    case INT8:
+                    case INT16:
+                    case INT32:
+                    case INT64:
+                    case FLOAT:
+                    case DOUBLE:
+                        type = BuiltinType.ADOUBLE;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + t2.getTypeName());
+                }
+                break;
+            case FLOAT:
+                switch (tag2) {
+                    case INT8:
+                    case INT16:
+                    case INT32:
+                    case INT64:
+                    case FLOAT:
+                        type = BuiltinType.AFLOAT;
+                        break;
+                    case DOUBLE:
+                        type = BuiltinType.ADOUBLE;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + t2.getTypeName());
+                }
+                break;
+            case INT64:
+                switch (tag2) {
+                    case INT8:
+                    case INT16:
+                    case INT32:
+                    case INT64:
+                        type = BuiltinType.AINT64;
+                        break;
+                    case FLOAT:
+                        type = BuiltinType.AFLOAT;
+                        break;
+                    case DOUBLE:
+                        type = BuiltinType.ADOUBLE;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + t2.getTypeName());
+                }
+                break;
+            case INT32:
+                switch (tag2) {
+                    case INT8:
+                    case INT16:
+                    case INT32:
+                        type = BuiltinType.AINT32;
+                        break;
+                    case INT64:
+                        type = BuiltinType.AINT64;
+                        break;
+                    case FLOAT:
+                        type = BuiltinType.AFLOAT;
+                        break;
+                    case DOUBLE:
+                        type = BuiltinType.ADOUBLE;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case INT16:
+                switch (tag2) {
+                    case INT8:
+                    case INT16:
+                        type = BuiltinType.AINT16;
+                        break;
+                    case INT32:
+                        type = BuiltinType.AINT32;
+                        break;
+                    case INT64:
+                        type = BuiltinType.AINT64;
+                        break;
+                    case FLOAT:
+                        type = BuiltinType.AFLOAT;
+                        break;
+                    case DOUBLE:
+                        type = BuiltinType.ADOUBLE;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case INT8:
+                switch (tag2) {
+                    case INT8:
+                        type = BuiltinType.AINT8;
+                        break;
+                    case INT16:
+                        type = BuiltinType.AINT16;
+                        break;
+                    case INT32:
+                        type = BuiltinType.AINT32;
+                        break;
+                    case INT64:
+                        type = BuiltinType.AINT64;
+                        break;
+                    case FLOAT:
+                        type = BuiltinType.AFLOAT;
+                        break;
+                    case DOUBLE:
+                        type = BuiltinType.ADOUBLE;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case ANY:
+                switch (tag2) {
+                    case INT8:
+                    case INT16:
+                    case INT32:
+                    case INT64:
+                    case FLOAT:
+                    case ANY:
+                    case DOUBLE:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case DATE:
+                switch (tag2) {
+                    case DATE:
+                        type = BuiltinType.ADURATION;
+                        break;
+                    case YEARMONTHDURATION:
+                    case DAYTIMEDURATION:
+                    case DURATION:
+                        type = BuiltinType.ADATE;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case TIME:
+                switch (tag2) {
+                    case TIME:
+                        type = BuiltinType.ADURATION;
+                        break;
+                    case YEARMONTHDURATION:
+                    case DAYTIMEDURATION:
+                    case DURATION:
+                        type = BuiltinType.ATIME;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case DATETIME:
+                switch (tag2) {
+                    case DATETIME:
+                        type = BuiltinType.ADURATION;
+                        break;
+                    case YEARMONTHDURATION:
+                    case DAYTIMEDURATION:
+                    case DURATION:
+                        type = BuiltinType.ADATETIME;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case DURATION:
+                switch (tag2) {
+                    case DATE:
+                        type = BuiltinType.ADATE;
+                        break;
+                    case TIME:
+                        type = BuiltinType.ATIME;
+                        break;
+                    case DATETIME:
+                        type = BuiltinType.ADATETIME;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case YEARMONTHDURATION:
+                switch (tag2) {
+                    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 ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            case DAYTIMEDURATION:
+                switch (tag2) {
+                    case DATE:
+                        type = BuiltinType.ADATE;
+                        break;
+                    case TIME:
+                        type = BuiltinType.ATIME;
+                        break;
+                    case DATETIME:
+                        type = BuiltinType.ADATETIME;
+                        break;
+                    case DAYTIMEDURATION:
+                        type = BuiltinType.ADAYTIMEDURATION;
+                        break;
+                    case ANY:
+                        type = BuiltinType.ANY;
+                        break;
+                    default:
+                        throw new NotImplementedException(ERR_MSG + tag2);
+                }
+                break;
+            default:
+                throw new NotImplementedException(ERR_MSG + tag1);
+        }
+        return type;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulTypeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulTypeDescriptor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulTypeDescriptor.java
deleted file mode 100644
index 2796022..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulTypeDescriptor.java
+++ /dev/null
@@ -1,83 +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.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-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 NumericAddSubMulTypeDescriptor implements IResultTypeComputer {
-
-    private static final String errMsg = "Arithmetic operations are only implemented for AINT32 and ADOUBLE.";
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
-        ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
-        ILogicalExpression arg2 = fce.getArguments().get(1).getValue();
-        IAType t1;
-        IAType t2;
-        try {
-            t1 = (IAType) env.getType(arg1);
-            t2 = (IAType) env.getType(arg2);
-        } catch (AlgebricksException e) {
-            throw new AlgebricksException(e);
-        }
-        if (t1 == null || t2 == null) {
-            return null;
-        }
-        switch (t1.getTypeTag()) {
-            case INT32: {
-                switch (t2.getTypeTag()) {
-                    case INT32: {
-                        return BuiltinType.AINT32;
-                    }
-                    case DOUBLE: {
-                        return BuiltinType.ADOUBLE;
-                    }
-                    default: {
-                        throw new NotImplementedException(errMsg);
-                    }
-                }
-            }
-            case DOUBLE: {
-                switch (t2.getTypeTag()) {
-                    case INT32:
-                    case DOUBLE: {
-                        return BuiltinType.ADOUBLE;
-                    }
-                    default: {
-                        throw new NotImplementedException(errMsg);
-                    }
-                }
-            }
-            default: {
-                throw new NotImplementedException(errMsg);
-            }
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAggTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAggTypeComputer.java
new file mode 100644
index 0000000..691ee7a
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAggTypeComputer.java
@@ -0,0 +1,73 @@
+/*
+ * 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 NumericAggTypeComputer extends AbstractResultTypeComputer {
+
+    private static final String ERR_MSG = "Aggregator is not implemented for ";
+
+    public static final NumericAggTypeComputer INSTANCE = new NumericAggTypeComputer();
+
+    private NumericAggTypeComputer() {
+    }
+
+    @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 ANY:
+                break;
+            default:
+                throw new NotImplementedException(ERR_MSG + tag);
+        }
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        ATypeTag tag = strippedInputTypes[0].getTypeTag();
+        IAType type;
+        switch (tag) {
+            case DOUBLE:
+            case FLOAT:
+            case INT64:
+            case INT32:
+            case INT16:
+            case INT8:
+            case ANY:
+                type = strippedInputTypes[0];
+                break;
+            default:
+                throw new NotImplementedException(ERR_MSG + tag);
+        }
+        return AUnionType.createNullableType(type, "AggResult");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRoundHalfToEven2TypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRoundHalfToEven2TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRoundHalfToEven2TypeComputer.java
new file mode 100644
index 0000000..675d1f0
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRoundHalfToEven2TypeComputer.java
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+/*
+ * Numeric round half to even
+ * Author : Xiaoyu Ma@UC Irvine
+ * 01/30/2012
+ */
+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;
+import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class NumericRoundHalfToEven2TypeComputer extends AbstractResultTypeComputer {
+
+    public static final NumericRoundHalfToEven2TypeComputer INSTANCE = new NumericRoundHalfToEven2TypeComputer();
+
+    private NumericRoundHalfToEven2TypeComputer() {
+
+    }
+
+    @Override
+    protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+        ATypeTag tag = type.getTypeTag();
+        if (argIndex == 0) {
+            switch (tag) {
+                case INT8:
+                case INT16:
+                case INT32:
+                case INT64:
+                case FLOAT:
+                case DOUBLE:
+                    break;
+                default:
+                    throw new NotImplementedException(
+                            "Arithmetic operations are not implemented for " + type.getDisplayName());
+            }
+        }
+        if (argIndex == 1) {
+            switch (tag) {
+                case INT8:
+                case INT16:
+                case INT32:
+                case INT64:
+                    break;
+                default:
+                    throw new AlgebricksException("Argument $precision cannot be type " + type.getDisplayName());
+            }
+        }
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        ATypeTag tag = strippedInputTypes[0].getTypeTag();
+        switch (tag) {
+            case INT8:
+            case INT16:
+            case INT32:
+            case INT64:
+            case FLOAT:
+            case DOUBLE:
+            case ANY:
+                return strippedInputTypes[0];
+            default:
+                return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
new file mode 100644
index 0000000..017e178
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+/*
+ * Numeric Unary Functions like abs
+ * Author : Xiaoyu Ma@UC Irvine
+ * 01/30/2012
+ */
+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;
+
+public class NumericUnaryFunctionTypeComputer extends AbstractResultTypeComputer {
+
+    private static final String ERR_MSG = "Arithmetic operations are not implemented for ";
+    public static final NumericUnaryFunctionTypeComputer INSTANCE = new NumericUnaryFunctionTypeComputer();
+
+    private NumericUnaryFunctionTypeComputer() {
+    }
+
+    @Override
+    protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+        ATypeTag tag = type.getTypeTag();
+        switch (tag) {
+            case INT8:
+            case INT16:
+            case INT32:
+            case INT64:
+            case FLOAT:
+            case DOUBLE:
+            case ANY:
+                break;
+            default:
+                throw new AlgebricksException(ERR_MSG + type.getDisplayName());
+        }
+    }
+
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        ATypeTag tag = strippedInputTypes[0].getTypeTag();
+        switch (tag) {
+            case INT8:
+            case INT16:
+            case INT32:
+            case INT64:
+            case FLOAT:
+            case DOUBLE:
+            case ANY:
+                return strippedInputTypes[0];
+            default:
+                return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenARecordTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenARecordTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenARecordTypeComputer.java
new file mode 100644
index 0000000..4a041d4
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenARecordTypeComputer.java
@@ -0,0 +1,43 @@
+/*
+ * 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.pointables.base.DefaultOpenFieldType;
+import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+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.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+public class OpenARecordTypeComputer implements IResultTypeComputer {
+
+    public static final OpenARecordTypeComputer INSTANCE = new OpenARecordTypeComputer();
+
+    private OpenARecordTypeComputer() {
+    }
+
+    @Override
+    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+        return AUnionType.createUnknownableType(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, "UnknownableOpenRecord");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
index 862d1cd..3e1955d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
@@ -26,7 +26,7 @@ import java.util.List;
 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.IAType;
 import org.apache.asterix.om.types.TypeHelper;
@@ -51,7 +51,7 @@ public class OpenRecordConstructorResultType implements IResultTypeComputer {
         /**
          * if type has been top-down propagated, use the enforced type
          */
-        ARecordType type = (ARecordType) TypeComputerUtilities.getRequiredType(f);
+        ARecordType type = (ARecordType) TypeCastUtils.getRequiredType(f);
         if (type != null)
             return type;
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
deleted file mode 100644
index 9831665..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
+++ /dev/null
@@ -1,48 +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.typecomputer.base.TypeComputerUtilities;
-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 OptionalABinaryTypeComputer implements IResultTypeComputer {
-    public static final OptionalABinaryTypeComputer INSTANCE = new OptionalABinaryTypeComputer();
-
-    private OptionalABinaryTypeComputer() {
-
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
-            return AUnionType.createNullableType(BuiltinType.ABINARY, "OptionalBinary");
-        } else {
-            return BuiltinType.ABINARY;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
deleted file mode 100644
index 3e91d23..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
+++ /dev/null
@@ -1,48 +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.typecomputer.base.TypeComputerUtilities;
-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 OptionalABooleanTypeComputer implements IResultTypeComputer {
-
-    public static final OptionalABooleanTypeComputer INSTANCE = new OptionalABooleanTypeComputer();
-
-    private OptionalABooleanTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
-            return AUnionType.createNullableType(BuiltinType.ABOOLEAN, "OptionalBoolean");
-        } else {
-            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/OptionalACircleTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java
deleted file mode 100644
index 244156d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java
+++ /dev/null
@@ -1,48 +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.typecomputer.base.TypeComputerUtilities;
-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 OptionalACircleTypeComputer implements IResultTypeComputer {
-
-    public static final OptionalACircleTypeComputer INSTANCE = new OptionalACircleTypeComputer();
-
-    private OptionalACircleTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
-            return AUnionType.createNullableType(BuiltinType.ACIRCLE, "OptionalCircle");
-        } else {
-            return BuiltinType.ACIRCLE;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
deleted file mode 100644
index 04729bf..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
+++ /dev/null
@@ -1,48 +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.typecomputer.base.TypeComputerUtilities;
-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 OptionalADateTimeTypeComputer implements IResultTypeComputer {
-
-    public static final OptionalADateTimeTypeComputer INSTANCE = new OptionalADateTimeTypeComputer();
-
-    private OptionalADateTimeTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
-        if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
-            return AUnionType.createNullableType(BuiltinType.ADATETIME, "OptionalDatetime");
-        } else {
-            return BuiltinType.ADATETIME;
-        }
-    }
-
-}