asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [04/22] asterixdb git commit: Unify runtime type exceptions by using error code and message template.
Date Tue, 01 Nov 2016 03:08:13 GMT
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
index 480cf8f..fa1e681 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
@@ -27,13 +27,13 @@ import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeseriali
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ADuration;
 import org.apache.asterix.om.base.AMutableDuration;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -59,14 +59,12 @@ public class DurationFromMillisecondsDescriptor extends AbstractScalarFunctionDy
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -81,35 +79,32 @@ public class DurationFromMillisecondsDescriptor extends AbstractScalarFunctionDy
                     AMutableDuration aDuration = new AMutableDuration(0, 0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
                         byte[] bytes = argPtr0.getByteArray();
                         int offset = argPtr0.getStartOffset();
 
-                        try {
-                            ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
-                            switch (argPtrTypeTag) {
-                                case INT8:
-                                    aDuration.setValue(0, AInt8SerializerDeserializer.getByte(bytes, offset + 1));
-                                    break;
-                                case INT16:
-                                    aDuration.setValue(0, AInt16SerializerDeserializer.getShort(bytes, offset + 1));
-                                    break;
-                                case INT32:
-                                    aDuration.setValue(0, AInt32SerializerDeserializer.getInt(bytes, offset + 1));
-                                    break;
-                                case INT64:
-                                    aDuration.setValue(0, AInt64SerializerDeserializer.getLong(bytes, offset + 1));
-                                    break;
-                                default:
-                                    throw new AlgebricksException(FID.getName()
-                                            + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag);
-                            }
-                            durationSerde.serialize(aDuration, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
+                        switch (argPtrTypeTag) {
+                            case INT8:
+                                aDuration.setValue(0, AInt8SerializerDeserializer.getByte(bytes, offset + 1));
+                                break;
+                            case INT16:
+                                aDuration.setValue(0, AInt16SerializerDeserializer.getShort(bytes, offset + 1));
+                                break;
+                            case INT32:
+                                aDuration.setValue(0, AInt32SerializerDeserializer.getInt(bytes, offset + 1));
+                                break;
+                            case INT64:
+                                aDuration.setValue(0, AInt64SerializerDeserializer.getLong(bytes, offset + 1));
+                                break;
+                            default:
+                                throw new TypeMismatchException(getIdentifier(), 0, bytes[offset],
+                                        ATypeTag.SERIALIZED_INT8_TYPE_TAG, ATypeTag.SERIALIZED_INT16_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_INT32_TYPE_TAG, ATypeTag.SERIALIZED_INT64_TYPE_TAG);
                         }
+                        durationSerde.serialize(aDuration, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
index 5db6294..907992b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
@@ -29,7 +29,6 @@ import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -54,14 +53,13 @@ public class DurationFromMonthsDescriptor extends AbstractScalarFunctionDynamicD
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -76,19 +74,14 @@ public class DurationFromMonthsDescriptor extends AbstractScalarFunctionDynamicD
                     AMutableDuration aDuration = new AMutableDuration(0, 0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
-
                         byte[] bytes = argPtr0.getByteArray();
                         int offset = argPtr0.getStartOffset();
-
-                        try {
-                            aDuration.setValue(ATypeHierarchy.getIntegerValue(bytes, offset), 0);
-                            durationSerde.serialize(aDuration, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
-                        }
+                        aDuration.setValue(ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 0, bytes, offset),
+                                0);
+                        durationSerde.serialize(aDuration, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
index cb84fc8..3f9616b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
@@ -24,14 +24,13 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeser
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ADayTimeDuration;
 import org.apache.asterix.om.base.AMutableDayTimeDuration;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -55,14 +54,13 @@ public class GetDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicD
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -77,25 +75,21 @@ public class GetDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicD
                     AMutableDayTimeDuration aDayTimeDuration = new AMutableDayTimeDuration(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
 
                         byte[] bytes = argPtr0.getByteArray();
                         int offset = argPtr0.getStartOffset();
 
-                        try {
-                            if (bytes[offset] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
-                            }
+                        if (bytes[offset] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes[offset],
+                                    ATypeTag.SERIALIZED_DURATION_TYPE_TAG);
+                        }
 
-                            aDayTimeDuration
+                        aDayTimeDuration
                                     .setMilliseconds(ADurationSerializerDeserializer.getDayTime(bytes, offset + 1));
-                            dayTimeDurationSerde.serialize(aDayTimeDuration, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
-                        }
+                        dayTimeDurationSerde.serialize(aDayTimeDuration, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
index d4e3b5f..8258df8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
@@ -30,9 +30,9 @@ import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.pointables.nonvisitor.AIntervalPointable;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.asterix.runtime.exceptions.IncompatibleTypeException;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -54,14 +54,12 @@ public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDyna
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     protected final IntervalLogic il = new IntervalLogic();
@@ -88,45 +86,41 @@ public class GetOverlappingIntervalDescriptor extends AbstractScalarFunctionDyna
                             .getSerializerDeserializer(BuiltinType.AINTERVAL);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
                         eval1.evaluate(tuple, argPtr1);
                         byte type0 = argPtr0.getTag();
                         byte type1 = argPtr1.getTag();
 
-                        try {
-                            if (type0 == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG && type0 == type1) {
-                                argPtr0.getValue(interval0);
-                                argPtr1.getValue(interval1);
-                                byte intervalType0 = interval0.getType();
-                                byte intervalType1 = interval1.getType();
 
-                                if (intervalType0 != intervalType1) {
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": expecting two (nullable) interval values with the same internal time type but got interval of "
-                                            + interval0.getTypeTag() + " and interval of " + interval1.getTypeTag());
-                                }
+                        if (type0 == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG && type0 == type1) {
+                            argPtr0.getValue(interval0);
+                            argPtr1.getValue(interval1);
+                            byte intervalType0 = interval0.getType();
+                            byte intervalType1 = interval1.getType();
+
+                            if (intervalType0 != intervalType1) {
+                                throw new IncompatibleTypeException(getIdentifier(), intervalType0, intervalType1);
+                            }
 
-                                if (il.overlaps(interval0, interval1) || il.overlappedBy(interval0, interval1)
-                                        || il.covers(interval0, interval1) || il.coveredBy(interval0, interval1)) {
-                                    long start = Math.max(interval0.getStartValue(), interval1.getStartValue());
-                                    long end = Math.min(interval0.getEndValue(), interval1.getEndValue());
-                                    aInterval.setValue(start, end, intervalType0);
-                                    intervalSerde.serialize(aInterval, out);
-                                } else {
-                                    nullSerde.serialize(ANull.NULL, out);
-                                }
+                            if (il.overlaps(interval0, interval1) || il.overlappedBy(interval0, interval1)
+                                    || il.covers(interval0, interval1) || il.coveredBy(interval0, interval1)) {
+                                long start = Math.max(interval0.getStartValue(), interval1.getStartValue());
+                                long end = Math.min(interval0.getEndValue(), interval1.getEndValue());
+                                aInterval.setValue(start, end, intervalType0);
+                                intervalSerde.serialize(aInterval, out);
                             } else {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expecting two (nullable) interval values but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type0) + " and "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(type1));
+                                nullSerde.serialize(ANull.NULL, out);
                             }
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                            result.set(resultStorage);
+                            return;
+                        } else if (type0 != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, type0,
+                                    ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG);
+                        } else {
+                            throw new IncompatibleTypeException(getIdentifier(), type0, type1);
                         }
-                        result.set(resultStorage);
                     }
 
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
index d2e4b6e..7224c13 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
@@ -24,14 +24,13 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeser
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.AMutableYearMonthDuration;
 import org.apache.asterix.om.base.AYearMonthDuration;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -55,14 +54,12 @@ public class GetYearMonthDurationDescriptor extends AbstractScalarFunctionDynami
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -77,25 +74,17 @@ public class GetYearMonthDurationDescriptor extends AbstractScalarFunctionDynami
                     AMutableYearMonthDuration aYearMonthDuration = new AMutableYearMonthDuration(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
-
                         byte[] bytes0 = argPtr0.getByteArray();
                         int offset0 = argPtr0.getStartOffset();
-
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]));
-                            }
-
-                            aYearMonthDuration
-                                    .setMonths(ADurationSerializerDeserializer.getYearMonth(bytes0, offset0 + 1));
-                            yearMonthDurationSerde.serialize(aYearMonthDuration, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_DURATION_TYPE_TAG);
                         }
+                        aYearMonthDuration.setMonths(ADurationSerializerDeserializer.getYearMonth(bytes0, offset0 + 1));
+                        yearMonthDurationSerde.serialize(aYearMonthDuration, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
index b584442..c8b27d5 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
@@ -37,7 +37,11 @@ import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.asterix.runtime.exceptions.IncompatibleTypeException;
+import org.apache.asterix.runtime.exceptions.InvalidDataFormatException;
+import org.apache.asterix.runtime.exceptions.OverflowException;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
+import org.apache.asterix.runtime.exceptions.UnderflowException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -61,14 +65,13 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -91,7 +94,7 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                     private final GregorianCalendarSystem GREG_CAL = GregorianCalendarSystem.getInstance();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
                         eval1.evaluate(tuple, argPtr1);
@@ -114,8 +117,9 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 chrononToBin = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
                                 break;
                             default:
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0);
+                                throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                        ATypeTag.SERIALIZED_DATE_TYPE_TAG, ATypeTag.SERIALIZED_TIME_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
                         }
 
                         byte[] bytes1 = argPtr1.getByteArray();
