Repository: asterixdb
Updated Branches:
  refs/heads/master 407e56b79 -> 4547639bb


[ASTERIXDB-2416][FUN] Remove some internal function names from error messages

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Remove function names from type mismatch error messages
  raised by the following functions: field-access-by-index(),
  field-access-by-name(), field-access-nested(),
  any-collection-member(), scan-collection()

Change-Id: I625faf91a33f981964465cc60b77a27f4aecb6a8
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2785
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <ti...@apache.org>
Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/4547639b
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/4547639b
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/4547639b

Branch: refs/heads/master
Commit: 4547639bb4fd8aa098ea5402da445b1c5e36a991
Parents: 407e56b
Author: Dmitry Lychagin <dmitry.lycha...@couchbase.com>
Authored: Tue Jul 17 21:28:35 2018 -0700
Committer: Dmitry Lychagin <dmitry.lycha...@couchbase.com>
Committed: Wed Jul 18 22:24:58 2018 -0700

----------------------------------------------------------------------
 .../resources/runtimets/testsuite_sqlpp.xml     |  8 ++---
 .../asterix/common/exceptions/ErrorCode.java    |  6 ++--
 .../main/resources/asx_errormsg/en.properties   |  2 ++
 .../nontagged/BinaryBooleanInspector.java       |  2 +-
 .../om/exceptions/TypeMismatchException.java    | 27 +++++++++++-----
 .../impl/CollectionMemberResultType.java        |  3 +-
 .../impl/FieldAccessByIndexResultType.java      |  4 +--
 .../impl/FieldAccessByNameResultType.java       |  4 +--
 .../impl/FieldAccessNestedResultType.java       | 13 +++-----
 .../om/types/hierachy/ATypeHierarchy.java       |  6 ++--
 .../AnyCollectionMemberDescriptor.java          |  5 ++-
 .../records/FieldAccessByIndexEvalFactory.java  |  9 +++---
 .../records/FieldAccessByNameEvalFactory.java   |  5 ++-
 .../records/FieldAccessNestedEvalFactory.java   | 18 +++++------
 .../exceptions/TypeMismatchException.java       | 34 ++++++++++++++------
 .../std/ScanCollectionDescriptor.java           |  4 +--
 16 files changed, 85 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index a28d247..bc3b226 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -2911,13 +2911,13 @@
     <test-case FilePath="global-aggregate">
       <compilation-unit name="q05_error">
         <output-dir compare="Text">q01</output-dir>
-        <expected-error>Type mismatch: function field-access-by-name expects 
its 1st input parameter to be type object, but the actual input type is 
array</expected-error>
+        <expected-error>ASX1091: Type mismatch: expected value of type object, 
but got the value of type array (in line 22, at column 8)</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="global-aggregate">
       <compilation-unit name="q06_error">
         <output-dir compare="Text">q01</output-dir>
-        <expected-error>Type mismatch: function scan-collection expects its 
1st input parameter to be type array or multiset, but the actual input type is 
string</expected-error>
+        <expected-error>ASX0037: Type mismatch: expected value of type array 
or multiset, but got the value of type string (in line 22, at column 
8)</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="global-aggregate">
@@ -3014,7 +3014,7 @@
     <test-case FilePath="group-by">
       <compilation-unit name="sugar-01-negative">
         <output-dir compare="Text">core-01</output-dir>
-        <expected-error>Type mismatch: function field-access-by-name expects 
its 1st input parameter to be type object, but the actual input type is 
array</expected-error>
+        <expected-error>ASX1091: Type mismatch: expected value of type object, 
but got the value of type array (in line 26, at column 38)</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="group-by">
@@ -6814,7 +6814,7 @@
     <test-case FilePath="subquery">
       <compilation-unit name="query-ASTERIXDB-1574">
         <output-dir compare="Text">query-ASTERIXDB-1574</output-dir>
