asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [05/22] asterixdb git commit: Unify runtime type exceptions by using error code and message template.
Date Tue, 01 Nov 2016 03:08:14 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/CalendarDurationFromDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
index b053d99..cba7f20 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
@@ -32,9 +32,8 @@ 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.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;
@@ -55,9 +54,11 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
  * 2. Calculate the differences by fields between two different time points;<br/>
  * 3. Re-format the duration into a human-readable one.
  * <p/>
- * Here "human-readable" means the value of each field of the duration is within the value range of the field in the calendar system. For example, month would be in [0, 12), and hour would be in [0, 24).
+ * Here "human-readable" means the value of each field of the duration is within the value range of the field in the
+ * calendar system. For example, month would be in [0, 12), and hour would be in [0, 24).
  * <p/>
- * The result can be considered as a "field-based" difference between the two datetime value, but all negative values would be converted to be non-negative.
+ * The result can be considered as a "field-based" difference between the two datetime value, but all negative values
+ * would be converted to be non-negative.
  * <p/>
  * In the implementation, we always do the subtraction from the later time point, resulting a positive duration always.
  * <p/>
@@ -73,18 +74,14 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti
         }
     };
 
-    /* (non-Javadoc)
-     * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
-     */
     @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();
@@ -95,15 +92,15 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti
                     private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
 
                     @SuppressWarnings("unchecked")
-                    private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
-                            .getSerializerDeserializer(BuiltinType.ADURATION);
+                    private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.
+                            INSTANCE.getSerializerDeserializer(BuiltinType.ADURATION);
 
                     private AMutableDuration aDuration = new AMutableDuration(0, 0);
 
                     private GregorianCalendarSystem calInstanct = 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);
@@ -113,118 +110,110 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti
                         byte[] bytes1 = argPtr1.getByteArray();
                         int offset1 = argPtr1.getStartOffset();
 
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects type DATETIME/NULL for parameter 0 but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]));
-                            }
+                        if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
+                        }
 
-                            if (bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects type DURATION/NULL for parameter 1 but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]));
+                        if (bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                    ATypeTag.SERIALIZED_DURATION_TYPE_TAG);
+                        }
+
+                        int yearMonthDurationInMonths = ADurationSerializerDeserializer.getYearMonth(bytes1,
+                                offset1 + 1);
+                        long dayTimeDurationInMs = ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1);
+
+                        long startingTimePoint = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
+
+                        long endingTimePoint = DurationArithmeticOperations.addDuration(startingTimePoint,
+                                yearMonthDurationInMonths, dayTimeDurationInMs, false);
+
+                        if (startingTimePoint == endingTimePoint) {
+                            aDuration.setValue(0, 0);
+                        } else {
+                            boolean negative = false;
+                            if (endingTimePoint < startingTimePoint) {
+                                negative = true;
+                                // swap the starting and ending time, so that ending time is always larger than the
+                                // starting time.
+                                long tmpTime = endingTimePoint;
+                                endingTimePoint = startingTimePoint;
+                                startingTimePoint = tmpTime;
                             }
 
-                            int yearMonthDurationInMonths = ADurationSerializerDeserializer.getYearMonth(bytes1,
-                                    offset1 + 1);
-                            long dayTimeDurationInMs = ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1);
+                            int year0 = calInstanct.getYear(startingTimePoint);
+                            int month0 = calInstanct.getMonthOfYear(startingTimePoint, year0);
+
+                            int year1 = calInstanct.getYear(endingTimePoint);
+                            int month1 = calInstanct.getMonthOfYear(endingTimePoint, year1);
+
+                            int year = year1 - year0;
+                            int month = month1 - month0;
+                            int day = calInstanct.getDayOfMonthYear(endingTimePoint, year1, month1)
+                                    - calInstanct.getDayOfMonthYear(startingTimePoint, year0, month0);
+                            int hour = calInstanct.getHourOfDay(endingTimePoint)
+                                    - calInstanct.getHourOfDay(startingTimePoint);
+                            int min = calInstanct.getMinOfHour(endingTimePoint)
+                                    - calInstanct.getMinOfHour(startingTimePoint);
+                            int sec = calInstanct.getSecOfMin(endingTimePoint)
+                                    - calInstanct.getSecOfMin(startingTimePoint);
+                            int ms = calInstanct.getMillisOfSec(endingTimePoint)
+                                    - calInstanct.getMillisOfSec(startingTimePoint);
+
+                            if (ms < 0) {
+                                ms += GregorianCalendarSystem.CHRONON_OF_SECOND;
+                                sec -= 1;
+                            }
 