@@ -123,8 +127,7 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                         ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
 
                         if (type0 != type1) {
-                            throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0
-                                    + " for the second argument but got " + type1);
+                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0], bytes1[offset1]);
                         }
 
                         long chrononToStart = 0;
@@ -140,8 +143,9 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 chrononToStart = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                 break;
                             default:
-                                throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0
-                                        + " for the second argument but got " + type1);
+                                throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                        ATypeTag.SERIALIZED_DATE_TYPE_TAG, ATypeTag.SERIALIZED_TIME_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
                         }
 
                         byte[] bytes2 = argPtr2.getByteArray();
@@ -165,13 +169,11 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                         + ((totalMonths < 0 && totalMonths % yearMonth != 0) ? -1 : 0);
 
                                 if (binIndex > Integer.MAX_VALUE) {
-                                    throw new AlgebricksException(
-                                            getIdentifier().getName() + ": Overflowing time value to be binned!");
+                                    throw new OverflowException(getIdentifier());
                                 }
 
                                 if (binIndex < Integer.MIN_VALUE) {
-                                    throw new AlgebricksException(
-                                            getIdentifier().getName() + ": Underflowing time value to be binned!");
+                                    throw new UnderflowException(getIdentifier());
                                 }
 
                                 break;
@@ -184,9 +186,9 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                         + ((totalChronon < 0 && totalChronon % dayTime != 0) ? -1 : 0);
                                 break;
                             default:
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got "
-                                        + type2);
+                                throw new TypeMismatchException(getIdentifier().getName(), 2, bytes2[offset2],
+                                        ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG);
                         }
 
                         switch (type0) {
@@ -207,8 +209,8 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 break;
                             case TIME:
                                 if (yearMonth != 0) {
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": cannot create year-month bin for a time value");
+                                    throw new InvalidDataFormatException(getIdentifier(),
+                                            ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG);
                                 }
                                 binStartChronon = DurationArithmeticOperations.addDuration(chrononToStart,
                                         yearMonth * (int) binIndex, dayTime * binIndex, true);