-        <expected-error>Type mismatch: function scan-collection expects its 
1st input parameter to be type multiset or array, but the actual input type is 
object</expected-error>
+        <expected-error>ASX1091: Type mismatch: expected value of type 
multiset or array, but got the value of type object (in line 25, at column 
41)</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="subquery">

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index de91d13..4358eac 100644
--- 
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ 
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -42,7 +42,7 @@ public class ErrorCode {
 
     // Runtime errors
     public static final int CASTING_FIELD = 1;
-    public static final int TYPE_MISMATCH = 2;
+    public static final int TYPE_MISMATCH_FUNCTION = 2;
     public static final int TYPE_INCOMPATIBLE = 3;
     public static final int TYPE_UNSUPPORTED = 4;
     public static final int TYPE_ITEM = 5;
@@ -77,6 +77,7 @@ public class ErrorCode {
     public static final int DIVISION_BY_ZERO = 34;
     public static final int UNSUPPORTED_MULTIPLE_STATEMENTS = 35;
     public static final int CANNOT_COMPARE_COMPLEX = 36;
+    public static final int TYPE_MISMATCH_GENERIC = 37;
 
     public static final int UNSUPPORTED_JRE = 100;
 
@@ -84,7 +85,7 @@ public class ErrorCode {
 
     // Compilation errors
     public static final int PARSE_ERROR = 1001;
-    public static final int COMPILATION_TYPE_MISMATCH = 1002;
+    public static final int COMPILATION_TYPE_MISMATCH_FUNCTION = 1002;
     public static final int COMPILATION_TYPE_INCOMPATIBLE = 1003;
     public static final int COMPILATION_TYPE_UNSUPPORTED = 1004;
     public static final int COMPILATION_TYPE_ITEM = 1005;
@@ -173,6 +174,7 @@ public class ErrorCode {
     public static final int FIELD_NOT_FOUND = 1088;
     public static final int FIELD_NOT_OF_TYPE = 1089;
     public static final int ARRAY_FIELD_ELEMENTS_MUST_BE_OF_TYPE = 1090;
+    public static final int COMPILATION_TYPE_MISMATCH_GENERIC = 1091;
 
     // Feed errors
     public static final int DATAFLOW_ILLEGAL_STATE = 3001;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties 
b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index b042972..5227e4b 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -38,6 +38,8 @@
 5,1005 = Invalid item type: function %1$s cannot process item type %2$s in an 
input array (or multiset)
 13,1006 = Duplicate field name \"%1$s\"
 1009 = A returning expression cannot contain dataset access
+37,1091 = Type mismatch: expected value of type %1$s, but got the value of 
type %2$s
+
 
 # Data errors
 6 = Invalid format for %1$s in %2$s

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryBooleanInspector.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryBooleanInspector.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryBooleanInspector.java
index 6b33408..1dfa05b 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryBooleanInspector.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/BinaryBooleanInspector.java
@@ -54,7 +54,7 @@ public class BinaryBooleanInspector implements 
IBinaryBooleanInspector {
         /** check if the runtime type is boolean */
         ATypeTag typeTag = 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serializedTypeTag);
         if (typeTag != ATypeTag.BOOLEAN) {
-            throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH, NAME, 0, 
ATypeTag.BOOLEAN, typeTag);
+            throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH_FUNCTION, 
NAME, 0, ATypeTag.BOOLEAN, typeTag);
         }
 
         return bytes[offset + 1] == 1;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
index 9dab8ac..14622aa 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/TypeMismatchException.java
@@ -30,30 +30,41 @@ import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class TypeMismatchException extends CompilationException {
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(FunctionIdentifier fid, Integer i, ATypeTag 
actualTypeTag,
             ATypeTag... expectedTypeTags) {
-        super(ErrorCode.COMPILATION_TYPE_MISMATCH, fid.getName(), 
indexToPosition(i),
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH_FUNCTION, fid.getName(), 
indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags), actualTypeTag);
     }
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(SourceLocation sourceLoc, FunctionIdentifier 
fid, Integer i, ATypeTag actualTypeTag,
             ATypeTag... expectedTypeTags) {
-        super(ErrorCode.COMPILATION_TYPE_MISMATCH, sourceLoc, fid.getName(), 
indexToPosition(i),
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH_FUNCTION, sourceLoc, 
fid.getName(), indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags), actualTypeTag);
     }
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(String functionName, Integer i, ATypeTag 
actualTypeTag, ATypeTag... expectedTypeTags) {
-        super(ErrorCode.COMPILATION_TYPE_MISMATCH, functionName, 
indexToPosition(i),
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH_FUNCTION, functionName, 
indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags), actualTypeTag);
     }
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(SourceLocation sourceLoc, String 
functionName, Integer i, ATypeTag actualTypeTag,
             ATypeTag... expectedTypeTags) {
-        super(ErrorCode.COMPILATION_TYPE_MISMATCH, sourceLoc, functionName, 
indexToPosition(i),
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH_FUNCTION, sourceLoc, 
functionName, indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags), actualTypeTag);
     }
