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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
deleted file mode 100644
index c6a2790..0000000
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
+++ /dev/null
@@ -1,52 +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 OptionalADayTimeDurationTypeComputer implements 
IResultTypeComputer {
-
-    public static final OptionalADayTimeDurationTypeComputer INSTANCE = new 
OptionalADayTimeDurationTypeComputer();
-
-    private OptionalADayTimeDurationTypeComputer() {
-
-    }
-
-    /* (non-Javadoc)
-     * @see 
org.apache.asterix.om.typecomputer.base.IResultTypeComputer#computeType(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression,
 
org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment,
 org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
-     */
-    @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
-        if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
-            return AUnionType.createNullableType(BuiltinType.ADAYTIMEDURATION, 
"OptionalDayTimeDuration");
-        } else {
-            return BuiltinType.ADAYTIMEDURATION;
-        }
-    }
-
-}

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

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

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

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

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

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

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

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
deleted file mode 100644
index 29be8c3..0000000
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.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 OptionalAStringTypeComputer implements IResultTypeComputer {
-
-    public static final OptionalAStringTypeComputer INSTANCE = new 
OptionalAStringTypeComputer();
-
-    private OptionalAStringTypeComputer() {
-    }
-
-    @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
-        if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
-            return AUnionType.createNullableType(BuiltinType.ASTRING, 
"OptionalString");
-        } else {
-            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/OptionalATemporalInstanceTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java
deleted file mode 100644
index 0414bb9..0000000
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.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 java.util.ArrayList;
-import java.util.List;
-
-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 OptionalATemporalInstanceTypeComputer implements 
IResultTypeComputer {
-
-    public static final OptionalATemporalInstanceTypeComputer INSTANCE = new 
OptionalATemporalInstanceTypeComputer();
-
-    private OptionalATemporalInstanceTypeComputer() {
-    }
-
-    /* (non-Javadoc)
-     * @see 
org.apache.asterix.om.typecomputer.base.IResultTypeComputer#computeType(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression,
 
org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment,
 org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
-     */
-    @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
-        List<IAType> unionList = new ArrayList<IAType>();
-        unionList.add(BuiltinType.ANULL);
-        unionList.add(BuiltinType.ADATE);
-        unionList.add(BuiltinType.ATIME);
-        unionList.add(BuiltinType.ADATETIME);
-        return new AUnionType(unionList, "OptionalTemporalInstance");
-    }
-
-}

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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
deleted file mode 100644
index df0e46d..0000000
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
+++ /dev/null
@@ -1,52 +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 OptionalAYearMonthDurationTypeComputer implements 
IResultTypeComputer {
-
-    public static final OptionalAYearMonthDurationTypeComputer INSTANCE = new 
OptionalAYearMonthDurationTypeComputer();
-
-    private OptionalAYearMonthDurationTypeComputer() {
-
-    }
-
-    /* (non-Javadoc)
-     * @see 
org.apache.asterix.om.typecomputer.base.IResultTypeComputer#computeType(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression,
 
org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment,
 org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
-     */
-    @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
-        if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
-            return 
AUnionType.createNullableType(BuiltinType.AYEARMONTHDURATION, 
"OptionalYearMonthDuration");
-        } else {
-            return BuiltinType.AYEARMONTHDURATION;
-        }
-    }
-
-}

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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
index f8c0a2a..70a0ca5 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
@@ -19,15 +19,13 @@
 
 package org.apache.asterix.om.typecomputer.impl;
 
-import java.util.ArrayList;
-
 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.AOrderedListType;
+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.core.algebra.base.ILogicalExpression;
 import 