-                            long startingTimePoint = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
+                            if (sec < 0) {
+                                sec += GregorianCalendarSystem.CHRONON_OF_MINUTE
+                                        / GregorianCalendarSystem.CHRONON_OF_SECOND;
+                                min -= 1;
+                            }
 
-                            long endingTimePoint = DurationArithmeticOperations.addDuration(startingTimePoint,
-                                    yearMonthDurationInMonths, dayTimeDurationInMs, false);
+                            if (min < 0) {
+                                min += GregorianCalendarSystem.CHRONON_OF_HOUR
+                                        / GregorianCalendarSystem.CHRONON_OF_MINUTE;
+                                hour -= 1;
+                            }
 
-                            if (startingTimePoint == endingTimePoint) {
-                                aDuration.setValue(0, 0);
-                            } else {
+                            if (hour < 0) {
+                                hour += GregorianCalendarSystem.CHRONON_OF_DAY
+                                        / GregorianCalendarSystem.CHRONON_OF_HOUR;
+                                day -= 1;
+                            }
 
-                                boolean negative = false;
-
-                                if (endingTimePoint < startingTimePoint) {
-                                    negative = true;
-                                    // swap the starting and ending time, so that ending time is always larger than the starting time.
-                                    long tmpTime = endingTimePoint;
-                                    endingTimePoint = startingTimePoint;
-                                    startingTimePoint = tmpTime;
-                                }
-
-                                int year0 = calInstanct.getYear(startingTimePoint);
-                                int month0 = calInstanct.getMonthOfYear(startingTimePoint, year0);
-
-                                int year1 = calInstanct.getYear(endingTimePoint);
-                                int month1 = calInstanct.getMonthOfYear(endingTimePoint, year1);
-
-                                int year = year1 - year0;
-                                int month = month1 - month0;
-                                int day = calInstanct.getDayOfMonthYear(endingTimePoint, year1, month1)
-                                        - calInstanct.getDayOfMonthYear(startingTimePoint, year0, month0);
-                                int hour = calInstanct.getHourOfDay(endingTimePoint)
-                                        - calInstanct.getHourOfDay(startingTimePoint);
-                                int min = calInstanct.getMinOfHour(endingTimePoint)
-                                        - calInstanct.getMinOfHour(startingTimePoint);
-                                int sec = calInstanct.getSecOfMin(endingTimePoint)
-                                        - calInstanct.getSecOfMin(startingTimePoint);
-                                int ms = calInstanct.getMillisOfSec(endingTimePoint)
-                                        - calInstanct.getMillisOfSec(startingTimePoint);
-
-                                if (ms < 0) {
-                                    ms += GregorianCalendarSystem.CHRONON_OF_SECOND;
-                                    sec -= 1;
-                                }
-
-                                if (sec < 0) {
-                                    sec += GregorianCalendarSystem.CHRONON_OF_MINUTE
-                                            / GregorianCalendarSystem.CHRONON_OF_SECOND;
-                                    min -= 1;
-                                }
-
-                                if (min < 0) {
-                                    min += GregorianCalendarSystem.CHRONON_OF_HOUR
-                                            / GregorianCalendarSystem.CHRONON_OF_MINUTE;
-                                    hour -= 1;
-                                }
-
-                                if (hour < 0) {
-                                    hour += GregorianCalendarSystem.CHRONON_OF_DAY
-                                            / GregorianCalendarSystem.CHRONON_OF_HOUR;
-                                    day -= 1;
-                                }
-
-                                if (day < 0) {
-                                    boolean isLeapYear = calInstanct.isLeapYear(year1);
-                                    // need to "borrow" the days in previous month to make the day positive; when month is 1 (Jan), Dec will be borrowed
-                                    day += (isLeapYear)
-                                            ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[(12 + month1 - 2) % 12])
-                                            : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[(12 + month1 - 2) % 12]);
-                                    month -= 1;
-                                }
-
-                                if (month < 0) {
-                                    month += GregorianCalendarSystem.MONTHS_IN_A_YEAR;
-                                    year -= 1;
-                                }
-
-                                if (negative) {
-                                    aDuration.setValue(-1 * (year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month),
-                                            -1 * (day * GregorianCalendarSystem.CHRONON_OF_DAY
-                                                    + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
-                                                    + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
-                                                    + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms));
-                                } else {
-                                    aDuration.setValue(year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month,
-                                            day * GregorianCalendarSystem.CHRONON_OF_DAY
-                                                    + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
-                                                    + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
-                                                    + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms);
-                                }
+                            if (day < 0) {
+                                boolean isLeapYear = calInstanct.isLeapYear(year1);
+                                // need to "borrow" the days in previous month to make the day positive; when month is
+                                // 1 (Jan), Dec will be borrowed
+                                day += isLeapYear
+                                        ? (GregorianCalendarSystem.DAYS_OF_MONTH_LEAP[(12 + month1 - 2) % 12])
+                                        : (GregorianCalendarSystem.DAYS_OF_MONTH_ORDI[(12 + month1 - 2) % 12]);
+                                month -= 1;
                             }
 