+
+    // Generic type mismatch.
+    public TypeMismatchException(SourceLocation sourceLoc, ATypeTag 
actualTypeTag, ATypeTag... expectedTypeTags) {
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH_GENERIC, sourceLoc, 
toExpectedTypeString(expectedTypeTags),
+                actualTypeTag);
+    }
+
+    // Generic type mismatch.
+    public TypeMismatchException(SourceLocation sourceLoc, ATypeTag 
actualTypeTag, String expectedType) {
+        super(ErrorCode.COMPILATION_TYPE_MISMATCH_GENERIC, sourceLoc, 
expectedType, actualTypeTag);
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
index 9e88438..1db946d 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
@@ -39,8 +39,7 @@ public class CollectionMemberResultType extends 
AbstractResultTypeComputer {
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (type.getTypeTag() != ATypeTag.MULTISET && type.getTypeTag() != 
ATypeTag.ARRAY) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, 
actualTypeTag, ATypeTag.MULTISET,
-                    ATypeTag.ARRAY);
+            throw new TypeMismatchException(sourceLoc, actualTypeTag, 
ATypeTag.MULTISET, ATypeTag.ARRAY);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
index 71fa15c..cf40cbf 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
@@ -42,10 +42,10 @@ public class FieldAccessByIndexResultType extends 
AbstractResultTypeComputer {
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (argIndex == 0 && actualTypeTag != ATypeTag.OBJECT) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, 
actualTypeTag, ATypeTag.OBJECT);
+            throw new TypeMismatchException(sourceLoc, actualTypeTag, 
ATypeTag.OBJECT);
         }
         if (argIndex == 1 && actualTypeTag != ATypeTag.INTEGER) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, 
actualTypeTag, ATypeTag.INTEGER);
+            throw new TypeMismatchException(sourceLoc, actualTypeTag, 
ATypeTag.INTEGER);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
index 948f8d1..91cd887 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
@@ -42,10 +42,10 @@ public class FieldAccessByNameResultType extends 
AbstractResultTypeComputer {
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (argIndex == 0 && actualTypeTag != ATypeTag.OBJECT) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, 
actualTypeTag, ATypeTag.OBJECT);
+            throw new TypeMismatchException(sourceLoc, actualTypeTag, 
ATypeTag.OBJECT);
         }
         if (argIndex == 1 && actualTypeTag != ATypeTag.STRING) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, 
actualTypeTag, ATypeTag.STRING);
+            throw new TypeMismatchException(sourceLoc, actualTypeTag, 
ATypeTag.STRING);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
index 20f51ec..c80e1ab 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
@@ -26,7 +26,6 @@ import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.constants.AsterixConstantValue;
 import org.apache.asterix.om.exceptions.TypeMismatchException;
-import org.apache.asterix.om.exceptions.UnsupportedItemTypeException;
 import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
 import org.apache.asterix.om.types.AOrderedListType;
 import org.apache.asterix.om.types.ARecordType;
@@ -51,27 +50,26 @@ public class FieldAccessNestedResultType extends 
AbstractResultTypeComputer {
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (argIndex == 0 && actualTypeTag != ATypeTag.OBJECT) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, 
actualTypeTag, ATypeTag.OBJECT);
+            throw new TypeMismatchException(sourceLoc, actualTypeTag, 
ATypeTag.OBJECT);
         }
         if (argIndex == 1) {
             switch (actualTypeTag) {
                 case STRING:
                     break;
                 case ARRAY:
-                    checkOrderedList(funcName, type, sourceLoc);
+                    checkOrderedList(type, sourceLoc);
                     break;
                 default:
-                    throw new TypeMismatchException(sourceLoc, funcName, 
argIndex, actualTypeTag, ATypeTag.STRING,
-                            ATypeTag.ARRAY);
+                    throw new TypeMismatchException(sourceLoc, actualTypeTag, 
ATypeTag.STRING, ATypeTag.ARRAY);
             }
         }
     }
 
