asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [14/22] asterixdb git commit: Unify runtime type exceptions by using error code and message template.
Date Tue, 01 Nov 2016 03:08:23 GMT
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
index a296ae9..2aeb6ee 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
@@ -32,12 +32,14 @@ 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.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;
 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.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -59,14 +61,13 @@ public class ATimeConstructorDescriptor extends AbstractScalarFunctionDynamicDes
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
                     private DataOutput out = resultStorage.getDataOutput();
                     private IPointable inputArg = new VoidPointable();
                     private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-                    private String errorMessage = "This can not be an instance of time";
                     private AMutableTime aTime = new AMutableTime(0);
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -74,8 +75,7 @@ public class ATimeConstructorDescriptor extends AbstractScalarFunctionDynamicDes
                     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 {
                         try {
                             resultStorage.reset();
                             eval.evaluate(tuple, inputArg);
@@ -90,9 +90,8 @@ public class ATimeConstructorDescriptor extends AbstractScalarFunctionDynamicDes
 
                                 // the string to be parsed should be at least 6 characters: hhmmss
                                 if (stringLength < 6) {
-                                    throw new AlgebricksException(errorMessage
-                                            + ": the string length should be at least 6 (hhmmss) but it is "
-                                            + stringLength);
+                                    throw new InvalidDataFormatException(getIdentifier(),
+                                            ATypeTag.SERIALIZED_POLYGON_TYPE_TAG);
                                 }
 
                                 int chrononTimeInMs = ATimeParserFactory.parseTimePart(serString, startOffset,
@@ -105,11 +104,13 @@ public class ATimeConstructorDescriptor extends AbstractScalarFunctionDynamicDes
                                 aTime.setValue(chrononTimeInMs);
                                 timeSerde.serialize(aTime, out);
                             } else {
-                                throw new AlgebricksException(errorMessage);
+                                throw new TypeMismatchException(getIdentifier(), 0, serString[offset],
+                                        ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             }
                             result.set(resultStorage);
-                        } catch (IOException e1) {
-                            throw new AlgebricksException(errorMessage);
+                        } catch (IOException e) {
+                            throw new InvalidDataFormatException(getIdentifier(), e,
+                                    ATypeTag.SERIALIZED_POLYGON_TYPE_TAG);
                         }
                     }
                 };

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java
index 44140fb..bddd9bc 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java
@@ -30,12 +30,14 @@ 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.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;
 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.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -62,14 +64,13 @@ public class AUUIDFromStringConstructorDescriptor extends AbstractScalarFunction
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
                     private DataOutput out = resultStorage.getDataOutput();
                     private IPointable inputArg = new VoidPointable();
                     private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-                    private String errorMessage = "This can not be an instance of UUID";
                     private AMutableUUID uuid = new AMutableUUID();
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<AUUID> uuidSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -78,7 +79,7 @@ public class AUUIDFromStringConstructorDescriptor extends AbstractScalarFunction
                     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 {
                         try {
                             resultStorage.reset();
                             eval.evaluate(tuple, inputArg);
@@ -93,11 +94,12 @@ public class AUUIDFromStringConstructorDescriptor extends AbstractScalarFunction
                                 uuid.parseUUIDHexBytes(serString, offset);
                                 uuidSerde.serialize(uuid, out);
                             } else {
-                                throw new AlgebricksException(errorMessage);
+                                throw new TypeMismatchException(getIdentifier(), 0, serString[start],
+                                        ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             }
                             result.set(resultStorage);
-                        } catch (IOException e1) {
-                            throw new AlgebricksException(errorMessage);
+                        } catch (IOException e) {
+                            throw new InvalidDataFormatException(getIdentifier(), e, ATypeTag.SERIALIZED_UUID_TYPE_TAG);
                         }
                     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
index 160043f..889af14 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
@@ -31,12 +31,14 @@ 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.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;
 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.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -59,14 +61,13 @@ public class AYearMonthDurationConstructorDescriptor extends AbstractScalarFunct
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
                 return new IScalarEvaluator() {
 
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
                     private DataOutput out = resultStorage.getDataOutput();
                     private IPointable inputArg = new VoidPointable();
                     private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-                    private String errorMessage = "This can not be an instance of year-month-duration";
                     private AMutableYearMonthDuration aYearMonthDuration = new AMutableYearMonthDuration(0);
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -74,7 +75,7 @@ public class AYearMonthDurationConstructorDescriptor extends AbstractScalarFunct
                     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 {
                         try {
                             resultStorage.reset();
                             eval.evaluate(tuple, inputArg);
@@ -89,11 +90,13 @@ public class AYearMonthDurationConstructorDescriptor extends AbstractScalarFunct
                                         stringLength, aYearMonthDuration, ADurationParseOption.YEAR_MONTH);
                                 yearMonthDurationSerde.serialize(aYearMonthDuration, out);
                             } else {
-                                throw new AlgebricksException(errorMessage);
+                                throw new TypeMismatchException(getIdentifier(), 0, serString[offset],
+                                        ATypeTag.SERIALIZED_STRING_TYPE_TAG);
                             }
                             result.set(resultStorage);
-                        } catch (Exception e1) {
-                            throw new AlgebricksException(e1);
+                        } catch (Exception e) {
+                            throw new InvalidDataFormatException(getIdentifier(), e,
+                                    ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG);
                         }
                     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
index 94f3b20..002e1a9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
@@ -27,7 +27,6 @@ import org.apache.asterix.om.functions.IFunctionDescriptor;
 import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
 import org.apache.asterix.om.types.ARecordType;
 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;
@@ -67,7 +66,7 @@ public class OpenRecordConstructorDescriptor extends AbstractScalarFunctionDynam
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
                 int n = args.length / 2;
                 final IScalarEvaluator[] evalNames = new IScalarEvaluator[n];
                 final IScalarEvaluator[] evalFields = new IScalarEvaluator[n];
@@ -85,31 +84,27 @@ public class OpenRecordConstructorDescriptor extends AbstractScalarFunctionDynam
                     private boolean first = true;
 
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
-                        try {
-                            resultStorage.reset();
-                            closedFieldId = 0;
-                            if (first) {
-                                first = false;
-                                recBuilder.reset(recType);
-                            }
-                            recBuilder.init();
-                            for (int i = 0; i < evalFields.length; i++) {
-                                evalFields[i].evaluate(tuple, fieldValuePointable);
-                                boolean openField = openFields[i];
-                                if (openField) {
-                                    evalNames[i].evaluate(tuple, fieldNamePointable);
-                                    recBuilder.addField(fieldNamePointable, fieldValuePointable);
-                                } else {
-                                    recBuilder.addField(closedFieldId, fieldValuePointable);
-                                    closedFieldId++;
-                                }
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
+                        resultStorage.reset();
+                        closedFieldId = 0;
+                        if (first) {
+                            first = false;
+                            recBuilder.reset(recType);
+                        }
+                        recBuilder.init();
+                        for (int i = 0; i < evalFields.length; i++) {
+                            evalFields[i].evaluate(tuple, fieldValuePointable);
+                            boolean openField = openFields[i];
+                            if (openField) {
+                                evalNames[i].evaluate(tuple, fieldNamePointable);
+                                recBuilder.addField(fieldNamePointable, fieldValuePointable);
+                            } else {
+                                recBuilder.addField(closedFieldId, fieldValuePointable);
+                                closedFieldId++;
                             }
-                            recBuilder.write(out, true);
-                            result.set(resultStorage);
-                        } catch (HyracksDataException e) {
-                            throw new AlgebricksException(e);
                         }
+                        recBuilder.write(out, true);
+                        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/AbstractBinaryStringBoolEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java
index 99ba91a..128802d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java
@@ -23,7 +23,7 @@ import java.io.IOException;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -39,7 +39,7 @@ public abstract class AbstractBinaryStringBoolEval extends AbstractBinaryStringE
             .getSerializerDeserializer(BuiltinType.ABOOLEAN);
 
     public AbstractBinaryStringBoolEval(IHyracksTaskContext context, IScalarEvaluatorFactory evalLeftFactory,
-            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws AlgebricksException {
+            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws HyracksDataException {
         super(context, evalLeftFactory, evalRightFactory, funcID);
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringEval.java
index ab66ac6..7c0ee6b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringEval.java
@@ -22,13 +22,13 @@ package org.apache.asterix.runtime.evaluators.functions;
 import java.io.DataOutput;
 import java.io.IOException;
 
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-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;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -55,7 +55,7 @@ public abstract class AbstractBinaryStringEval implements IScalarEvaluator {
     private final FunctionIdentifier funcID;
 
     public AbstractBinaryStringEval(IHyracksTaskContext context, IScalarEvaluatorFactory evalLeftFactory,
-            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws AlgebricksException {
+            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws HyracksDataException {
         this.evalLeft = evalLeftFactory.createScalarEvaluator(context);
         this.evalRight = evalRightFactory.createScalarEvaluator(context);
         this.funcID = funcID;
@@ -63,7 +63,7 @@ public abstract class AbstractBinaryStringEval implements IScalarEvaluator {
 
     @SuppressWarnings("unchecked")
     @Override
-    public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws AlgebricksException {
+    public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws HyracksDataException {
         resultStorage.reset();
 
         // Gets the first argument.
@@ -79,11 +79,11 @@ public abstract class AbstractBinaryStringEval implements IScalarEvaluator {
         int len1 = argPtrSecond.getLength();
 
         // Type check.
-        if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-            throw new AlgebricksException(funcID.getName() + ": expects input type STRING, but got "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + " and "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")!");
+        if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 0, bytes0[offset0], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+        }
+        if (bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 1, bytes1[offset1], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
         }
 
         // Sets StringUTF8Pointables.
@@ -94,7 +94,7 @@ public abstract class AbstractBinaryStringEval implements IScalarEvaluator {
         try {
             process(leftPtr, rightPtr, resultPointable);
         } catch (IOException e) {
-            throw new AlgebricksException(e);
+            throw new HyracksDataException(e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringIntEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringIntEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringIntEval.java
index cd7f6c4..4aecdb8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringIntEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringIntEval.java
@@ -24,7 +24,7 @@ import java.io.IOException;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.AMutableInt32;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -41,7 +41,7 @@ public abstract class AbstractBinaryStringIntEval extends AbstractBinaryStringEv
     private AMutableInt32 resultValue = new AMutableInt32(0);
 
     public AbstractBinaryStringIntEval(IHyracksTaskContext context, IScalarEvaluatorFactory evalLeftFactory,
-            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws AlgebricksException {
+            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws HyracksDataException {
         super(context, evalLeftFactory, evalRightFactory, funcID);
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringStringEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringStringEval.java
index a944de3..7cdf673 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringStringEval.java
@@ -22,10 +22,10 @@ package org.apache.asterix.runtime.evaluators.functions;
 import java.io.IOException;
 
 import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.GrowableArray;
@@ -39,7 +39,7 @@ public abstract class AbstractBinaryStringStringEval extends AbstractBinaryStrin
     protected final UTF8StringBuilder resultBuilder = new UTF8StringBuilder();
 
     public AbstractBinaryStringStringEval(IHyracksTaskContext context, IScalarEvaluatorFactory evalLeftFactory,
-            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws AlgebricksException {
+            IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws HyracksDataException {
         super(context, evalLeftFactory, evalRightFactory, funcID);
     }
 
@@ -60,7 +60,7 @@ public abstract class AbstractBinaryStringStringEval extends AbstractBinaryStrin
      *            , the second input argument.
      * @param resultStrPtr
      *            , a pointable that is supposed to point to the result string.
-     * @throws AlgebricksException
+     * @throws HyracksDataException
      */
     protected abstract void compute(UTF8StringPointable left, UTF8StringPointable right,
             UTF8StringPointable resultStrPtr) throws IOException;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
index 56b473e..0dbda8e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
@@ -48,8 +48,12 @@ 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.asterix.runtime.exceptions.IncompatibleTypeException;
+import org.apache.asterix.runtime.exceptions.OverflowException;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
+import org.apache.asterix.runtime.exceptions.UnderflowException;
+import org.apache.asterix.runtime.exceptions.UnsupportedTypeException;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -97,7 +101,7 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
             private static final long serialVersionUID = 1L;
 
             @Override
-            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
+            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {
 
                 return new IScalarEvaluator() {
                     private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
@@ -134,156 +138,149 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
 
                     @SuppressWarnings("unchecked")
                     @Override
-                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
-                        try {
-                            resultStorage.reset();
-                            resultType = 0;
-                            int currentType = 0;
-                            evalLeft.evaluate(tuple, argPtr0);
-                            evalRight.evaluate(tuple, argPtr1);
-
-                            for (int i = 0; i < args.length; i++) {
-                                IPointable argPtr = i == 0 ? argPtr0 : argPtr1;
-                                byte[] bytes = argPtr.getByteArray();
-                                int offset = argPtr.getStartOffset();
-
-                                typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
-                                switch (typeTag) {
-                                    case INT8: {
-                                        currentType = typeInt8;
-                                        operandsInteger[i] = AInt8SerializerDeserializer.getByte(bytes, offset + 1);
-                                        operandsFloating[i] = operandsInteger[i];
-                                        break;
-                                    }
-                                    case INT16: {
-                                        currentType = typeInt16;
-                                        operandsInteger[i] = AInt16SerializerDeserializer.getShort(bytes, offset + 1);
-                                        operandsFloating[i] = operandsInteger[i];
-                                        break;
-                                    }
-                                    case INT32: {
-                                        currentType = typeInt32;
-                                        operandsInteger[i] = AInt32SerializerDeserializer.getInt(bytes, offset + 1);
-                                        operandsFloating[i] = operandsInteger[i];
-                                        break;
-                                    }
-                                    case INT64: {
-                                        currentType = typeInt64;
-                                        operandsInteger[i] = AInt64SerializerDeserializer.getLong(bytes, offset + 1);
-                                        operandsFloating[i] = operandsInteger[i];
-                                        break;
-                                    }
-                                    case FLOAT: {
-                                        currentType = typeFloat;
-                                        operandsFloating[i] = AFloatSerializerDeserializer.getFloat(bytes, offset + 1);
-                                        break;
-                                    }
-                                    case DOUBLE: {
-                                        currentType = typeDouble;
-                                        operandsFloating[i] = ADoubleSerializerDeserializer.getDouble(bytes,
-                                                offset + 1);
-                                        break;
-                                    }
-                                    case DATE:
-                                    case TIME:
-                                    case DATETIME:
-                                    case DURATION:
-                                    case YEARMONTHDURATION:
-                                    case DAYTIMEDURATION:
-                                        evaluateTemporalArthmeticOperation(typeTag);
-                                        result.set(resultStorage);
-                                        return;
-                                    default: {
-                                        throw new NotImplementedException(getIdentifier().getName()
-                                                + (i == 0 ? ": Left" : ": Right")
-                                                + " operand expects INT8/INT16/INT32/INT64/FLOAT/DOUBLE/NULL, but got "
-                                                + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
-                                    }
-                                }
-
-                                if (resultType < currentType) {
-                                    resultType = currentType;
-                                }
-                            }
-
-                            long lres = 0;
-                            double dres = 0;
-                            switch (resultType) {
-                                case typeInt8:
-                                    serde = AqlSerializerDeserializerProvider.INSTANCE
-                                            .getSerializerDeserializer(BuiltinType.AINT8);
-                                    lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
-                                    if (lres > Byte.MAX_VALUE) {
-                                        throw new AlgebricksException("Overflow happened.");
-                                    }
-                                    if (lres < Byte.MIN_VALUE) {
-                                        throw new AlgebricksException("Underflow happened.");
-                                    }
-                                    aInt8.setValue((byte) lres);
-                                    serde.serialize(aInt8, out);
+                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
+                        resultStorage.reset();
+                        resultType = 0;
+                        int currentType;
+                        evalLeft.evaluate(tuple, argPtr0);
+                        evalRight.evaluate(tuple, argPtr1);
+
+                        for (int i = 0; i < args.length; i++) {
+                            IPointable argPtr = i == 0 ? argPtr0 : argPtr1;
+                            byte[] bytes = argPtr.getByteArray();
+                            int offset = argPtr.getStartOffset();
+
+                            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
+                            switch (typeTag) {
+                                case INT8:
+                                    currentType = typeInt8;
+                                    operandsInteger[i] = AInt8SerializerDeserializer.getByte(bytes, offset + 1);
+                                    operandsFloating[i] = operandsInteger[i];
                                     break;
-                                case typeInt16:
-                                    serde = AqlSerializerDeserializerProvider.INSTANCE
-                                            .getSerializerDeserializer(BuiltinType.AINT16);
-                                    lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
-                                    if (lres > Short.MAX_VALUE) {
-                                        throw new AlgebricksException("Overflow happened.");
-                                    }
-                                    if (lres < Short.MIN_VALUE) {
-                                        throw new AlgebricksException("Underflow happened.");
-                                    }
-                                    aInt16.setValue((short) lres);
-                                    serde.serialize(aInt16, out);
+                                case INT16:
+                                    currentType = typeInt16;
+                                    operandsInteger[i] = AInt16SerializerDeserializer.getShort(bytes, offset + 1);
+                                    operandsFloating[i] = operandsInteger[i];
                                     break;
-                                case typeInt32:
-                                    serde = AqlSerializerDeserializerProvider.INSTANCE
-                                            .getSerializerDeserializer(BuiltinType.AINT32);
-                                    lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
-                                    if (lres > Integer.MAX_VALUE) {
-                                        throw new AlgebricksException("Overflow happened.");
-                                    }
-                                    if (lres < Integer.MIN_VALUE) {
-                                        throw new AlgebricksException("Underflow happened.");
-                                    }
-                                    aInt32.setValue((int) lres);
-                                    serde.serialize(aInt32, out);
+                                case INT32:
+                                    currentType = typeInt32;
+                                    operandsInteger[i] = AInt32SerializerDeserializer.getInt(bytes, offset + 1);
+                                    operandsFloating[i] = operandsInteger[i];
                                     break;
-                                case typeInt64:
-                                    serde = AqlSerializerDeserializerProvider.INSTANCE
-                                            .getSerializerDeserializer(BuiltinType.AINT64);
-                                    lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
-                                    aInt64.setValue(lres);
-                                    serde.serialize(aInt64, out);
+                                case INT64:
+                                    currentType = typeInt64;
+                                    operandsInteger[i] = AInt64SerializerDeserializer.getLong(bytes, offset + 1);
+                                    operandsFloating[i] = operandsInteger[i];
                                     break;
-                                case typeFloat:
-                                    serde = AqlSerializerDeserializerProvider.INSTANCE
-                                            .getSerializerDeserializer(BuiltinType.AFLOAT);
-                                    dres = evaluateDouble(operandsFloating[0], operandsFloating[1]);
-                                    if (dres > Float.MAX_VALUE) {
-                                        throw new AlgebricksException("Overflow happened.");
-                                    }
-                                    if (dres < -Float.MAX_VALUE) {
-                                        throw new AlgebricksException("Underflow happened.");
-                                    }
-                                    aFloat.setValue((float) dres);
-                                    serde.serialize(aFloat, out);
+                                case FLOAT:
+                                    currentType = typeFloat;
+                                    operandsFloating[i] = AFloatSerializerDeserializer.getFloat(bytes, offset + 1);
                                     break;
-                                case typeDouble:
-                                    serde = AqlSerializerDeserializerProvider.INSTANCE
-                                            .getSerializerDeserializer(BuiltinType.ADOUBLE);
-                                    aDouble.setValue(evaluateDouble(operandsFloating[0], operandsFloating[1]));
-                                    serde.serialize(aDouble, out);
+                                case DOUBLE:
+                                    currentType = typeDouble;
+                                    operandsFloating[i] = ADoubleSerializerDeserializer.getDouble(bytes, offset + 1);
                                     break;
+                                case DATE:
+                                case TIME:
+                                case DATETIME:
+                                case DURATION:
+                                case YEARMONTHDURATION:
+                                case DAYTIMEDURATION:
+                                    evaluateTemporalArthmeticOperation(typeTag);
+                                    result.set(resultStorage);
+                                    return;
+                                default:
+                                    throw new TypeMismatchException(getIdentifier(), i, bytes[offset],
+                                            ATypeTag.SERIALIZED_INT8_TYPE_TAG, ATypeTag.SERIALIZED_INT16_TYPE_TAG,
+                                            ATypeTag.SERIALIZED_INT32_TYPE_TAG, ATypeTag.SERIALIZED_INT64_TYPE_TAG,
+                                            ATypeTag.SERIALIZED_FLOAT_TYPE_TAG, ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG,
+                                            ATypeTag.SERIALIZED_DATE_TYPE_TAG, ATypeTag.SERIALIZED_TIME_TYPE_TAG,
+                                            ATypeTag.SERIALIZED_DATETIME_TYPE_TAG,
+                                            ATypeTag.SERIALIZED_DURATION_TYPE_TAG,
+                                            ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG,
+                                            ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG);
+                            }
+
+                            if (resultType < currentType) {
+                                resultType = currentType;
                             }
-                            result.set(resultStorage);
-                        } catch (HyracksDataException hde) {
-                            throw new AlgebricksException(hde);
                         }
+
+                        long lres;
+                        double dres;
+                        switch (resultType) {
+                            case typeInt8:
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT8);
+                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
+                                if (lres > Byte.MAX_VALUE) {
+                                    throw new OverflowException(getIdentifier());
+                                }
+                                if (lres < Byte.MIN_VALUE) {
+                                    throw new UnderflowException(getIdentifier());
+                                }
+                                aInt8.setValue((byte) lres);
+                                serde.serialize(aInt8, out);
+                                break;
+                            case typeInt16:
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT16);
+                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
+                                if (lres > Short.MAX_VALUE) {
+                                    throw new OverflowException(getIdentifier());
+                                }
+                                if (lres < Short.MIN_VALUE) {
+                                    throw new UnderflowException(getIdentifier());
+                                }
+                                aInt16.setValue((short) lres);
+                                serde.serialize(aInt16, out);
+                                break;
+                            case typeInt32:
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT32);
+                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
+                                if (lres > Integer.MAX_VALUE) {
+                                    throw new OverflowException(getIdentifier());
+                                }
+                                if (lres < Integer.MIN_VALUE) {
+                                    throw new UnderflowException(getIdentifier());
+                                }
+                                aInt32.setValue((int) lres);
+                                serde.serialize(aInt32, out);
+                                break;
+                            case typeInt64:
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AINT64);
+                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
+                                aInt64.setValue(lres);
+                                serde.serialize(aInt64, out);
+                                break;
+                            case typeFloat:
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.AFLOAT);
+                                dres = evaluateDouble(operandsFloating[0], operandsFloating[1]);
+                                if (dres > Float.MAX_VALUE) {
+                                    throw new OverflowException(getIdentifier());
+                                }
+                                if (dres < -Float.MAX_VALUE) {
+                                    throw new UnderflowException(getIdentifier());
+                                }
+                                aFloat.setValue((float) dres);
+                                serde.serialize(aFloat, out);
+                                break;
+                            case typeDouble:
+                                serde = AqlSerializerDeserializerProvider.INSTANCE
+                                        .getSerializerDeserializer(BuiltinType.ADOUBLE);
+                                aDouble.setValue(evaluateDouble(operandsFloating[0], operandsFloating[1]));
+                                serde.serialize(aDouble, out);
+                                break;
+                        }
+                        result.set(resultStorage);
                     }
 
                     @SuppressWarnings("unchecked")
                     private void evaluateTemporalArthmeticOperation(ATypeTag leftType)
-                            throws HyracksDataException, AlgebricksException {
+                            throws HyracksDataException {
                         byte[] bytes1 = argPtr1.getByteArray();
                         int offset1 = argPtr1.getStartOffset();
                         ATypeTag rightType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
@@ -327,7 +324,7 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
                                             offset1 + 1);
                                     break;
                                 default:
-                                    throw new NotImplementedException();
+                                    throw new UnsupportedTypeException(getIdentifier(), bytes1[offset1]);
                             }
 
                             dayTime = evaluateTimeInstanceArithmetic(leftChronon, rightChronon);
@@ -361,9 +358,8 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
                                                     offset1 + 1);
                                             break;
                                         default:
-                                            throw new NotImplementedException(getIdentifier().getName()
-                                                    + ": arithmetic operation between " + leftType + " and a "
-                                                    + rightType + " value is not supported.");
+                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
+                                                    bytes1[offset1]);
                                     }
                                     break;
                                 case DATE:
@@ -394,9 +390,8 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
                                                     offset1 + 1);
                                             break;
                                         default:
-                                            throw new NotImplementedException(getIdentifier().getName()
-                                                    + ": arithmetic operation between " + leftType + " and a "
-                                                    + rightType + " value is not supported.");
+                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
+                                                    bytes1[offset1]);
                                     }
                                     break;
                                 case YEARMONTHDURATION:
@@ -417,9 +412,8 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
                                                     * GregorianCalendarSystem.CHRONON_OF_DAY;
                                             break;
                                         default:
-                                            throw new NotImplementedException(getIdentifier().getName()
-                                                    + ": arithmetic operation between " + leftType + " and a "
-                                                    + rightType + " value is not supported.");
+                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
+                                                    bytes1[offset1]);
                                     }
                                     break;
                                 case DURATION:
@@ -454,22 +448,19 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
                                                 break;
                                             }
                                         default:
-                                            throw new NotImplementedException(getIdentifier().getName()
-                                                    + ": arithmetic operation between " + leftType + " and a "
-                                                    + rightType + " value is not supported.");
+                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
+                                                    bytes1[offset1]);
                                     }
                                     break;
                                 default:
-                                    throw new NotImplementedException(
-                                            getIdentifier().getName() + ": arithmetic operation between " + leftType
-                                                    + " and a " + rightType + " value is not supported.");
+                                    throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
+                                            bytes1[offset1]);
                             }
 
                             chronon = evaluateTimeDurationArithmetic(chronon, yearMonth, dayTime, isTimeOnly);
 
                             switch (resultType) {
                                 case DATE:
-
                                     if (chronon < 0 && chronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
                                         chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY - 1;
                                     } else {
@@ -487,10 +478,8 @@ public abstract class AbstractNumericArithmeticEval extends AbstractScalarFuncti
                                     serde.serialize(aDatetime, out);
                                     break;
                                 default:
-                                    throw new NotImplementedException(
-                                            getIdentifier().getName() + ": arithmetic operation between " + leftType
-                                                    + " and a " + rightType + " value is not supported.");
-
+                                    throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
+                                            bytes1[offset1]);
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
index 6eb6272..7814d90 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
@@ -27,15 +27,15 @@ import java.io.IOException;
 
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.AMutableString;
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
-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;
 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.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -69,7 +69,7 @@ public abstract class AbstractQuadStringStringEval implements IScalarEvaluator {
 
     public AbstractQuadStringStringEval(IHyracksTaskContext context, IScalarEvaluatorFactory eval0,
             IScalarEvaluatorFactory eval1, IScalarEvaluatorFactory eval2, IScalarEvaluatorFactory eval3,
-            FunctionIdentifier funcID) throws AlgebricksException {
+            FunctionIdentifier funcID) throws HyracksDataException {
         this.eval0 = eval0.createScalarEvaluator(context);
         this.eval1 = eval1.createScalarEvaluator(context);
         this.eval2 = eval2.createScalarEvaluator(context);
@@ -79,40 +79,53 @@ public abstract class AbstractQuadStringStringEval implements IScalarEvaluator {
 
     @SuppressWarnings("unchecked")
     @Override
-    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
         eval0.evaluate(tuple, array0);
         eval1.evaluate(tuple, array1);
         eval2.evaluate(tuple, array2);
         eval3.evaluate(tuple, array3);
 
+        byte[] bytes0 = array0.getByteArray();
+        byte[] bytes1 = array1.getByteArray();
+        byte[] bytes2 = array2.getByteArray();
+        byte[] bytes3 = array3.getByteArray();
+
+        int start0 = array0.getStartOffset();
+        int start1 = array1.getStartOffset();
+        int start2 = array2.getStartOffset();
+        int start3 = array3.getStartOffset();
+
+        int len0 = array0.getLength();
+        int len1 = array1.getLength();
+        int len2 = array2.getLength();
+        int len3 = array3.getLength();
+
         resultStorage.reset();
-        if (array0.getByteArray()[array0.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                || array1.getByteArray()[array1.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                || array2.getByteArray()[array2.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                || array3.getByteArray()[array3.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-            throw new AlgebricksException(funcID.getName()
-                    + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL, STRING/NULL), but got ("
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array0.getByteArray()[array0.getStartOffset()])
-                    + ", "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array1.getByteArray()[array1.getStartOffset()])
-                    + ", "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[array2.getStartOffset()])
-                    + ", "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array3.getByteArray()[array3.getStartOffset()])
-                    + ".");
+        // Type check.
+        if (bytes0[start0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 0, bytes0[start0], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+        }
+        if (bytes1[start1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 1, bytes1[start1], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+        }
+        if (bytes2[start2] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 2, bytes2[start2], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+        }
+        if (bytes3[start3] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 3, bytes1[start3], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
         }
 
-        strPtr1st.set(array0.getByteArray(), array0.getStartOffset() + 1, array0.getLength());
-        strPtr2nd.set(array1.getByteArray(), array1.getStartOffset() + 1, array1.getLength());
-        strPtr3rd.set(array2.getByteArray(), array2.getStartOffset() + 1, array2.getLength());
-        strPtr4th.set(array3.getByteArray(), array3.getStartOffset() + 1, array3.getLength());
+        strPtr1st.set(bytes0, start0 + 1, len0);
+        strPtr2nd.set(bytes1, start1 + 1, len1);
+        strPtr3rd.set(bytes2, start2 + 1, len2);
+        strPtr4th.set(bytes3, start3 + 1, len3);
 
         try {
             String res = compute(strPtr1st, strPtr2nd, strPtr3rd, strPtr4th);
             resultBuffer.setValue(res);
             strSerde.serialize(resultBuffer, dout);
         } catch (IOException e) {
-            throw new AlgebricksException(e);
+            throw new HyracksDataException(e);
         }
         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/AbstractTripleStringBoolEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java
index 50e7135..a9196d5 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java
@@ -23,11 +23,11 @@ import java.io.IOException;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.ABoolean;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 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.UTF8StringPointable;
 
@@ -39,7 +39,7 @@ public abstract class AbstractTripleStringBoolEval extends AbstractTripleStringE
 
     public AbstractTripleStringBoolEval(IHyracksTaskContext context, IScalarEvaluatorFactory eval0,
             IScalarEvaluatorFactory eval1, IScalarEvaluatorFactory eval2, FunctionIdentifier funcID)
-            throws AlgebricksException {
+            throws HyracksDataException {
         super(context, eval0, eval1, eval2, funcID);
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringEval.java
index e54ac3f..d4a9329 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringEval.java
@@ -22,13 +22,13 @@ package org.apache.asterix.runtime.evaluators.functions;
 import java.io.DataOutput;
 import java.io.IOException;
 
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-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;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -58,7 +58,7 @@ abstract class AbstractTripleStringEval implements IScalarEvaluator {
     private final FunctionIdentifier funcID;
 
     AbstractTripleStringEval(IHyracksTaskContext context, IScalarEvaluatorFactory eval0, IScalarEvaluatorFactory eval1,
-            IScalarEvaluatorFactory eval2, FunctionIdentifier funcID) throws AlgebricksException {
+            IScalarEvaluatorFactory eval2, FunctionIdentifier funcID) throws HyracksDataException {
         this.eval0 = eval0.createScalarEvaluator(context);
         this.eval1 = eval1.createScalarEvaluator(context);
         this.eval2 = eval2.createScalarEvaluator(context);
@@ -67,7 +67,7 @@ abstract class AbstractTripleStringEval implements IScalarEvaluator {
 
     @SuppressWarnings("unchecked")
     @Override
-    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
         // Gets the first argument.
         eval0.evaluate(tuple, argPtrFirst);
         byte[] bytes0 = argPtrFirst.getByteArray();
@@ -87,13 +87,15 @@ abstract class AbstractTripleStringEval implements IScalarEvaluator {
         int len2 = argPtrThird.getLength();
 
         // Type check.
-        if (bytes0[start0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                || bytes1[start1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
-                || bytes2[start2] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-            throw new AlgebricksException(funcID.getName() + ": expects iput type (STRING, STRING, STRING) but got ("
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[start0]) + ", "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[start1]) + ", "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes2[start2]) + ")");
+        // Type check.
+        if (bytes0[start0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 0, bytes0[start0], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+        }
+        if (bytes1[start1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 1, bytes1[start1], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
+        }
+        if (bytes2[start2] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+            throw new TypeMismatchException(funcID, 2, bytes2[start2], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
         }
 
         // Sets argument UTF8Pointables.
@@ -107,7 +109,7 @@ abstract class AbstractTripleStringEval implements IScalarEvaluator {
         try {
             process(strPtr1st, strPtr2nd, strPtr3rd, result);
         } catch (IOException e) {
-            throw new AlgebricksException(e);
+            throw new HyracksDataException(e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringIntEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringIntEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringIntEval.java
index 97c843a..c7dc9dc 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringIntEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringIntEval.java
@@ -24,11 +24,11 @@ import java.io.IOException;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.AMutableInt32;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 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.UTF8StringPointable;
 
@@ -41,15 +41,14 @@ public abstract class AbstractTripleStringIntEval extends AbstractTripleStringEv
 
     public AbstractTripleStringIntEval(IHyracksTaskContext context, IScalarEvaluatorFactory eval0,
             IScalarEvaluatorFactory eval1, IScalarEvaluatorFactory eval2, FunctionIdentifier funcID)
-            throws AlgebricksException {
+            throws HyracksDataException {
         super(context, eval0, eval1, eval2, funcID);
     }
 
     @SuppressWarnings("unchecked")
     @Override
     protected void process(UTF8StringPointable first, UTF8StringPointable second, UTF8StringPointable thrid,
-            IPointable result)
- throws IOException {
+            IPointable result) throws IOException {
         resultValue.setValue(compute(first, second, thrid));
         intSerde.serialize(resultValue, dout);
         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/AbstractTripleStringStringEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
index 6f6fdc4..f0a3678 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
@@ -23,7 +23,7 @@ import java.io.IOException;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.om.base.AMutableString;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -40,7 +40,7 @@ public abstract class AbstractTripleStringStringEval extends AbstractTripleStrin
 
     public AbstractTripleStringStringEval(IHyracksTaskContext context, IScalarEvaluatorFactory eval0,
             IScalarEvaluatorFactory eval1, IScalarEvaluatorFactory eval2, FunctionIdentifier funcID)
-            throws AlgebricksException {
+            throws HyracksDataException {
         super(context, eval0, eval1, eval2, funcID);
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java
index 28e54d1..241452a 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericDoubleFunctionEval.java
@@ -19,7 +19,7 @@
 
 package org.apache.asterix.runtime.evaluators.functions;
 
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -31,35 +31,35 @@ import org.apache.hyracks.data.std.api.IPointable;
 abstract class AbstractUnaryNumericDoubleFunctionEval extends AbstractUnaryNumericFunctionEval {
 
     public AbstractUnaryNumericDoubleFunctionEval(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory,
-            FunctionIdentifier funcID) throws AlgebricksException {
+            FunctionIdentifier funcID) throws HyracksDataException {
         super(context, argEvalFactory, funcID);
     }
 
     @Override
-    protected void processInt8(byte arg, IPointable resultPointable) throws AlgebricksException {
+    protected void processInt8(byte arg, IPointable resultPointable) throws HyracksDataException {
         processDouble(arg, resultPointable);
     }
 
     @Override
-    protected void processInt16(short arg, IPointable resultPointable) throws AlgebricksException {
+    protected void processInt16(short arg, IPointable resultPointable) throws HyracksDataException {
         processDouble(arg, resultPointable);
     }
 
     @Override
-    protected void processInt32(int arg, IPointable resultPointable) throws AlgebricksException {
+    protected void processInt32(int arg, IPointable resultPointable) throws HyracksDataException {
         processDouble(arg, resultPointable);
     }
 
     @Override
-    protected void processInt64(long arg, IPointable resultPointable) throws AlgebricksException {
+    protected void processInt64(long arg, IPointable resultPointable) throws HyracksDataException {
         processDouble(arg, resultPointable);
     }
 
     @Override
-    protected void processFloat(float arg, IPointable resultPointable) throws AlgebricksException {
+    protected void processFloat(float arg, IPointable resultPointable) throws HyracksDataException {
         processDouble(arg, resultPointable);
     }
 
     @Override
-    protected abstract void processDouble(double arg, IPointable resultPointable) throws AlgebricksException;
+    protected abstract void processDouble(double arg, IPointable resultPointable) throws HyracksDataException;
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java
index 50ff0de..24c2135 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryNumericFunctionEval.java
@@ -38,13 +38,13 @@ import org.apache.asterix.om.base.AMutableInt8;
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
-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;
 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;
@@ -94,14 +94,14 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
     private final FunctionIdentifier funcID;
 
     public AbstractUnaryNumericFunctionEval(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory,
-            FunctionIdentifier funcID) throws AlgebricksException {
+            FunctionIdentifier funcID) throws HyracksDataException {
         this.argEval = argEvalFactory.createScalarEvaluator(context);
         this.funcID = funcID;
     }
 
     @SuppressWarnings("unchecked")
     @Override
-    public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
         resultStorage.reset();
         argEval.evaluate(tuple, argPtr);
         byte[] data = argPtr.getByteArray();
@@ -126,8 +126,10 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
             double val = ADoubleSerializerDeserializer.getDouble(data, offset + 1);
             processDouble(val, result);
         } else {
-            throw new AlgebricksException(funcID + " expects a numeric input type, but gets "
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]));
+            throw new TypeMismatchException(funcID, 0, data[offset], ATypeTag.SERIALIZED_INT8_TYPE_TAG,
+                    ATypeTag.SERIALIZED_INT16_TYPE_TAG, ATypeTag.SERIALIZED_INT32_TYPE_TAG,
+                    ATypeTag.SERIALIZED_INT64_TYPE_TAG, ATypeTag.SERIALIZED_FLOAT_TYPE_TAG,
+                    ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG);
         }
     }
 
@@ -140,7 +142,7 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
      *            ,
      *            the pointable that should be set to the result location.
      */
-    protected abstract void processInt8(byte arg, IPointable resultPointable) throws AlgebricksException;
+    protected abstract void processInt8(byte arg, IPointable resultPointable) throws HyracksDataException;
 
     /**
      * Processes an int16 argument.
@@ -151,7 +153,7 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
      *            ,
      *            the pointable that should be set to the result location.
      */
-    protected abstract void processInt16(short arg, IPointable resultPointable) throws AlgebricksException;
+    protected abstract void processInt16(short arg, IPointable resultPointable) throws HyracksDataException;
 
     /**
      * Processes an int32 argument.
@@ -162,7 +164,7 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
      *            ,
      *            the pointable that should be set to the result location.
      */
-    protected abstract void processInt32(int arg, IPointable resultPointable) throws AlgebricksException;
+    protected abstract void processInt32(int arg, IPointable resultPointable) throws HyracksDataException;
 
     /**
      * Processes an int64 argument.
@@ -173,7 +175,7 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
      *            ,
      *            the pointable that should be set to the result location.
      */
-    protected abstract void processInt64(long arg, IPointable resultPointable) throws AlgebricksException;
+    protected abstract void processInt64(long arg, IPointable resultPointable) throws HyracksDataException;
 
     /**
      * Processes a float argument.
@@ -184,7 +186,7 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
      *            ,
      *            the pointable that should be set to the result location.
      */
-    protected abstract void processFloat(float arg, IPointable resultPointable) throws AlgebricksException;
+    protected abstract void processFloat(float arg, IPointable resultPointable) throws HyracksDataException;
 
     /**
      * Processes a double argument.
@@ -195,17 +197,17 @@ abstract class AbstractUnaryNumericFunctionEval implements IScalarEvaluator {
      *            ,
      *            the pointable that should be set to the result location.
      */
-    protected abstract void processDouble(double arg, IPointable resultPointable) throws AlgebricksException;
+    protected abstract void processDouble(double arg, IPointable resultPointable) throws HyracksDataException;
 
     // Serializes result into the result storage.
     @SuppressWarnings("unchecked")
     protected void serialize(IAObject result, ISerializerDeserializer serde, IPointable resultPointable)
-            throws AlgebricksException {
+            throws HyracksDataException {
         try {
             serde.serialize(result, dataOutput);
             resultPointable.set(resultStorage);
         } catch (IOException e) {
-            throw new AlgebricksException(e);
+            throw new HyracksDataException(e);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/52671a2c/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryStringStringEval.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryStringStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryStringStringEval.java
index 8e68143..1f9909c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryStringStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractUnaryStringStringEval.java
@@ -22,13 +22,13 @@ package org.apache.asterix.runtime.evaluators.functions;
 import java.io.DataOutput;
 import java.io.IOException;
 
+import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-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;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -52,22 +52,21 @@ abstract class AbstractUnaryStringStringEval implements IScalarEvaluator {
     private final FunctionIdentifier funcID;
 
     AbstractUnaryStringStringEval(IHyracksTaskContext context, IScalarEvaluatorFactory argEvalFactory,
-            FunctionIdentifier funcID) throws AlgebricksException {
+            FunctionIdentifier funcID) throws HyracksDataException {
         this.argEval = argEvalFactory.createScalarEvaluator(context);
         this.funcID = funcID;
     }
 
     @SuppressWarnings("unchecked")
     @Override
-    public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws AlgebricksException {
+    public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws HyracksDataException {
         resultStorage.reset();
         argEval.evaluate(tuple, argPtr);
         byte[] argBytes = argPtr.getByteArray();
         int offset = argPtr.getStartOffset();
         byte inputTypeTag = argBytes[offset];
         if (inputTypeTag != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
-            throw new AlgebricksException(funcID.getName() + ": expects input type to be STRING, but got ("
-                    + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(inputTypeTag) + ".");
+            throw new TypeMismatchException(funcID, 0, argBytes[offset], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
         }
         stringPtr.set(argBytes, offset + 1, argPtr.getLength() - 1);
         resultArray.reset();
@@ -75,7 +74,7 @@ abstract class AbstractUnaryStringStringEval implements IScalarEvaluator {
             process(stringPtr, resultPointable);
             writeResult(resultPointable);
         } catch (IOException e) {
-            throw new AlgebricksException(e);
+            throw new HyracksDataException(e);
         }
     }
 


Mime
View raw message