-                            durationSerde.serialize(aDuration, out);
+                            if (month < 0) {
+                                month += GregorianCalendarSystem.MONTHS_IN_A_YEAR;
+                                year -= 1;
+                            }
 
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                            if (negative) {
+                                aDuration.setValue(-1 * (year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month),
+                                        -1 * (day * GregorianCalendarSystem.CHRONON_OF_DAY
+                                                + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
+                                                + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
+                                                + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms));
+                            } else {
+                                aDuration.setValue(year * GregorianCalendarSystem.MONTHS_IN_A_YEAR + month,
+                                        day * GregorianCalendarSystem.CHRONON_OF_DAY
+                                                + hour * GregorianCalendarSystem.CHRONON_OF_HOUR
+                                                + min * GregorianCalendarSystem.CHRONON_OF_MINUTE
+                                                + sec * GregorianCalendarSystem.CHRONON_OF_SECOND + ms);
+                            }
                         }
+                        durationSerde.serialize(aDuration, out);
                         result.set(resultStorage);
                     }
                 };
@@ -233,8 +222,8 @@ public class CalendarDurationFromDateTimeDescriptor extends AbstractScalarFuncti
     }
 
     /* (non-Javadoc)
-     * @see org.apache.asterix.om.functions.IFunctionDescriptor#getIdentifier()
-     */
+    * @see org.apache.asterix.om.functions.IFunctionDescriptor#getIdentifier()
+    */
     @Override
     public FunctionIdentifier getIdentifier() {
         return FID;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateDescriptor.java
index e1f783a..e958a30 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateDescriptor.java
@@ -29,7 +29,6 @@ import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 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;
@@ -54,13 +53,13 @@ public class CurrentDateDescriptor extends AbstractScalarFunctionDynamicDescript
     };
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(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();
@@ -72,17 +71,12 @@ public class CurrentDateDescriptor extends AbstractScalarFunctionDynamicDescript
                     private AMutableDate aDate = new AMutableDate(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
-                        try {
-                            resultStorage.reset();
-                            int dateChronon = (int) (System.currentTimeMillis()
-                                    / GregorianCalendarSystem.CHRONON_OF_DAY);
-                            aDate.setValue(dateChronon);
-                            dateSerde.serialize(aDate, out);
-                            result.set(resultStorage);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
-                        }
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
+                        resultStorage.reset();
+                        int dateChronon = (int) (System.currentTimeMillis() / GregorianCalendarSystem.CHRONON_OF_DAY);
+                        aDate.setValue(dateChronon);
+                        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/CurrentDateTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateTimeDescriptor.java
index c7cc45d..c8f310a 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentDateTimeDescriptor.java
@@ -28,7 +28,6 @@ import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 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;
@@ -56,13 +55,12 @@ public class CurrentDateTimeDescriptor extends AbstractScalarFunctionDynamicDesc
     }
 
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(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();
@@ -74,15 +72,11 @@ public class CurrentDateTimeDescriptor extends AbstractScalarFunctionDynamicDesc
                     private AMutableDateTime aDateTime = new AMutableDateTime(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
-                        try {
-                            resultStorage.reset();
-                            aDateTime.setValue(System.currentTimeMillis());
-                            datetimeSerde.serialize(aDateTime, out);
-                            result.set(resultStorage);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
-                        }
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
+                        resultStorage.reset();
+                        aDateTime.setValue(System.currentTimeMillis());
+                        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/CurrentTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentTimeDescriptor.java
index 857c25b..be1f877 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CurrentTimeDescriptor.java
@@ -29,7 +29,6 @@ import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 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;
@@ -57,13 +56,12 @@ public class CurrentTimeDescriptor extends AbstractScalarFunctionDynamicDescript
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @Override
-    public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
+    public IScalarEvaluatorFactory createEvaluatorFactory(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();
@@ -75,17 +73,12 @@ public class CurrentTimeDescriptor extends AbstractScalarFunctionDynamicDescript
                     private AMutableTime aTime = new AMutableTime(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
-                        try {
-                            resultStorage.reset();
-                            int timeChronon = (int) (System.currentTimeMillis()
-                                    % GregorianCalendarSystem.CHRONON_OF_DAY);
-                            aTime.setValue(timeChronon);
-                            timeSerde.serialize(aTime, out);
-                            result.set(resultStorage);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
-                        }
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
+                        resultStorage.reset();
+                        int timeChronon = (int) (System.currentTimeMillis() % GregorianCalendarSystem.CHRONON_OF_DAY);
+                        aTime.setValue(timeChronon);
+                        timeSerde.serialize(aTime, 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/DateFromDatetimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
index d4fa0e6..869ac7b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
@@ -25,14 +25,13 @@ import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ADate;
 import org.apache.asterix.om.base.AMutableDate;
 import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
+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;
@@ -57,14 +56,13 @@ public class DateFromDatetimeDescriptor extends AbstractScalarFunctionDynamicDes
     };
 
     @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();
@@ -79,29 +77,23 @@ public class DateFromDatetimeDescriptor extends AbstractScalarFunctionDynamicDes
                     private AMutableDate aDate = new AMutableDate(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval.evaluate(tuple, argPtr);
                         byte[] bytes = argPtr.getByteArray();
                         int offset = argPtr.getStartOffset();
 
-                        try {
-                            if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects input type DATETIME/NULL but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
-                            }
-                            long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
-                            int dateChrononInDays = (int) (datetimeChronon / GregorianCalendarSystem.CHRONON_OF_DAY);
-                            if (dateChrononInDays < 0
-                                    && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
-                                dateChrononInDays -= 1;
-                            }
-                            aDate.setValue(dateChrononInDays);
-                            dateSerde.serialize(aDate, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes[offset],
+                                    ATypeTag.SERIALIZED_DATETIME_TYPE_TAG);
                         }
+                        long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
+                        int dateChrononInDays = (int) (datetimeChronon / GregorianCalendarSystem.CHRONON_OF_DAY);
+                        if (dateChrononInDays < 0 && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
+                            dateChrononInDays -= 1;
+                        }
+                        aDate.setValue(dateChrononInDays);
+                        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/DateFromUnixTimeInDaysDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
index 5fa57f6..58e2213 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.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,12 @@ public class DateFromUnixTimeInDaysDescriptor 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() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -77,16 +74,12 @@ public class DateFromUnixTimeInDaysDescriptor extends AbstractScalarFunctionDyna
                             .getSerializerDeserializer(BuiltinType.ADATE);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval.evaluate(tuple, argPtr);
-                        try {
-                            aDate.setValue(
-                                    ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset()));
-                            dateSerde.serialize(aDate, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
-                        }
+                        aDate.setValue(ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 0,
+                                argPtr.getByteArray(), argPtr.getStartOffset()));
+                        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/DatetimeFromDateAndTimeDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
index 98f84aa..96a3e30 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
@@ -26,14 +26,13 @@ import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ADateTime;
 import org.apache.asterix.om.base.AMutableDateTime;
 import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
+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;
@@ -61,14 +60,12 @@ public class DatetimeFromDateAndTimeDescriptor extends AbstractScalarFunctionDyn
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @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 +82,7 @@ public class DatetimeFromDateAndTimeDescriptor extends AbstractScalarFunctionDyn
                     private AMutableDateTime aDateTime = new AMutableDateTime(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);
                         eval1.evaluate(tuple, argPtr1);
@@ -95,25 +92,21 @@ public class DatetimeFromDateAndTimeDescriptor extends AbstractScalarFunctionDyn
                         byte[] bytes1 = argPtr1.getByteArray();
                         int offset1 = argPtr1.getStartOffset();
 
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG
-                                    && bytes1[offset1] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName()
-                                        + ": expects input type (DATE/NULL, TIME/NULL) but got ("
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ").");
-
-                            }
+                        if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_DATE_TYPE_TAG);
+                        }
+                        if (bytes1[offset1] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                    ATypeTag.SERIALIZED_TIME_TYPE_TAG);
+                        }
 