-    private void checkOrderedList(String funcName, IAType type, SourceLocation 
sourceLoc) throws AlgebricksException {
+    private void checkOrderedList(IAType type, SourceLocation sourceLoc) 
throws AlgebricksException {
         AOrderedListType listType = (AOrderedListType) type;
         ATypeTag itemTypeTag = listType.getItemType().getTypeTag();
         if (itemTypeTag != ATypeTag.STRING && itemTypeTag != ATypeTag.ANY) {
-            throw new UnsupportedItemTypeException(sourceLoc, funcName, 
itemTypeTag);
+            throw new TypeMismatchException(sourceLoc, itemTypeTag, 
ATypeTag.STRING, ATypeTag.ANY);
         }
     }
 
@@ -100,5 +98,4 @@ public class FieldAccessNestedResultType extends 
AbstractResultTypeComputer {
         IAType fieldType = recType.getSubFieldType(fieldPath);
         return fieldType == null ? BuiltinType.ANY : fieldType;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
index 67514a3..f182370 100644
--- 
a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
+++ 
b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java
@@ -315,7 +315,7 @@ public class ATypeHierarchy {
             case DOUBLE:
                 return 
DoubleToInt32TypeConvertComputer.getInstance(strictDemote).convertType(bytes, 
offset);
             default:
-                throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH, name, 
argIndex,
+                throw new 
RuntimeDataException(ErrorCode.TYPE_MISMATCH_FUNCTION, name, argIndex,
                         Arrays.toString(new Object[] { ATypeTag.TINYINT, 
ATypeTag.SMALLINT, ATypeTag.INTEGER,
                                 ATypeTag.BIGINT, ATypeTag.FLOAT, 
ATypeTag.DOUBLE }),
                         sourceTypeTag);
@@ -354,7 +354,7 @@ public class ATypeHierarchy {
             case DOUBLE:
                 return 
DoubleToInt64TypeConvertComputer.getInstance(strictDemote).convertType(bytes, 
offset);
             default:
-                throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH, name, 
argIndex,
+                throw new 
RuntimeDataException(ErrorCode.TYPE_MISMATCH_FUNCTION, name, argIndex,
                         Arrays.toString(new Object[] { ATypeTag.TINYINT, 
ATypeTag.SMALLINT, ATypeTag.INTEGER,
                                 ATypeTag.BIGINT, ATypeTag.FLOAT, 
ATypeTag.DOUBLE }),
                         sourceTypeTag);
@@ -385,7 +385,7 @@ public class ATypeHierarchy {
             case BIGINT:
                 return 
IntegerToDoubleTypeConvertComputer.getInstance().convertType(bytes, offset, 
sourceTypeTag);
             default:
-                throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH, name, 
argIndex,
+                throw new 
RuntimeDataException(ErrorCode.TYPE_MISMATCH_FUNCTION, name, argIndex,
                         Arrays.toString(new ATypeTag[] { ATypeTag.TINYINT, 
ATypeTag.SMALLINT, ATypeTag.INTEGER,
                                 ATypeTag.BIGINT, ATypeTag.FLOAT, 
ATypeTag.DOUBLE }),
                         sourceTypeTag);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
index 1833fcc..b03dafa 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
@@ -95,9 +95,8 @@ public class AnyCollectionMemberDescriptor extends 
AbstractScalarFunctionDynamic
 
                     if (serList[offset] != 
ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
                             && serList[offset] != 
ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
-                        throw new TypeMismatchException(sourceLoc, 
BuiltinFunctions.ANY_COLLECTION_MEMBER, 0,
-                                serList[offset], 
ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG,
-                                ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG);
+                        throw new TypeMismatchException(sourceLoc, 
serList[offset],
+                                ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG, 
ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG);
                     }
 
                     try {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
index 3454c2e..3fcf87d 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
@@ -22,7 +22,6 @@ import java.io.DataOutput;
 import java.io.IOException;
 
 import 
org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AUnionType;
@@ -92,15 +91,15 @@ public class FieldAccessByIndexEvalFactory implements 
IScalarEvaluatorFactory {
                     int offset = inputArg0.getStartOffset();
 
                     if (serRecord[offset] != 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
-                        throw new TypeMismatchException(sourceLoc, 
BuiltinFunctions.FIELD_ACCESS_BY_INDEX, 0,
-                                serRecord[offset], 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
+                        throw new TypeMismatchException(sourceLoc, 
serRecord[offset],
+                                ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
                     }
                     eval1.evaluate(tuple, inputArg1);
                     byte[] indexBytes = inputArg1.getByteArray();
                     int indexOffset = inputArg1.getStartOffset();
                     if (indexBytes[indexOffset] != 
ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
-                        throw new TypeMismatchException(sourceLoc, 
BuiltinFunctions.FIELD_ACCESS_BY_INDEX, 1,
-                                indexBytes[offset], 
ATypeTag.SERIALIZED_INT32_TYPE_TAG);
+                        throw new TypeMismatchException(sourceLoc, 
indexBytes[offset],
+                                ATypeTag.SERIALIZED_INT32_TYPE_TAG);
                     }
                     fieldIndex = IntegerPointable.getInteger(indexBytes, 
indexOffset + 1);
                     fieldValueType = recordType.getFieldTypes()[fieldIndex];

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
index 774b427..3deef73 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
@@ -22,7 +22,6 @@ import java.io.DataOutput;
 import java.io.IOException;
 
 import 
org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.EnumDeserializer;
 import org.apache.asterix.om.utils.NonTaggedFormatUtil;
@@ -78,8 +77,8 @@ public class FieldAccessByNameEvalFactory implements 
IScalarEvaluatorFactory {
                     int serRecordLen = inputArg0.getLength();
 
                     if (serRecord[serRecordOffset] != 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
-                        throw new TypeMismatchException(sourceLoc, 
BuiltinFunctions.FIELD_ACCESS_BY_NAME, 0,
-                                serRecord[serRecordOffset], 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
+                        throw new TypeMismatchException(sourceLoc, 
serRecord[serRecordOffset],
+                                ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
                     }
                     byte[] serFldName = inputArg1.getByteArray();
                     int serFldNameOffset = inputArg1.getStartOffset();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
index 8fee257..632a698 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
@@ -27,7 +27,6 @@ import 
org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
 import org.apache.asterix.om.base.AMissing;
 import org.apache.asterix.om.base.ANull;
 import org.apache.asterix.om.base.AString;
-import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.AUnionType;
@@ -38,7 +37,6 @@ import 
org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
 import org.apache.asterix.om.utils.NonTaggedFormatUtil;
 import org.apache.asterix.om.utils.RecordUtil;
 import org.apache.asterix.runtime.exceptions.TypeMismatchException;
-import org.apache.asterix.runtime.exceptions.UnsupportedTypeException;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -118,8 +116,8 @@ public class FieldAccessNestedEvalFactory implements 
IScalarEvaluatorFactory {
                     int len = inputArg0.getLength();
 
                     if (serRecord[start] != 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
-                        throw new TypeMismatchException(sourceLoc, 
BuiltinFunctions.FIELD_ACCESS_NESTED, 0,
-                                serRecord[start], 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
+                        throw new TypeMismatchException(sourceLoc, 
serRecord[start],
+                                ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
                     }
 
                     int subFieldIndex = -1;
@@ -141,8 +139,8 @@ public class FieldAccessNestedEvalFactory implements 
IScalarEvaluatorFactory {
                             subType = ((AUnionType) subType).getActualType();
                             byte serializedTypeTag = 
subType.getTypeTag().serialize();
                             if (serializedTypeTag != 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
-                                throw new UnsupportedTypeException(sourceLoc,
-                                        
BuiltinFunctions.FIELD_ACCESS_NESTED.getName(), serializedTypeTag);
+                                throw new TypeMismatchException(sourceLoc, 
serializedTypeTag,
+                                        ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
                             }
                             if (subType.getTypeTag() == ATypeTag.OBJECT) {
                                 recTypeInfos[pathIndex].reset((ARecordType) 
subType);
@@ -197,8 +195,8 @@ public class FieldAccessNestedEvalFactory implements 
IScalarEvaluatorFactory {
                         // type check
                         if (pathIndex < fieldPointables.length - 1
                                 && serRecord[start] != 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
-                            throw new UnsupportedTypeException(sourceLoc, 
BuiltinFunctions.FIELD_ACCESS_NESTED,
-                                    serRecord[start]);
+                            throw new TypeMismatchException(sourceLoc, 
serRecord[start],
+                                    ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
                         }
                     }
 
@@ -232,8 +230,8 @@ public class FieldAccessNestedEvalFactory implements 
IScalarEvaluatorFactory {
                             return;
                         }
                         if (serRecord[start] != 
ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
-                            throw new UnsupportedTypeException(sourceLoc,
-                                    
BuiltinFunctions.FIELD_ACCESS_NESTED.getName(), serRecord[start]);
+                            throw new TypeMismatchException(sourceLoc, 
serRecord[start],
+                                    ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
                         }
                     }
                     // emit the final result.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
index 6c80b67..36f6813 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/exceptions/TypeMismatchException.java
@@ -30,38 +30,52 @@ import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class TypeMismatchException extends RuntimeDataException {
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(FunctionIdentifier fid, Integer i, byte 
actualTypeTag, byte... expectedTypeTags) {
-        super(ErrorCode.TYPE_MISMATCH, fid.getName(), indexToPosition(i), 
toExpectedTypeString(expectedTypeTags),
+        super(ErrorCode.TYPE_MISMATCH_FUNCTION, fid.getName(), 
indexToPosition(i),
+                toExpectedTypeString(expectedTypeTags),
                 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(SourceLocation sourceLoc, FunctionIdentifier 
fid, Integer i, byte actualTypeTag,
             byte... expectedTypeTags) {
-        super(ErrorCode.TYPE_MISMATCH, sourceLoc, fid.getName(), 
indexToPosition(i),
+        super(ErrorCode.TYPE_MISMATCH_FUNCTION, sourceLoc, fid.getName(), 
indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags),
                 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(String functionName, Integer i, byte 
actualTypeTag, byte... expectedTypeTags) {
-        super(ErrorCode.TYPE_MISMATCH, functionName, indexToPosition(i), 
toExpectedTypeString(expectedTypeTags),
+        super(ErrorCode.TYPE_MISMATCH_FUNCTION, functionName, 
indexToPosition(i),
+                toExpectedTypeString(expectedTypeTags),
                 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(SourceLocation sourceLoc, String 
functionName, Integer i, byte actualTypeTag,
             byte... expectedTypeTags) {
-        super(ErrorCode.TYPE_MISMATCH, sourceLoc, functionName, 
indexToPosition(i),
+        super(ErrorCode.TYPE_MISMATCH_FUNCTION, sourceLoc, functionName, 
indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags),
                 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
-    // Parameter type mistmatch.
+    // Function parameter type mismatch.
     public TypeMismatchException(SourceLocation sourceLoc, FunctionIdentifier 
fid, Integer i, byte actualTypeTag,
             String expectedType) {
-        super(ErrorCode.TYPE_MISMATCH, sourceLoc, fid.getName(), 
indexToPosition(i), expectedType,
+        super(ErrorCode.TYPE_MISMATCH_FUNCTION, sourceLoc, fid.getName(), 
indexToPosition(i), expectedType,
+                
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
+    }
+
+    // Generic type mismatch.
+    public TypeMismatchException(SourceLocation sourceLoc, byte actualTypeTag, 
byte... expectedTypeTags) {
+        super(ErrorCode.TYPE_MISMATCH_GENERIC, sourceLoc, 
toExpectedTypeString(expectedTypeTags),
+                
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
+    }
+
+    // Generic type mismatch.
+    public TypeMismatchException(SourceLocation sourceLoc, byte actualTypeTag, 
String expectedType) {
+        super(ErrorCode.TYPE_MISMATCH_GENERIC, sourceLoc, expectedType,
                 
EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4547639b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
index eaf0d9c..a1a4e42 100644
--- 
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
+++ 
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
@@ -94,8 +94,8 @@ public class ScanCollectionDescriptor extends 
AbstractUnnestingFunctionDynamicDe
                     }
                     if (typeTag != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
                             && typeTag != 
ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
-                        throw new TypeMismatchException(sourceLoc, 
BuiltinFunctions.SCAN_COLLECTION, 0, typeTag,
-                                ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG, 
ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG);
+                        throw new TypeMismatchException(sourceLoc, typeTag, 
ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG,
+                                ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG);
                     }
                     listAccessor.reset(inputVal.getByteArray(), 
inputVal.getStartOffset());
                     itemIndex = 0;

Reply via email to