org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
@@ -46,23 +44,28 @@ public class OrderedListConstructorResultType implements 
IResultTypeComputer {
         /**
          * if type has been top-down propagated, use the enforced type
          */
-        AOrderedListType reqType = (AOrderedListType) 
TypeComputerUtilities.getRequiredType(f);
-        if (reqType != null)
+        AOrderedListType reqType = (AOrderedListType) 
TypeCastUtils.getRequiredType(f);
+        if (reqType != null) {
             return reqType;
+        }
 
-        ArrayList<IAType> types = new ArrayList<IAType>();
+        IAType currentType = null;
+        boolean any = false;
         for (int k = 0; k < f.getArguments().size(); k++) {
             IAType type = (IAType) 
env.getType(f.getArguments().get(k).getValue());
-            if (NonTaggedFormatUtil.isOptional(type))
-                type = ((AUnionType) type).getNullableType();
-            if (types.indexOf(type) < 0) {
-                types.add(type);
+            if (type.getTypeTag() == ATypeTag.UNION) {
+                type = ((AUnionType) type).getActualType();
+            }
+            if (currentType != null && !currentType.equals(type)) {
+                any = true;
+                break;
             }
+            currentType = type;
         }
-        if (types.size() == 1) {
-            return new AOrderedListType(types.get(0), null);
-        } else {
+        if (any || currentType == null) {
             return new AOrderedListType(BuiltinType.ANY, null);
+        } else {
+            return new AOrderedListType(currentType, 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/OrderedListOfAInt32TypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.java
index 3297cca..a0ea2a5 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.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.AOrderedListType;
 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 OrderedListOfAInt32TypeComputer implements IResultTypeComputer {
+public class OrderedListOfAInt32TypeComputer extends 
AbstractResultTypeComputer {
 
     public static final OrderedListOfAInt32TypeComputer INSTANCE = new 
OrderedListOfAInt32TypeComputer();
 
@@ -35,8 +31,7 @@ public class OrderedListOfAInt32TypeComputer implements 
IResultTypeComputer {
     }
 
     @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
+    protected IAType getResultType(IAType... strippedInputTypes) {
         return new AOrderedListType(BuiltinType.AINT32, 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/OrderedListOfAInt64TypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.java
index c88336f..1aec3c7 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.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.AOrderedListType;
 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 OrderedListOfAInt64TypeComputer implements IResultTypeComputer {
+public class OrderedListOfAInt64TypeComputer extends 
AbstractResultTypeComputer {
 
     public static final OrderedListOfAInt64TypeComputer INSTANCE = new 
OrderedListOfAInt64TypeComputer();
 
@@ -35,8 +31,7 @@ public class OrderedListOfAInt64TypeComputer implements 
IResultTypeComputer {
     }
 
     @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
+    protected IAType getResultType(IAType... strippedInputTypes) {
         return new AOrderedListType(BuiltinType.AINT64, 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/OrderedListOfAIntervalTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java
index d6474a1..f3892dd 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.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.AOrderedListType;
 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 OrderedListOfAIntervalTypeComputer implements IResultTypeComputer 
{
+public class OrderedListOfAIntervalTypeComputer extends 
AbstractResultTypeComputer {
 
     public static final OrderedListOfAIntervalTypeComputer INSTANCE = new 
OrderedListOfAIntervalTypeComputer();
 
@@ -35,8 +31,7 @@ public class OrderedListOfAIntervalTypeComputer implements 
IResultTypeComputer {
     }
 
     @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
+    protected IAType getResultType(IAType... strippedInputTypes) {
         return new AOrderedListType(BuiltinType.AINTERVAL, 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/OrderedListOfAPointTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.java
index 36ec846..2d99a09 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.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.AOrderedListType;
 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 OrderedListOfAPointTypeComputer implements IResultTypeComputer {
+public class OrderedListOfAPointTypeComputer extends 
AbstractResultTypeComputer {
 
     public static final OrderedListOfAPointTypeComputer INSTANCE = new 
OrderedListOfAPointTypeComputer();
 
@@ -35,8 +31,7 @@ public class OrderedListOfAPointTypeComputer implements 
IResultTypeComputer {
     }
 
     @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
+    protected IAType getResultType(IAType... strippedInputTypes) {
         return new AOrderedListType(BuiltinType.APOINT, 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/OrderedListOfAStringTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.java
index 3106171..977b7e4 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.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.AOrderedListType;
 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 OrderedListOfAStringTypeComputer implements IResultTypeComputer {
+public class OrderedListOfAStringTypeComputer extends 
AbstractResultTypeComputer {
 
     public static final OrderedListOfAStringTypeComputer INSTANCE = new 
OrderedListOfAStringTypeComputer();
 
@@ -35,8 +31,7 @@ public class OrderedListOfAStringTypeComputer implements 
IResultTypeComputer {
     }
 
     @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
+    protected IAType getResultType(IAType... strippedInputTypes) {
         return new AOrderedListType(BuiltinType.ASTRING, 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/OrderedListOfAnyTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.java
index 48bec4f..e88e80b 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.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.AOrderedListType;
 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 OrderedListOfAnyTypeComputer implements IResultTypeComputer {
+public class OrderedListOfAnyTypeComputer extends AbstractResultTypeComputer {
 
     public static final OrderedListOfAnyTypeComputer INSTANCE = new 
OrderedListOfAnyTypeComputer();
 
@@ -35,8 +31,7 @@ public class OrderedListOfAnyTypeComputer implements 
IResultTypeComputer {
     }
 
     @Override
-    public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
-            IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
+    protected IAType getResultType(IAType... strippedInputTypes) {
         return new AOrderedListType(BuiltinType.ANY, 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/QuadStringStringOrNullTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/QuadStringStringOrNullTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/QuadStringStringOrNullTypeComputer.java
deleted file mode 100644
index f238125..0000000
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/QuadStringStringOrNullTypeComputer.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.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-
-/**
- * @author Xiaoyu Ma
- */
-public class QuadStringStringOrNullTypeComputer extends 
AbstractQuadStringTypeComputer {
-    public static final QuadStringStringOrNullTypeComputer INSTANCE = new 
QuadStringStringOrNullTypeComputer();
-
-    private QuadStringStringOrNullTypeComputer() {
-    }
-
-    @Override
-    public IAType getResultType(IAType t0, IAType t1, IAType t2, IAType t3) {
-        if (TypeHelper.canBeNull(t0) || TypeHelper.canBeNull(t1) || 
TypeHelper.canBeNull(t2)
-                || TypeHelper.canBeNull(t3)) {
-            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/RecordAddFieldsTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
index 05002a6..a77935e 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
@@ -63,19 +63,19 @@ public class RecordAddFieldsTypeComputer implements 
IResultTypeComputer {
         AbstractFunctionCallExpression funcExpr = 
(AbstractFunctionCallExpression) expression;
         IAType type0 = (IAType) 
env.getType(funcExpr.getArguments().get(0).getValue());
 
-        ARecordType inputRecordType = 
TypeComputerUtils.extractRecordType(type0);
+        ARecordType inputRecordType = 
TypeComputeUtils.extractRecordType(type0);
         if (inputRecordType == null) {
             throw new AlgebricksException("Input record cannot be null");
         }
 
         AbstractLogicalExpression arg1 = (AbstractLogicalExpression) 
funcExpr.getArguments().get(1).getValue();
         IAType type1 = (IAType) env.getType(arg1);
-        AOrderedListType inputOrderedListType = 
TypeComputerUtils.extractOrderedListType(type1);
+        AOrderedListType inputOrderedListType = 
TypeComputeUtils.extractOrderedListType(type1);
         if (inputOrderedListType == null) {
             return inputRecordType;
         }
 
-        boolean nullable = TypeHelper.canBeNull(type0) || 
TypeHelper.canBeNull(type1);
+        boolean nullable = TypeHelper.canBeUnknown(type0) || 
TypeHelper.canBeUnknown(type1);
         Map<String, IAType> additionalFields = new HashMap<>();
         List<String> resultFieldNames = new ArrayList<>();
         List<IAType> resultFieldTypes = new ArrayList<>();
@@ -103,7 +103,7 @@ public class RecordAddFieldsTypeComputer implements 
IResultTypeComputer {
             // Iterating through the orderlist input
             for (Mutable<ILogicalExpression> arg : args) {
                 AbstractFunctionCallExpression recConsExpr = 
(AbstractFunctionCallExpression) arg.getValue();
-                ARecordType rtype = 
TypeComputerUtils.extractRecordType((IAType) env.getType(recConsExpr));
+                ARecordType rtype = 
TypeComputeUtils.extractRecordType((IAType) env.getType(recConsExpr));
                 if (rtype != null) {
                     String[] fn = rtype.getFieldNames();
                     IAType[] ft = rtype.getFieldTypes();

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
index a9c7968..1a977db 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
@@ -24,7 +24,7 @@ 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.IAType;
 import org.apache.commons.lang3.mutable.Mutable;
@@ -51,7 +51,7 @@ public class RecordConstructorResultType implements 
IResultTypeComputer {
     public IAType computeType(ILogicalExpression expression, 
IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws 
AlgebricksException {
         AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) 
expression;
-        IAType reqType = TypeComputerUtilities.getRequiredType(f);
+        IAType reqType = TypeCastUtils.getRequiredType(f);
         if (reqType != null)
             return reqType;
         int n = f.getArguments().size() / 2;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
index 9611b9c..4a55924 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
@@ -49,9 +49,9 @@ public class RecordMergeTypeComputer implements 
IResultTypeComputer {
         AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) 
expression;
         IAType t0 = (IAType) env.getType(f.getArguments().get(0).getValue());
         IAType t1 = (IAType) env.getType(f.getArguments().get(1).getValue());
-        boolean nullable = TypeHelper.canBeNull(t0) || 
TypeHelper.canBeNull(t1);
-        ARecordType recType0 = TypeComputerUtils.extractRecordType(t0);
-        ARecordType recType1 = TypeComputerUtils.extractRecordType(t1);
+        boolean nullable = TypeHelper.canBeUnknown(t0) || 
TypeHelper.canBeUnknown(t1);
+        ARecordType recType0 = TypeComputeUtils.extractRecordType(t0);
+        ARecordType recType1 = TypeComputeUtils.extractRecordType(t1);
 
         if (recType0 == null || recType1 == null) {
             throw new AlgebricksException(

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
index ea84c95..2323f95 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
@@ -154,14 +154,14 @@ public class RecordRemoveFieldsTypeComputer implements 
IResultTypeComputer {
         Set<String> fieldNameSet = new HashSet<>();
         Deque<String> fieldPathStack = new ArrayDeque<>();
 
-        ARecordType inputRecordType = 
NonTaggedFieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
+        ARecordType inputRecordType = 
FieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
         if (inputRecordType == null) {
             return BuiltinType.ANY;
         }
 
         AbstractLogicalExpression arg1 = (AbstractLogicalExpression) 
funcExpr.getArguments().get(1).getValue();
         IAType inputListType = (IAType) env.getType(arg1);
-        AOrderedListType inputOrderedListType = 
TypeComputerUtils.extractOrderedListType(inputListType);
+        AOrderedListType inputOrderedListType = 
TypeComputeUtils.extractOrderedListType(inputListType);
         if (inputOrderedListType == null) {
             throw new AlgebricksException(
                     "The function 'remove-fields' expects an ordered list as 
the second argument, but got "
@@ -209,7 +209,6 @@ public class RecordRemoveFieldsTypeComputer implements 
IResultTypeComputer {
 
     private IAType buildOutputType(Deque<String> fieldPathStack, ARecordType 
inputRecordType, Set<String> fieldNameSet,
             List<List<String>> pathList) throws AlgebricksException {
-        IAType resultType;
         List<String> resultFieldNames = new ArrayList<>();
         List<IAType> resultFieldTypes = new ArrayList<>();
 
@@ -247,11 +246,13 @@ public class RecordRemoveFieldsTypeComputer implements 
IResultTypeComputer {
      * Note: l2 uses a LIFO insert and removal.
      */
     private <E> boolean isEqualPaths(List<E> l1, Deque<E> l2) {
-        if ((l1 == null) || (l2 == null))
+        if ((l1 == null) || (l2 == null)) {
             return false;
+        }
 
-        if (l1.size() != l2.size())
+        if (l1.size() != l2.size()) {
             return false;
+        }
 
         Iterator<E> it2 = l2.iterator();
 
@@ -259,8 +260,9 @@ public class RecordRemoveFieldsTypeComputer implements 
IResultTypeComputer {
         for (int i = len - 1; i >= 0; i--) {
             E o1 = l1.get(i);
             E o2 = it2.next();
-            if (!o1.equals(o2))
+            if (!o1.equals(o2)) {
                 return false;
+            }
         }
         return true;
     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
index 69d4beb..3fecfd9 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
@@ -18,19 +18,15 @@
  */
 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.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.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 ScalarVersionOfAggregateResultType implements IResultTypeComputer 
{
+public class ScalarVersionOfAggregateResultType extends 
AbstractResultTypeComputer {
 
     public static final ScalarVersionOfAggregateResultType INSTANCE = new 
ScalarVersionOfAggregateResultType();
 
@@ -38,24 +34,22 @@ public class ScalarVersionOfAggregateResultType implements 
IResultTypeComputer {
     }
 
     @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);
-        IAType nonOpt = TypeHelper.getNonOptionalType(t1);
-        ATypeTag tag1 = nonOpt.getTypeTag();
-        if (tag1 != ATypeTag.ORDEREDLIST && tag1 != ATypeTag.UNORDEREDLIST) {
-            throw new AlgebricksException("Type of argument in " + expression
-                    + " should be a collection type instead of " + t1);
-        }
-        AbstractCollectionType act = (AbstractCollectionType) nonOpt;
-        IAType t = act.getItemType();
-        if (TypeHelper.canBeNull(t)) {
-            return t;
-        } else {
-            return AUnionType.createNullableType(t);
+    public void checkArgType(int argIndex, IAType type) throws 
AlgebricksException {
+        ATypeTag tag = type.getTypeTag();
+        if (tag != ATypeTag.ANY && tag != ATypeTag.ORDEREDLIST && tag != 
ATypeTag.UNORDEREDLIST) {
+            throw new AlgebricksException(
+                    "Type of argument in aggregation should be a collection 
type instead of " + type.getDisplayName());
         }
     }
 
+    @Override
+    protected IAType getResultType(IAType... strippedInputTypes) {
+        AbstractCollectionType act = (AbstractCollectionType) 
strippedInputTypes[0];
+        ATypeTag tag = act.getTypeTag();
+        if (tag == ATypeTag.ANY) {
+            return BuiltinType.ANY;
+        }
+        IAType t = act.getItemType();
+        return AUnionType.createNullableType(t);
+    }
 }


Reply via email to