-                            long datetimeChronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
-                                    * GregorianCalendarSystem.CHRONON_OF_DAY
-                                    + ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
+                        long datetimeChronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
+                                * GregorianCalendarSystem.CHRONON_OF_DAY
+                                + ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
 
-                            aDateTime.setValue(datetimeChronon);
-                            datetimeSerde.serialize(aDateTime, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
-                        }
+                        aDateTime.setValue(datetimeChronon);
+                        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/DatetimeFromUnixTimeInMsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java
index d9c0156..a5200cd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.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.ADateTime;
 import org.apache.asterix.om.base.AMutableDateTime;
+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;
@@ -62,14 +62,13 @@ public class DatetimeFromUnixTimeInMsDescriptor extends AbstractScalarFunctionDy
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @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,34 +84,31 @@ public class DatetimeFromUnixTimeInMsDescriptor extends AbstractScalarFunctionDy
                     private AMutableDateTime aDatetime = new AMutableDateTime(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval.evaluate(tuple, argPtr);
                         byte[] bytes = argPtr.getByteArray();
                         int offset = argPtr.getStartOffset();
-                        try {
-                            ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
-                            switch (argPtrTypeTag) {
-                                case INT8:
-                                    aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1));
-                                    break;
-                                case INT16:
-                                    aDatetime.setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1));
-                                    break;
-                                case INT32:
-                                    aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1));
-                                    break;
-                                case INT64:
-                                    aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1));
-                                    break;
-                                default:
-                                    throw new AlgebricksException(FID.getName()
-                                            + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag);
-                            }
-                            datetimeSerde.serialize(aDatetime, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
+                        switch (argPtrTypeTag) {
+                            case INT8:
+                                aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1));
+                                break;
+                            case INT16:
+                                aDatetime.setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1));
+                                break;
+                            case INT32:
+                                aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1));
+                                break;
+                            case INT64:
+                                aDatetime.setValue(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);
                         }