@@ -222,15 +224,12 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                         yearMonth * ((int) binIndex + 1), dayTime * (binIndex + 1), false);
                                 break;
                             default:
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0);
-                        }
-                        try {
-                            aInterval.setValue(binStartChronon, binEndChronon, type0.serialize());
-                            intervalSerde.serialize(aInterval, out);
-                        } catch (HyracksDataException ex) {
-                            throw new AlgebricksException(ex);
+                                throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                        ATypeTag.SERIALIZED_DATE_TYPE_TAG, ATypeTag.SERIALIZED_TIME_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
                         }
+                        aInterval.setValue(binStartChronon, binEndChronon, type0.serialize());
+                        intervalSerde.serialize(aInterval, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
index ffca207..5c49eed 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
@@ -24,14 +24,13 @@ import org.apache.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializ
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.AInt64;
 import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -55,14 +54,12 @@ public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFun
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -77,25 +74,17 @@ public class MillisecondsFromDayTimeDurationDescriptor extends AbstractScalarFun
                     AMutableInt64 aInt64 = new AMutableInt64(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
-
                         byte[] bytes = argPtr0.getByteArray();
                         int offset = argPtr0.getStartOffset();
-
-                        try {
-                            if (bytes[offset] != ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects NULL/DAY-TIME-DURATION, but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
-                            }
-
-                            aInt64.setValue(ADayTimeDurationSerializerDeserializer.getDayTime(bytes, offset + 1));
-                            int64Serde.serialize(aInt64, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        if (bytes[offset] != ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes[offset],
+                                    ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG);
                         }
+                        aInt64.setValue(ADayTimeDurationSerializerDeserializer.getDayTime(bytes, offset + 1));
+                        int64Serde.serialize(aInt64, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
index 0d2b934..68b5f33 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
@@ -24,14 +24,13 @@ import org.apache.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerial
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.AInt64;
 import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -55,14 +54,12 @@ public class MonthsFromYearMonthDurationDescriptor extends AbstractScalarFunctio
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -77,25 +74,18 @@ public class MonthsFromYearMonthDurationDescriptor extends AbstractScalarFunctio
                     AMutableInt64 aInt64 = new AMutableInt64(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();;
                         eval0.evaluate(tuple, argPtr0);
-
                         byte[] bytes = argPtr0.getByteArray();
                         int offset = argPtr0.getStartOffset();
 
-                        try {
-                            if (bytes[offset] != ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects NULL/YEAR-MONTH-DURATION, but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
-                            }
-
-                            aInt64.setValue(AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, offset + 1));
-                            int64Serde.serialize(aInt64, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        if (bytes[offset] != ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes[offset],
+                                    ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG);
                         }
+                        aInt64.setValue(AYearMonthDurationSerializerDeserializer.getYearMonth(bytes, offset + 1));
+                        int64Serde.serialize(aInt64, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
index 15229e2..79fc90b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
@@ -36,18 +36,22 @@ import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.typecomputer.impl.ADateTypeComputer;
 import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.asterix.runtime.exceptions.IncompatibleTypeException;
+import org.apache.asterix.runtime.exceptions.InvalidDataFormatException;
+import org.apache.asterix.runtime.exceptions.OverflowException;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
+import org.apache.asterix.runtime.exceptions.UnderflowException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -65,14 +69,13 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
 
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -99,7 +102,7 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                     private final GregorianCalendarSystem gregCalSys = GregorianCalendarSystem.getInstance();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
                         eval1.evaluate(tuple, argPtr1);
@@ -122,8 +125,8 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 intervalStart = intervalStart * GregorianCalendarSystem.CHRONON_OF_DAY;
                             }
                         } else {
-                            throw new AlgebricksException(getIdentifier().getName()
-                                    + ": the first argument should be INTERVAL/NULL/MISSING but got " + type0);
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG);
                         }
 
                         // get the anchor instance time
@@ -131,8 +134,7 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                         int offset1 = argPtr1.getStartOffset();
                         ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
                         if (intervalTypeTag != bytes1[offset1]) {
-                            throw new AlgebricksException(getIdentifier().getName() + ": expecting compatible type to "
-                                    + type0 + "(" + intervalTypeTag + ") for the second argument but got " + type1);
+                            throw new IncompatibleTypeException(getIdentifier(), intervalTypeTag, bytes1[offset1]);
                         }
 
                         long anchorTime;
@@ -148,9 +150,9 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                 anchorTime = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                 break;
                             default:
-                                throw new AlgebricksException(
-                                        getIdentifier().getName() + ": expecting compatible type to " + type0 + "("
-                                                + intervalTypeTag + ") for the second argument but got " + type1);
+                                throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                        ATypeTag.SERIALIZED_DATE_TYPE_TAG, ATypeTag.SERIALIZED_TIME_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
                         }
 
                         byte[] bytes2 = argPtr2.getByteArray();
@@ -176,13 +178,11 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                         + ((totalMonths < 0 && totalMonths % yearMonth != 0) ? -1 : 0);
 
                                 if (firstBinIndex > Integer.MAX_VALUE) {
-                                    throw new AlgebricksException(
-                                            getIdentifier().getName() + ": Overflowing time value to be binned!");
+                                    throw new OverflowException(getIdentifier());
                                 }
 
                                 if (firstBinIndex < Integer.MIN_VALUE) {
-                                    throw new AlgebricksException(
-                                            getIdentifier().getName() + ": Underflowing time value to be binned!");
+                                    throw new UnderflowException(getIdentifier());
                                 }
                                 break;
 
@@ -195,17 +195,15 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                         + ((totalChronon < 0 && totalChronon % dayTime != 0) ? -1 : 0);
                                 break;
                             default:
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got "
-                                        + type2);
+                                throw new TypeMismatchException(getIdentifier(), 2, bytes2[offset2],
+                                        ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG);
                         }
 
                         long binStartChronon;
                         long binEndChronon;
                         int binOffset;