+                        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/DatetimeFromUnixTimeInSecsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java
index a0258b6..b71ac93 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.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
@@ -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.ADateTime;
 import org.apache.asterix.om.base.AMutableDateTime;
+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;
@@ -62,14 +62,12 @@ public class DatetimeFromUnixTimeInSecsDescriptor extends AbstractScalarFunction
      * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
      */
     @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,39 +83,33 @@ public class DatetimeFromUnixTimeInSecsDescriptor extends AbstractScalarFunction
                     private AMutableDateTime aDatetime = new AMutableDateTime(0);
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                         resultStorage.reset();
                         eval.evaluate(tuple, argPtr);
 
                         byte[] bytes = argPtr.getByteArray();
                         int offset = argPtr.getStartOffset();
-
-                        try {
-
-                            ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
-
-                            switch (argPtrTypeTag) {
-                                case INT8:
-                                    aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1) * 1000l);
-                                    break;
-                                case INT16:
-                                    aDatetime
-                                            .setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1) * 1000l);
-                                    break;
-                                case INT32:
-                                    aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1) * 1000l);
-                                    break;
-                                case INT64:
-                                    aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1) * 1000l);
-                                    break;
-                                default:
-                                    throw new AlgebricksException(FID.getName()
-                                            + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag);
-                            }
-                            datetimeSerde.serialize(aDatetime, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
+
+                        switch (argPtrTypeTag) {
+                            case INT8:
+                                aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1) * 1000l);
+                                break;
+                            case INT16:
+                                aDatetime.setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1) * 1000l);
+                                break;
+                            case INT32:
+                                aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1) * 1000l);
+                                break;
+                            case INT64:
+                                aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1) * 1000l);
+                                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);
                         }