-
                         listBuilder.reset(intListType);
-
                         try {
                             if (intervalTypeTag == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
 
@@ -235,8 +233,8 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
 
                             } else if (intervalTypeTag == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
                                 if (yearMonth != 0) {
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": cannot create year-month bin for a time value");
+                                    throw new InvalidDataFormatException(getIdentifier(),
+                                            ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG);
                                 }
 
                                 binOffset = 0;
@@ -250,8 +248,8 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
 
                                 if (binStartChronon < 0 || binStartChronon >= GregorianCalendarSystem.CHRONON_OF_DAY) {
                                     // avoid the case where a time bin is before 00:00:00 or no early than 24:00:00
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
+                                    throw new InvalidDataFormatException(getIdentifier(),
+                                            ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG);
                                 }
 
                                 while (!((binStartChronon < intervalStart && binEndChronon <= intervalStart)
@@ -274,8 +272,8 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                     }
 
                                     if (binEndChronon < binStartChronon) {
-                                        throw new AlgebricksException(getIdentifier().getName()
-                                                + ": reaches a bin with the end earlier than the start; probably the window is beyond the time scope. Maybe use DATETIME?");
+                                        throw new InvalidDataFormatException(getIdentifier(),
+                                                ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG);
                                     }
                                 }
                             } else if (intervalTypeTag == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
@@ -294,12 +292,13 @@ public class OverlapBinsDescriptor extends AbstractScalarFunctionDynamicDescript
                                     binOffset++;
                                 } while (binEndChronon < intervalEnd);
                             } else {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0);
+                                throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                        ATypeTag.SERIALIZED_DATE_TYPE_TAG, ATypeTag.SERIALIZED_TIME_TYPE_TAG,
+                                        ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
                             }
                             listBuilder.write(out, true);
                         } catch (IOException e1) {
-                            throw new AlgebricksException(e1.getMessage());
+                            throw new HyracksDataException(e1);
                         }
                         result.set(resultStorage);
                     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
index 1810b48..9aff8c9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
@@ -25,16 +25,16 @@ import org.apache.asterix.om.base.ADate;
 import org.apache.asterix.om.base.AMutableDate;
 import org.apache.asterix.om.base.temporal.AsterixTemporalTypeParseException;
 import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
-import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
 import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
+import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.asterix.runtime.exceptions.InvalidDataFormatException;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -64,14 +64,12 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -89,7 +87,7 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                     private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
                         eval1.evaluate(tuple, argPtr1);
@@ -101,54 +99,49 @@ public class ParseDateDescriptor extends AbstractScalarFunctionDynamicDescriptor
                         int offset1 = argPtr1.getStartOffset();
                         int len1 = argPtr1.getLength();
 
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expects two strings but got  ("
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
-                            }
-                            utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
-                            int start0 = utf8Ptr.getCharStartOffset();
-                            int length0 = utf8Ptr.getUTF8Length();
-
-                            utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
-                            int start1 = utf8Ptr.getCharStartOffset();
-                            int length1 = utf8Ptr.getUTF8Length();
-                            long chronon = 0;
-
-                            int formatStart = start1;
-                            int formatLength = 0;
-                            boolean processSuccessfully = false;
-                            while (!processSuccessfully && formatStart < start1 + length1) {
-                                // search for "|"
-                                formatLength = 0;
-                                for (; formatStart + formatLength < start1 + length1; formatLength++) {
-                                    if (argPtr1.getByteArray()[formatStart + formatLength] == '|') {
-                                        break;
-                                    }
-                                }
-                                try {
-                                    chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
-                                            formatLength, DateTimeParseMode.DATE_ONLY);
-                                } catch (AsterixTemporalTypeParseException ex) {
-                                    formatStart += formatLength + 1;
-                                    continue;
+                        if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+                        }
+                        if (bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                    ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+                        }
+
+                        utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
+                        int start0 = utf8Ptr.getCharStartOffset();
+                        int length0 = utf8Ptr.getUTF8Length();
+
+                        utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
+                        int start1 = utf8Ptr.getCharStartOffset();
+                        int length1 = utf8Ptr.getUTF8Length();
+                        long chronon = 0;
+
+                        int formatStart = start1;
+                        int formatLength;
+                        boolean processSuccessfully = false;
+                        while (!processSuccessfully && formatStart < start1 + length1) {
+                            // search for "|"
+                            formatLength = 0;
+                            for (; formatStart + formatLength < start1 + length1; formatLength++) {
+                                if (argPtr1.getByteArray()[formatStart + formatLength] == '|') {
+                                    break;
                                 }
-                                processSuccessfully = true;
                             }
-
-                            if (!processSuccessfully) {
-                                throw new HyracksDataException(
-                                        "parse-date: Failed to match with any given format string!");
+                            try {
+                                chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
+                                        formatLength, DateTimeParseMode.DATE_ONLY);
+                            } catch (AsterixTemporalTypeParseException ex) {
+                                formatStart += formatLength + 1;
+                                continue;
                             }
-
-                            aDate.setValue((int) (chronon / GregorianCalendarSystem.CHRONON_OF_DAY));
-                            dateSerde.serialize(aDate, out);
-                        } catch (HyracksDataException ex) {
-                            throw new AlgebricksException(ex);
+                            processSuccessfully = true;
+                        }
+                        if (!processSuccessfully) {
+                            throw new InvalidDataFormatException(getIdentifier(), ATypeTag.SERIALIZED_DATE_TYPE_TAG);
                         }