+                        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/DayOfWeekDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
index e1fe88b..5993da9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
@@ -26,14 +26,13 @@ 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.om.base.temporal.GregorianCalendarSystem;
+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;
@@ -61,14 +60,12 @@ public class DayOfWeekDescriptor 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();
@@ -83,53 +80,48 @@ public class DayOfWeekDescriptor extends AbstractScalarFunctionDynamicDescriptor
                     private 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();
                         eval.evaluate(tuple, argPtr);
 
                         byte[] bytes = argPtr.getByteArray();
                         int offset = argPtr.getStartOffset();
 
-                        try {
-                            int daysSinceAnchor;
-                            int reminder = 0;
-                            if (bytes[offset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
-                                daysSinceAnchor = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1)
-                                        / GregorianCalendarSystem.CHRONON_OF_DAY);
-                                reminder = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1)
-                                        % GregorianCalendarSystem.CHRONON_OF_DAY);
-                            } else if (bytes[offset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
-                                daysSinceAnchor = ADateSerializerDeserializer.getChronon(bytes, offset + 1);
-                            } else {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects input type DATETIME/DATE/NULL but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
-                            }
-
-                            // adjust the day before 1970-01-01
-                            if (daysSinceAnchor < 0 && reminder != 0) {
-                                daysSinceAnchor -= 1;
-                            }
-
-                            // compute the weekday (0-based, and 0 = Sunday). Adjustment is needed as
-                            // the anchor day is Thursday.
-                            int weekday = (daysSinceAnchor + ANCHOR_WEEKDAY) % 7;
-
-                            // handle the negative weekday
-                            if (weekday < 0) {
-                                weekday += 7;
-                            }
-
-                            // convert from 0-based to 1-based (so 7 = Sunday)
-                            if (weekday == 0) {
-                                weekday = 7;
-                            }
-
-                            aInt64.setValue(weekday);
-                            int64Serde.serialize(aInt64, out);
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        int daysSinceAnchor;
+                        int reminder = 0;
+                        if (bytes[offset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+                            daysSinceAnchor = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1)
+                                    / GregorianCalendarSystem.CHRONON_OF_DAY);
+                            reminder = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1)
+                                    % GregorianCalendarSystem.CHRONON_OF_DAY);
+                        } else if (bytes[offset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
+                            daysSinceAnchor = ADateSerializerDeserializer.getChronon(bytes, offset + 1);
+                        } else {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes[offset],
+                                    ATypeTag.SERIALIZED_DATETIME_TYPE_TAG, ATypeTag.SERIALIZED_DATE_TYPE_TAG);
+                        }
+
+                        // adjust the day before 1970-01-01
+                        if (daysSinceAnchor < 0 && reminder != 0) {
+                            daysSinceAnchor -= 1;
                         }
+
+                        // compute the weekday (0-based, and 0 = Sunday). Adjustment is needed as
+                        // the anchor day is Thursday.
+                        int weekday = (daysSinceAnchor + ANCHOR_WEEKDAY) % 7;
+
+                        // handle the negative weekday
+                        if (weekday < 0) {
+                            weekday += 7;
+                        }
+
+                        // convert from 0-based to 1-based (so 7 = Sunday)
+                        if (weekday == 0) {
+                            weekday = 7;
+                        }
+
+                        aInt64.setValue(weekday);
+                        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/DayTimeDurationComparatorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
index 2d29c81..3188b08 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
@@ -26,9 +26,9 @@ import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 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;
@@ -52,14 +52,12 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD
     }
 
     @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();
@@ -74,7 +72,7 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD
                             .getSerializerDeserializer(BuiltinType.ABOOLEAN);
 
                     @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);
@@ -84,29 +82,26 @@ public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionD
                         byte[] bytes1 = argPtr1.getByteArray();
                         int offset1 = argPtr1.getStartOffset();
 
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG
-                                    || bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(getIdentifier().getName()
-                                        + ": expects type NULL/DURATION, NULL/DURATION but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + " and "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]));
-                            }
-
-                            if ((ADurationSerializerDeserializer.getYearMonth(bytes0, offset0 + 1) != 0)
-                                    || (ADurationSerializerDeserializer.getYearMonth(bytes1, offset1 + 1) != 0)) {
-                                throw new AlgebricksException(
-                                        getIdentifier().getName() + ": only year-month durations are allowed.");
-                            }
-
-                            if (ADurationSerializerDeserializer.getDayTime(bytes0,
-                                    offset0 + 1) > ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1)) {
-                                boolSerde.serialize(isGreaterThan ? ABoolean.TRUE : ABoolean.FALSE, out);
-                            } else {
-                                boolSerde.serialize(isGreaterThan ? ABoolean.FALSE : ABoolean.TRUE, 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);
+                        }
+                        if (bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                    ATypeTag.SERIALIZED_DURATION_TYPE_TAG);
+                        }
+
+                        if ((ADurationSerializerDeserializer.getYearMonth(bytes0, offset0 + 1) != 0)
+                                || (ADurationSerializerDeserializer.getYearMonth(bytes1, offset1 + 1) != 0)) {
+                            throw new InvalidDataFormatException(getIdentifier(),
+                                    ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG);
+                        }
+
+                        if (ADurationSerializerDeserializer.getDayTime(bytes0,
+                                offset0 + 1) > ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1)) {
+                            boolSerde.serialize(isGreaterThan ? ABoolean.TRUE : ABoolean.FALSE, out);
+                        } else {
+                            boolSerde.serialize(isGreaterThan ? ABoolean.FALSE : ABoolean.TRUE, 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/DurationEqualDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
index 0a88684..27b3304 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
@@ -23,14 +23,13 @@ import java.io.DataOutput;
 import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ABoolean;
+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;
@@ -54,14 +53,12 @@ public class DurationEqualDescriptor 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();
@@ -76,7 +73,7 @@ public class DurationEqualDescriptor extends AbstractScalarFunctionDynamicDescri
                             .getSerializerDeserializer(BuiltinType.ABOOLEAN);
 
                     @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);
@@ -86,26 +83,23 @@ public class DurationEqualDescriptor extends AbstractScalarFunctionDynamicDescri
                         byte[] bytes1 = argPtr1.getByteArray();
                         int offset1 = argPtr1.getStartOffset();
 
-                        try {
-                            if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG
-                                    || bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
-                                throw new AlgebricksException(FID.getName()
-                                        + ": expects type NULL/DURATION, NULL/DURATION but got "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + " and "
-                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]));
-                            }
+                        if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes0[offset0],
+                                    ATypeTag.SERIALIZED_DURATION_TYPE_TAG);
+                        }
+                        if (bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 1, bytes1[offset1],
+                                    ATypeTag.SERIALIZED_DURATION_TYPE_TAG);
+                        }
 