+                        aDate.setValue((int) (chronon / GregorianCalendarSystem.CHRONON_OF_DAY));
+                        dateSerde.serialize(aDate, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
index 9717f8e..24f62ba 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
@@ -7,7 +7,7 @@
  * "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
+ *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
@@ -31,9 +31,9 @@ import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.asterix.runtime.exceptions.InvalidDataFormatException;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -59,14 +59,12 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -84,7 +82,7 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                     private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
                         eval1.evaluate(tuple, argPtr1);
@@ -96,53 +94,50 @@ public class ParseDateTimeDescriptor extends AbstractScalarFunctionDynamicDescri
                         int offset1 = argPtr1.getStartOffset();
                         int len1 = argPtr1.getLength();
 
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expects two strings but got  ("
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
-                            }
-                            utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
-                            int start0 = utf8Ptr.getCharStartOffset();
-                            int length0 = utf8Ptr.getUTF8Length();
-
-                            utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
-                            int start1 = utf8Ptr.getCharStartOffset();
-                            int length1 = utf8Ptr.getUTF8Length();
-                            long chronon = 0;
-
-                            int formatStart = start1;
-                            int formatLength = 0;
-                            boolean processSuccessfully = false;
-                            while (!processSuccessfully && formatStart < start1 + length1) {
-                                // search for "|"
-                                formatLength = 0;
-                                for (; formatStart + formatLength < start1 + length1; formatLength++) {
-                                    if (bytes1[formatStart + formatLength] == '|') {
-                                        break;
-                                    }
-                                }
-                                try {
-                                    chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
-                                            formatLength, DateTimeParseMode.DATETIME);
-                                } catch (AsterixTemporalTypeParseException ex) {
-                                    formatStart += formatLength + 1;
-                                    continue;
+                        if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+                        }
+                        if (bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                    ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+                        }
+                        utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
+                        int start0 = utf8Ptr.getCharStartOffset();
+                        int length0 = utf8Ptr.getUTF8Length();
+
+                        utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
+                        int start1 = utf8Ptr.getCharStartOffset();
+                        int length1 = utf8Ptr.getUTF8Length();
+                        long chronon = 0;
+
+                        int formatStart = start1;
+                        int formatLength;
+                        boolean processSuccessfully = false;
+                        while (!processSuccessfully && formatStart < start1 + length1) {
+                            // search for "|"
+                            formatLength = 0;
+                            for (; formatStart + formatLength < start1 + length1; formatLength++) {
+                                if (bytes1[formatStart + formatLength] == '|') {
+                                    break;
                                 }
-                                processSuccessfully = true;
                             }
-
-                            if (!processSuccessfully) {
-                                throw new HyracksDataException(
-                                        "parse-datetime: Failed to match with any given format string!");
+                            try {
+                                chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
+                                        formatLength, DateTimeParseMode.DATETIME);
+                            } catch (AsterixTemporalTypeParseException ex) {
+                                formatStart += formatLength + 1;
+                                continue;
                             }
-                            aDateTime.setValue(chronon);
-                            datetimeSerde.serialize(aDateTime, out);
-                        } catch (HyracksDataException ex) {
-                            throw new AlgebricksException(ex);
+                            processSuccessfully = true;
+                        }
+
+                        if (!processSuccessfully) {
+                            throw new InvalidDataFormatException(getIdentifier(),
+                                    ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
                         }
+                        aDateTime.setValue(chronon);
+                        datetimeSerde.serialize(aDateTime, out);
                         result.set(resultStorage);
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
index fb4bc55..3b07c98 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
@@ -31,9 +31,9 @@ import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.asterix.runtime.exceptions.InvalidDataFormatException;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -60,14 +60,12 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
-            throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
         return new IScalarEvaluatorFactory() {
-
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -85,7 +83,7 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                     private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval0.evaluate(tuple, argPtr0);
                         eval1.evaluate(tuple, argPtr1);
@@ -97,54 +95,50 @@ public class ParseTimeDescriptor extends AbstractScalarFunctionDynamicDescriptor
                         int offset1 = argPtr1.getStartOffset();
                         int len1 = argPtr1.getLength();
 
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                                    || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expects two strings but got  ("
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")");
-                            }
-                            utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
-                            int start0 = utf8Ptr.getCharStartOffset();
-                            int length0 = utf8Ptr.getUTF8Length();
-
-                            utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
-                            int start1 = utf8Ptr.getCharStartOffset();
-                            int length1 = utf8Ptr.getUTF8Length();
-                            long chronon = 0;
-
-                            int formatStart = start1;
-                            int formatLength = 0;
-                            boolean processSuccessfully = false;
-                            while (!processSuccessfully && formatStart < start1 + length1) {
-                                // search for "|"
-                                formatLength = 0;
-                                for (; formatStart + formatLength < start1 + length1; formatLength++) {
-                                    if (bytes1[formatStart + formatLength] == '|') {
-                                        break;
-                                    }
-                                }
-                                try {
-                                    chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
-                                            formatLength, DateTimeParseMode.TIME_ONLY);
-                                } catch (AsterixTemporalTypeParseException ex) {
-                                    formatStart += formatLength + 1;
-                                    continue;
+                        if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+                        }
+                        if (bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                    ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+                        }
+                        utf8Ptr.set(bytes0, offset0 + 1, len0 - 1);
+                        int start0 = utf8Ptr.getCharStartOffset();
+                        int length0 = utf8Ptr.getUTF8Length();
+
+                        utf8Ptr.set(bytes1, offset1 + 1, len1 - 1);
+                        int start1 = utf8Ptr.getCharStartOffset();
+                        int length1 = utf8Ptr.getUTF8Length();
+                        long chronon = 0;
+
+                        int formatStart = start1;
+                        int formatLength;
+                        boolean processSuccessfully = false;
+                        while (!processSuccessfully && formatStart < start1 + length1) {
+                            // search for "|"
+                            formatLength = 0;
+                            for (; formatStart + formatLength < start1 + length1; formatLength++) {
+                                if (bytes1[formatStart + formatLength] == '|') {
+                                    break;
                                 }
-                                processSuccessfully = true;
                             }
-
-                            if (!processSuccessfully) {
-                                throw new HyracksDataException(
-                                        "parse-date: Failed to match with any given format string!");
+                            try {
+                                chronon = DT_UTILS.parseDateTime(bytes0, start0, length0, bytes1, formatStart,
+                                        formatLength, DateTimeParseMode.TIME_ONLY);
+                            } catch (AsterixTemporalTypeParseException ex) {
+                                formatStart += formatLength + 1;
+                                continue;
                             }
+                            processSuccessfully = true;
+                        }
 
-                            aTime.setValue((int) chronon);
-                            timeSerde.serialize(aTime, out);
-                        } catch (HyracksDataException ex) {
-                            throw new AlgebricksException(ex);
+                        if (!processSuccessfully) {
+                            throw new InvalidDataFormatException(getIdentifier(), ATypeTag.SERIALIZED_TIME_TYPE_TAG);
                         }
+
+                        aTime.setValue((int) chronon);
+                        timeSerde.serialize(aTime, out);
                         result.set(resultStorage);
                     }
                 };


Mime
View raw message