-                            if ((ADurationSerializerDeserializer.getDayTime(bytes0,
-                                    offset0 + 1) == ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1))
-                                    && (ADurationSerializerDeserializer.getYearMonth(bytes0,
-                                            offset0 + 1) == ADurationSerializerDeserializer.getYearMonth(bytes1,
+                        if ((ADurationSerializerDeserializer.getDayTime(bytes0,
+                                offset0 + 1) == ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1))
+                                && (ADurationSerializerDeserializer.getYearMonth(bytes0,
+                                        offset0 + 1) == ADurationSerializerDeserializer.getYearMonth(bytes1,
                                                     offset1 + 1))) {
                                 boolSerde.serialize(ABoolean.TRUE, out);
-                            } else {
+                        } else {
                                 boolSerde.serialize(ABoolean.FALSE, out);
-                            }
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
                         }
                         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/DurationFromIntervalDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
index 0c4042f..d3862b7 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
@@ -25,14 +25,13 @@ 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.om.base.temporal.GregorianCalendarSystem;
+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;
@@ -57,14 +56,12 @@ public class DurationFromIntervalDescriptor 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();
@@ -79,35 +76,28 @@ public class DurationFromIntervalDescriptor extends AbstractScalarFunctionDynami
                     private 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();
                         eval.evaluate(tuple, argPtr);
 
                         byte[] bytes = argPtr.getByteArray();
                         int offset = argPtr.getStartOffset();
 
-                        try {
-                            if (bytes[offset] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
-                                throw new AlgebricksException(
-                                        FID.getName() + ": expects INTERVAL/NULL as the input but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
-                            }
-                            long chrononStart = AIntervalSerializerDeserializer.getIntervalStart(bytes, offset + 1);
-                            long chrononEnd = AIntervalSerializerDeserializer.getIntervalEnd(bytes, offset + 1);
-                            byte intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
-                                    offset + 1);
-
-                            if (intervalTypeTag == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
-                                chrononStart *= GregorianCalendarSystem.CHRONON_OF_DAY;
-                                chrononEnd *= GregorianCalendarSystem.CHRONON_OF_DAY;
-                            }
-
-                            aDayTimeDuration.setMilliseconds(chrononEnd - chrononStart);
-                            dayTimeDurationSerde.serialize(aDayTimeDuration, out);
-
-                        } catch (HyracksDataException hex) {
-                            throw new AlgebricksException(hex);
+                        if (bytes[offset] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+                            throw new TypeMismatchException(getIdentifier(), 0, bytes[offset],
+                                    ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG);
+                        }
+                        long chrononStart = AIntervalSerializerDeserializer.getIntervalStart(bytes, offset + 1);
+                        long chrononEnd = AIntervalSerializerDeserializer.getIntervalEnd(bytes, offset + 1);
+                        byte intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(bytes, offset + 1);
+
+                        if (intervalTypeTag == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
+                            chrononStart *= GregorianCalendarSystem.CHRONON_OF_DAY;
+                            chrononEnd *= GregorianCalendarSystem.CHRONON_OF_DAY;
                         }
+
+                        aDayTimeDuration.setMilliseconds(chrononEnd - chrononStart);
+                        dayTimeDurationSerde.serialize(aDayTimeDuration, out);
                         result.set(resultStorage);
                     }
                 };


Mime
View raw message