[NO ISSUE][FUN] Cleanup function name reporting in error messages

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

Details:
- Pass function identifier to exception constructors, so function name
  can be extracted by the constructor code
- Deprecate exception constructors that expect function name directly

Change-Id: If40e115db5482b255595e1a651b99c5d7b53712a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3273
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FullTextContainsParameterCheckRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FullTextContainsParameterCheckRule.java
index 73da2b4..c565b34 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FullTextContainsParameterCheckRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FullTextContainsParameterCheckRule.java
@@ -145,7 +145,7 @@
                 // The number of parameters should be three: exp1, exp2, and the option
                 if (oldExprs.size() != numberOfCorrectArguments) {
                     throw CompilationException.create(ErrorCode.COMPILATION_INVALID_PARAMETER_NUMBER,
-                            funcExpr.getSourceLocation(), fi, oldExprs.size());
+                            funcExpr.getSourceLocation(), fi.getName(), oldExprs.size());
                 }
 
                 // The last expression before the option needs to be copied first.
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
index ca43084..b7e9701 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
@@ -845,8 +845,7 @@
         AbstractFunctionCallExpression f = lookupFunction(signature, args, sourceLoc);
 
         if (f == null) {
-            throw new CompilationException(ErrorCode.UNKNOWN_FUNCTION, sourceLoc,
-                    signature.getName() + "@" + signature.getArity());
+            throw new CompilationException(ErrorCode.UNKNOWN_FUNCTION, sourceLoc, signature.getName());
         }
 
         // Put hints into function call expr.
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
index e5a1c1a..5324a0d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/async-deferred/AsyncDeferredQueries.xml
@@ -20,7 +20,7 @@
     <test-case FilePath="async-deferred">
         <compilation-unit name="async-failed">
             <output-dir compare="Text">async-failed</output-dir>
-            <expected-error>Injected failure in asterix:inject-failure</expected-error>
+            <expected-error>Injected failure in inject-failure</expected-error>
         </compilation-unit>
     </test-case>
     <test-case FilePath="async-deferred">
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 313ed78..49cb57a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4118,31 +4118,31 @@
     <test-case FilePath="failure">
       <compilation-unit name="group_by_failure">
         <output-dir compare="Text">group_by_failure</output-dir>
-        <expected-error>Injected failure in asterix:inject-failure</expected-error>
+        <expected-error>Injected failure in inject-failure</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="failure">
       <compilation-unit name="group_by_hash_failure">
         <output-dir compare="Text">group_by_hash_failure</output-dir>
-        <expected-error>Injected failure in asterix:inject-failure</expected-error>
+        <expected-error>Injected failure in inject-failure</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="failure">
       <compilation-unit name="q01_pricing_summary_report_failure">
         <output-dir compare="Text">q01_pricing_summary_report_failure</output-dir>
-        <expected-error>Injected failure in asterix:inject-failure</expected-error>
+        <expected-error>Injected failure in inject-failure</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="failure">
       <compilation-unit name="q18_large_volume_customer_failure">
         <output-dir compare="Text">q18_large_volume_customer_failure</output-dir>
-        <expected-error>Injected failure in asterix:inject-failure</expected-error>
+        <expected-error>Injected failure in inject-failure</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="failure">
       <compilation-unit name="order_by_failure">
         <output-dir compare="Text">order_by_failure</output-dir>
-        <expected-error>Injected failure in asterix:inject-failure</expected-error>
+        <expected-error>Injected failure in inject-failure</expected-error>
       </compilation-unit>
     </test-case>
   </test-group>
@@ -8301,7 +8301,7 @@
     <test-case FilePath="string">
       <compilation-unit name="repeat_error">
         <output-dir compare="Text">repeat</output-dir>
-        <expected-error>Invalid value: function asterix:repeat expects its 1 input parameter to be a non-negative value, but gets -1</expected-error>
+        <expected-error>Invalid value: function repeat expects its 1 input parameter to be a non-negative value, but gets -1</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="string">
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java
index 3035bd5..4ae729e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/IncompatibleTypeException.java
@@ -40,11 +40,13 @@
     }
 
     // Incompatible input parameters, e.g., "1.0" > 1.0
+    @Deprecated
     public IncompatibleTypeException(String functionName, ATypeTag typeTagLeft, ATypeTag typeTagRight) {
         super(ErrorCode.COMPILATION_TYPE_INCOMPATIBLE, functionName, typeTagLeft, typeTagRight);
     }
 
     // Incompatible input parameters, e.g., "1.0" > 1.0
+    @Deprecated
     public IncompatibleTypeException(SourceLocation sourceLoc, String functionName, ATypeTag typeTagLeft,
             ATypeTag typeTagRight) {
         super(ErrorCode.COMPILATION_TYPE_INCOMPATIBLE, sourceLoc, functionName, typeTagLeft, typeTagRight);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java
index c3c8fd2..7eb7e8b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/InvalidExpressionException.java
@@ -44,12 +44,14 @@
                 actualExpr.toString(), toExpectedTypeString(exprKinds));
     }
 
+    @Deprecated
     public InvalidExpressionException(String functionName, int index, ILogicalExpression actualExpr,
             LogicalExpressionTag... exprKinds) {
         super(ErrorCode.COMPILATION_INVALID_EXPRESSION, functionName, indexToPosition(index), actualExpr.toString(),
                 toExpectedTypeString(exprKinds));
     }
 
+    @Deprecated
     public InvalidExpressionException(SourceLocation sourceLoc, String functionName, int index,
             ILogicalExpression actualExpr, LogicalExpressionTag... exprKinds) {
         super(ErrorCode.COMPILATION_INVALID_EXPRESSION, sourceLoc, functionName, indexToPosition(index),
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 bcf8b84..e155b94 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
@@ -46,12 +46,14 @@
     }
 
     // Function parameter type mismatch.
+    @Deprecated
     public TypeMismatchException(String functionName, Integer i, ATypeTag actualTypeTag, ATypeTag... expectedTypeTags) {
         super(ErrorCode.COMPILATION_TYPE_MISMATCH_FUNCTION, functionName, indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags), actualTypeTag);
     }
 
     // Function parameter type mismatch.
+    @Deprecated
     public TypeMismatchException(SourceLocation sourceLoc, String functionName, Integer i, ATypeTag actualTypeTag,
             ATypeTag... expectedTypeTags) {
         super(ErrorCode.COMPILATION_TYPE_MISMATCH_FUNCTION, sourceLoc, functionName, indexToPosition(i),
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java
index d0f0bf2..06e3c9a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedItemTypeException.java
@@ -39,11 +39,13 @@
     }
 
     // Unsupported item type.
+    @Deprecated
     public UnsupportedItemTypeException(String functionName, ATypeTag itemTypeTag) {
         super(ErrorCode.COMPILATION_TYPE_ITEM, functionName, itemTypeTag);
     }
 
     // Unsupported item type.
+    @Deprecated
     public UnsupportedItemTypeException(SourceLocation sourceLoc, String functionName, ATypeTag itemTypeTag) {
         super(ErrorCode.COMPILATION_TYPE_ITEM, sourceLoc, functionName, itemTypeTag);
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java
index c4a8372..d89ebfd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/exceptions/UnsupportedTypeException.java
@@ -39,11 +39,13 @@
     }
 
     // Unsupported input type.
+    @Deprecated
     public UnsupportedTypeException(String funcName, ATypeTag actualTypeTag) {
         super(ErrorCode.COMPILATION_TYPE_UNSUPPORTED, funcName, actualTypeTag);
     }
 
     // Unsupported input type.
+    @Deprecated
     public UnsupportedTypeException(SourceLocation sourceLoc, String funcName, ATypeTag actualTypeTag) {
         super(ErrorCode.COMPILATION_TYPE_UNSUPPORTED, sourceLoc, funcName, actualTypeTag);
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/AbstractResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/AbstractResultTypeComputer.java
index 60a4985..c006936 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/AbstractResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/AbstractResultTypeComputer.java
@@ -24,6 +24,7 @@
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
@@ -39,9 +40,9 @@
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         AbstractFunctionCallExpression functionCallExpression = (AbstractFunctionCallExpression) expression;
-        String funcName = functionCallExpression.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = functionCallExpression.getFunctionIdentifier();
         return TypeComputeUtils.resolveResultType(expression, env,
-                (index, type, sourceLoc) -> checkArgType(funcName, index, type, sourceLoc), this::getResultType,
+                (index, type, sourceLoc) -> checkArgType(funcId, index, type, sourceLoc), this::getResultType,
                 propagateNullAndMissing());
     }
 
@@ -52,13 +53,13 @@
      *            the index of the argument to consider.
      * @param type,
      *            the type of the input argument.
-     * @param funcName
-     *            the function name.
+     * @param funcId
+     *            the function identifier.
      * @param sourceLoc
      *            the source location
      * @throws AlgebricksException
      */
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeCastUtils.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeCastUtils.java
index 8aad9d7..f61518c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeCastUtils.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeCastUtils.java
@@ -26,6 +26,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 
 public class TypeCastUtils {
 
@@ -43,8 +44,8 @@
             ATypeTag requiredTypeTag = requiredType.getTypeTag();
             ATypeTag actualTypeTag = TypeComputeUtils.getActualType(inputType).getTypeTag();
             if (!ATypeHierarchy.isCompatible(requiredTypeTag, actualTypeTag)) {
-                String funcName = expr.getFunctionIdentifier().getName();
-                throw new IncompatibleTypeException(expr.getSourceLocation(), funcName, actualTypeTag, requiredTypeTag);
+                FunctionIdentifier funcId = expr.getFunctionIdentifier();
+                throw new IncompatibleTypeException(expr.getSourceLocation(), funcId, actualTypeTag, requiredTypeTag);
             }
             expr.setOpaqueParameters(opaqueParameters);
             changed = true;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
index 08d2ca5..b24fab5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
@@ -24,16 +24,17 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 abstract public class AbstractStringTypeComputer extends AbstractResultTypeComputer {
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (actualTypeTag != ATypeTag.STRING) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, actualTypeTag, ATypeTag.STRING);
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, actualTypeTag, ATypeTag.STRING);
         }
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
index c6c744c..eefb4cb 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
@@ -26,6 +26,7 @@
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 
 public class BooleanFunctionTypeComputer extends AbstractResultTypeComputer {
@@ -39,10 +40,10 @@
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         AbstractFunctionCallExpression functionCallExpression = (AbstractFunctionCallExpression) expression;
-        String funcName = functionCallExpression.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = functionCallExpression.getFunctionIdentifier();
         // Boolean type computer doesn't follow the null/missing-in/out semantics.
         return TypeComputeUtils.resolveResultType(expression, env,
-                (index, type, sourceLoc) -> checkArgType(funcName, index, type, sourceLoc), this::getResultType, false);
+                (index, type, sourceLoc) -> checkArgType(funcId, index, type, sourceLoc), this::getResultType, false);
     }
 
     @Override
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
index 3500435..077e9b3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
@@ -47,7 +47,6 @@
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-        String funcName = f.getFunctionIdentifier().getName();
 
         /**
          * if type has been top-down propagated, use the enforced type
@@ -72,7 +71,7 @@
             }
             String fieldName = ConstantExpressionUtil.getStringConstant(e1);
             if (fieldName == null) {
-                throw new InvalidExpressionException(f.getSourceLocation(), funcName, 2 * i, e1,
+                throw new InvalidExpressionException(f.getSourceLocation(), f.getFunctionIdentifier(), 2 * i, e1,
                         LogicalExpressionTag.CONSTANT);
             }
             for (int j = 0; j < i; j++) {
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 26bc116..1d20775 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
@@ -27,6 +27,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class CollectionMemberResultType extends AbstractResultTypeComputer {
@@ -46,7 +47,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (type.getTypeTag() != ATypeTag.MULTISET && type.getTypeTag() != ATypeTag.ARRAY) {
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 cf40cbf..6c51d9d 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
@@ -28,6 +28,7 @@
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class FieldAccessByIndexResultType extends AbstractResultTypeComputer {
@@ -38,7 +39,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (argIndex == 0 && actualTypeTag != ATypeTag.OBJECT) {
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 91cd887..c5373bc 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
@@ -28,6 +28,7 @@
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class FieldAccessByNameResultType extends AbstractResultTypeComputer {
@@ -38,7 +39,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (argIndex == 0 && actualTypeTag != ATypeTag.OBJECT) {
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 c80e1ab..2f3965d 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
@@ -37,6 +37,7 @@
 import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class FieldAccessNestedResultType extends AbstractResultTypeComputer {
@@ -46,7 +47,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (argIndex == 0 && actualTypeTag != ATypeTag.OBJECT) {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FullTextContainsResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FullTextContainsResultTypeComputer.java
index 606a68e..9b71d9f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FullTextContainsResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FullTextContainsResultTypeComputer.java
@@ -25,6 +25,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class FullTextContainsResultTypeComputer extends AbstractResultTypeComputer {
@@ -35,17 +36,17 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         // Expression1 should be a string.
         if (argIndex == 0 && actualTypeTag != ATypeTag.STRING && actualTypeTag != ATypeTag.ANY) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, actualTypeTag, ATypeTag.STRING);
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, actualTypeTag, ATypeTag.STRING);
         }
         // Expression2 should be a string, or an (un)ordered list.
         if (argIndex == 1 && (actualTypeTag != ATypeTag.STRING && actualTypeTag != ATypeTag.MULTISET
                 && actualTypeTag != ATypeTag.ARRAY && actualTypeTag != ATypeTag.ANY)) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, actualTypeTag, ATypeTag.STRING,
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, actualTypeTag, ATypeTag.STRING,
                     ATypeTag.MULTISET, ATypeTag.ARRAY);
         }
         // Each option name should be a string if it is already processed by FullTextContainsParameterCheckRule.
@@ -53,7 +54,7 @@
         // The structure is: arg2 = optionName1, arg3 = optionValue1, arg4 = optionName1, arg5 = optionValue2, ...
         if (argIndex > 1 && argIndex % 2 == 0 && (actualTypeTag != ATypeTag.STRING && actualTypeTag != ATypeTag.OBJECT
                 && actualTypeTag != ATypeTag.ANY)) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, actualTypeTag, ATypeTag.STRING,
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, actualTypeTag, ATypeTag.STRING,
                     ATypeTag.OBJECT);
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
index 51fd6fc..7a59485 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
@@ -24,13 +24,14 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 /**
  * The first argument of INJECT_FAILURE can be any data model instance and will be passed verbatim to the
  * caller. The second argument is a boolean that determines if the invocation throws an exception.
  *
- * Consequently {@link AbstractResultTypeComputer#checkArgType(String, int, IAType, SourceLocation)} validates that the second argument is a
+ * Consequently {@link AbstractResultTypeComputer#checkArgType(FunctionIdentifier, int, IAType, SourceLocation)} validates that the second argument is a
  * boolean and {@link #getResultType(ILogicalExpression, IAType...)} returns the type of the first
  * argument.
  */
@@ -39,10 +40,10 @@
     public static final InjectFailureTypeComputer INSTANCE = new InjectFailureTypeComputer();
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         if (argIndex == 1 && type.getTypeTag() != ATypeTag.BOOLEAN) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, type.getTypeTag(), ATypeTag.BOOLEAN);
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, type.getTypeTag(), ATypeTag.BOOLEAN);
         }
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
index abdff7e..596ef67 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
@@ -25,6 +25,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class MinMaxAggTypeComputer extends AbstractResultTypeComputer {
@@ -35,7 +36,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         switch (tag) {
@@ -54,7 +55,7 @@
             case ANY:
                 return;
             default:
-                throw new UnsupportedTypeException(sourceLoc, funcName, tag);
+                throw new UnsupportedTypeException(sourceLoc, funcId, tag);
         }
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
index e896ae7..633feeb 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
@@ -28,6 +28,7 @@
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class NonTaggedGetItemResultType extends AbstractResultTypeComputer {
@@ -38,17 +39,17 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag actualTypeTag = type.getTypeTag();
         if (argIndex == 0) {
             if (type.getTypeTag() != ATypeTag.MULTISET && type.getTypeTag() != ATypeTag.ARRAY) {
-                throw new TypeMismatchException(sourceLoc, funcName, argIndex, actualTypeTag, ATypeTag.STRING,
+                throw new TypeMismatchException(sourceLoc, funcId, argIndex, actualTypeTag, ATypeTag.STRING,
                         ATypeTag.ARRAY);
             }
         } else {
             if (!ATypeHierarchy.isCompatible(type.getTypeTag(), ATypeTag.INTEGER)) {
-                throw new TypeMismatchException(sourceLoc, funcName, argIndex, actualTypeTag, ATypeTag.INTEGER);
+                throw new TypeMismatchException(sourceLoc, funcId, argIndex, actualTypeTag, ATypeTag.INTEGER);
             }
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
index 41a60c6..81cf905 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
@@ -27,6 +27,7 @@
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 
 public class NumericAddSubMulDivTypeComputer extends AbstractResultTypeComputer {
     /**
@@ -48,7 +49,7 @@
     @Override
     protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException {
         AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
-        String funcName = funcExpr.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = funcExpr.getFunctionIdentifier();
         IAType t1 = strippedInputTypes[0];
         IAType t2 = strippedInputTypes[1];
         ATypeTag tag1 = t1.getTypeTag();
@@ -70,7 +71,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case FLOAT:
@@ -89,7 +90,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case BIGINT:
@@ -110,7 +111,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case INTEGER:
@@ -133,7 +134,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case SMALLINT:
@@ -158,7 +159,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case TINYINT:
@@ -185,7 +186,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case ANY:
@@ -206,7 +207,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DATE:
@@ -223,7 +224,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case TIME:
@@ -240,7 +241,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DATETIME:
@@ -254,7 +255,7 @@
                         type = BuiltinType.ADATETIME;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DURATION:
@@ -272,7 +273,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case YEARMONTHDURATION:
@@ -293,7 +294,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DAYTIMEDURATION:
@@ -314,11 +315,11 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             default:
-                throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
         }
 
         if (nullable && type.getTypeTag() != ATypeTag.ANY) {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java
index c94a22b..0a130f0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDivideTypeComputer.java
@@ -28,6 +28,7 @@
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 
 /**
  * Returns double if both operands are integers
@@ -41,7 +42,7 @@
     @Override
     protected IAType getResultType(ILogicalExpression expr, IAType... strippedInputTypes) throws AlgebricksException {
         AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
-        String funcName = funcExpr.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = funcExpr.getFunctionIdentifier();
         IAType t1 = strippedInputTypes[0];
         IAType t2 = strippedInputTypes[1];
         ATypeTag tag1 = t1.getTypeTag();
@@ -63,7 +64,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case FLOAT:
@@ -82,7 +83,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case BIGINT:
@@ -104,7 +105,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case ANY:
@@ -119,7 +120,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DATE:
@@ -136,7 +137,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case TIME:
@@ -153,7 +154,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DATETIME:
@@ -167,7 +168,7 @@
                         type = BuiltinType.ADATETIME;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DURATION:
@@ -185,7 +186,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case YEARMONTHDURATION:
@@ -206,7 +207,7 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             case DAYTIMEDURATION:
@@ -227,11 +228,11 @@
                         type = BuiltinType.ANY;
                         break;
                     default:
-                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                        throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
                 }
                 break;
             default:
-                throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcName, tag1, tag2);
+                throw new IncompatibleTypeException(funcExpr.getSourceLocation(), funcId, tag1, tag2);
         }
 
         if (type.getTypeTag() != ATypeTag.ANY) {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDoubleOutputFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDoubleOutputFunctionTypeComputer.java
index 54e1bcd..61f0e98 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDoubleOutputFunctionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericDoubleOutputFunctionTypeComputer.java
@@ -26,6 +26,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class NumericDoubleOutputFunctionTypeComputer extends AbstractResultTypeComputer {
@@ -37,7 +38,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         switch (tag) {
@@ -49,7 +50,7 @@
             case DOUBLE:
                 break;
             default:
-                throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
+                throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
                         ATypeTag.INTEGER, ATypeTag.BIGINT, ATypeTag.FLOAT, ATypeTag.DOUBLE);
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericInt8OutputFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericInt8OutputFunctionTypeComputer.java
index 8d84ce0..203deef 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericInt8OutputFunctionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericInt8OutputFunctionTypeComputer.java
@@ -26,6 +26,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class NumericInt8OutputFunctionTypeComputer extends AbstractResultTypeComputer {
@@ -36,7 +37,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         switch (tag) {
@@ -48,7 +49,7 @@
             case DOUBLE:
                 break;
             default:
-                throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
+                throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
                         ATypeTag.INTEGER, ATypeTag.BIGINT, ATypeTag.FLOAT, ATypeTag.DOUBLE);
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRound2TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRound2TypeComputer.java
index b537ffc..09bcfd9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRound2TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRound2TypeComputer.java
@@ -29,6 +29,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class NumericRound2TypeComputer extends AbstractResultTypeComputer {
@@ -40,7 +41,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         if (argIndex == 0) {
@@ -53,7 +54,7 @@
                 case DOUBLE:
                     break;
                 default:
-                    throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.TINYINT,
+                    throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.TINYINT,
                             ATypeTag.SMALLINT, ATypeTag.INTEGER, ATypeTag.BIGINT, ATypeTag.FLOAT, ATypeTag.DOUBLE);
             }
         }
@@ -65,7 +66,7 @@
                 case BIGINT:
                     break;
                 default:
-                    throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.TINYINT,
+                    throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.TINYINT,
                             ATypeTag.SMALLINT, ATypeTag.INTEGER, ATypeTag.BIGINT);
             }
         }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericSumAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericSumAggTypeComputer.java
index 7b0bca6..1c67e56 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericSumAggTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericSumAggTypeComputer.java
@@ -26,6 +26,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class NumericSumAggTypeComputer extends AbstractResultTypeComputer {
@@ -35,7 +36,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         switch (tag) {
@@ -48,7 +49,7 @@
             case ANY:
                 break;
             default:
-                throw new UnsupportedTypeException(sourceLoc, funcName, tag);
+                throw new UnsupportedTypeException(sourceLoc, funcId, tag);
         }
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
index ef9791f..37103f8 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
@@ -29,6 +29,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class NumericUnaryFunctionTypeComputer extends AbstractResultTypeComputer {
@@ -38,7 +39,7 @@
     }
 
     @Override
-    protected void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    protected void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         switch (tag) {
@@ -51,7 +52,7 @@
             case ANY:
                 break;
             default:
-                throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
+                throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
                         ATypeTag.INTEGER, ATypeTag.BIGINT, ATypeTag.FLOAT, ATypeTag.DOUBLE);
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
index 5c59af6..1bd8832 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
@@ -43,6 +43,7 @@
 import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 
 public class RecordAddFieldsTypeComputer implements IResultTypeComputer {
@@ -58,12 +59,12 @@
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expression;
-        String funcName = funcExpr.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = funcExpr.getFunctionIdentifier();
 
         IAType type0 = (IAType) env.getType(funcExpr.getArguments().get(0).getValue());
         ARecordType inputRecordType = TypeComputeUtils.extractRecordType(type0);
         if (inputRecordType == null) {
-            throw new TypeMismatchException(funcExpr.getSourceLocation(), funcName, 0, type0.getTypeTag(),
+            throw new TypeMismatchException(funcExpr.getSourceLocation(), funcId, 0, type0.getTypeTag(),
                     ATypeTag.OBJECT);
         }
 
@@ -110,7 +111,7 @@
                         if (fn[j].equals(FIELD_NAME_NAME)) {
                             ILogicalExpression fieldNameExpr = recConsExpr.getArguments().get(j).getValue();
                             if (ConstantExpressionUtil.getStringConstant(fieldNameExpr) == null) {
-                                throw new InvalidExpressionException(funcExpr.getSourceLocation(), funcName, 1,
+                                throw new InvalidExpressionException(funcExpr.getSourceLocation(), funcId, 1,
                                         fieldNameExpr, LogicalExpressionTag.CONSTANT);
                             }
                             // Get the actual "field-name" string
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
index 98ec9e7..109f7c6 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
@@ -37,6 +37,7 @@
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
@@ -50,19 +51,19 @@
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
-        String funcName = f.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = f.getFunctionIdentifier();
 
         IAType t0 = (IAType) env.getType(f.getArguments().get(0).getValue());
         IAType t1 = (IAType) env.getType(f.getArguments().get(1).getValue());
         boolean unknownable = TypeHelper.canBeUnknown(t0) || TypeHelper.canBeUnknown(t1);
         ARecordType recType0 = TypeComputeUtils.extractRecordType(t0);
         if (recType0 == null) {
-            throw new TypeMismatchException(f.getSourceLocation(), funcName, 0, t0.getTypeTag(), ATypeTag.OBJECT);
+            throw new TypeMismatchException(f.getSourceLocation(), funcId, 0, t0.getTypeTag(), ATypeTag.OBJECT);
         }
 
         ARecordType recType1 = TypeComputeUtils.extractRecordType(t1);
         if (recType1 == null) {
-            throw new TypeMismatchException(f.getSourceLocation(), funcName, 1, t1.getTypeTag(), ATypeTag.OBJECT);
+            throw new TypeMismatchException(f.getSourceLocation(), funcId, 1, t1.getTypeTag(), ATypeTag.OBJECT);
         }
 
         List<String> resultFieldNames = new ArrayList<>();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
index 4e9a563..e50ce1b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
@@ -50,6 +50,7 @@
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractLogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
@@ -65,11 +66,12 @@
     private RecordRemoveFieldsTypeComputer() {
     }
 
-    private void getPathFromConstantExpression(String funcName, ILogicalExpression expression, Set<String> fieldNameSet,
-            List<List<String>> pathList, SourceLocation sourceLoc) throws AlgebricksException {
+    private void getPathFromConstantExpression(FunctionIdentifier funcId, ILogicalExpression expression,
+            Set<String> fieldNameSet, List<List<String>> pathList, SourceLocation sourceLoc)
+            throws AlgebricksException {
         ConstantExpression ce = (ConstantExpression) expression;
         if (!(ce.getValue() instanceof AsterixConstantValue)) {
-            throw new InvalidExpressionException(sourceLoc, funcName, 1, ce, LogicalExpressionTag.CONSTANT);
+            throw new InvalidExpressionException(sourceLoc, funcId, 1, ce, LogicalExpressionTag.CONSTANT);
         }
         IAObject item = ((AsterixConstantValue) ce.getValue()).getObject();
         ATypeTag type = item.getType().getTypeTag();
@@ -90,12 +92,12 @@
                 pathList.add(path);
                 break;
             default:
-                throw new UnsupportedTypeException(sourceLoc, funcName, type);
+                throw new UnsupportedTypeException(sourceLoc, funcId, type);
         }
     }
 
-    private List<String> getListFromExpression(String funcName, ILogicalExpression expression, SourceLocation sourceLoc)
-            throws AlgebricksException {
+    private List<String> getListFromExpression(FunctionIdentifier funcId, ILogicalExpression expression,
+            SourceLocation sourceLoc) throws AlgebricksException {
         AbstractFunctionCallExpression funcExp = (AbstractFunctionCallExpression) expression;
         List<Mutable<ILogicalExpression>> args = funcExp.getArguments();
 
@@ -105,30 +107,31 @@
             // Input list has only one level of nesting (list of list or list of strings)
             ConstantExpression ce = (ConstantExpression) arg.getValue();
             if (!(ce.getValue() instanceof AsterixConstantValue)) {
-                throw new InvalidExpressionException(sourceLoc, funcName, 1, ce, LogicalExpressionTag.CONSTANT);
+                throw new InvalidExpressionException(sourceLoc, funcId, 1, ce, LogicalExpressionTag.CONSTANT);
             }
             IAObject item = ((AsterixConstantValue) ce.getValue()).getObject();
             ATypeTag type = item.getType().getTypeTag();
             if (type == ATypeTag.STRING) {
                 list.add(((AString) item).getStringValue());
             } else {
-                throw new UnsupportedTypeException(sourceLoc, funcName, type);
+                throw new UnsupportedTypeException(sourceLoc, funcId, type);
             }
         }
 
         return list;
     }
 
-    private void getPathFromFunctionExpression(String funcName, ILogicalExpression expression, Set<String> fieldNameSet,
-            List<List<String>> pathList, SourceLocation sourceLoc) throws AlgebricksException {
-        List<String> path = getListFromExpression(funcName, expression, sourceLoc);
+    private void getPathFromFunctionExpression(FunctionIdentifier funcId, ILogicalExpression expression,
+            Set<String> fieldNameSet, List<List<String>> pathList, SourceLocation sourceLoc)
+            throws AlgebricksException {
+        List<String> path = getListFromExpression(funcId, expression, sourceLoc);
         // Add the path head to remove set
         fieldNameSet.add(path.get(0));
         pathList.add(path);
 
     }
 
-    private void computeTypeFromNonConstantExpression(String funcName, ILogicalExpression expression,
+    private void computeTypeFromNonConstantExpression(FunctionIdentifier funcId, ILogicalExpression expression,
             Set<String> fieldNameSet, List<List<String>> pathList) throws AlgebricksException {
         AbstractFunctionCallExpression funcExp = (AbstractFunctionCallExpression) expression;
         List<Mutable<ILogicalExpression>> args = funcExp.getArguments();
@@ -137,13 +140,13 @@
             ILogicalExpression le = arg.getValue();
             switch (le.getExpressionTag()) {
                 case CONSTANT:
-                    getPathFromConstantExpression(funcName, le, fieldNameSet, pathList, funcExp.getSourceLocation());
+                    getPathFromConstantExpression(funcId, le, fieldNameSet, pathList, funcExp.getSourceLocation());
                     break;
                 case FUNCTION_CALL:
-                    getPathFromFunctionExpression(funcName, le, fieldNameSet, pathList, funcExp.getSourceLocation());
+                    getPathFromFunctionExpression(funcId, le, fieldNameSet, pathList, funcExp.getSourceLocation());
                     break;
                 default:
-                    throw new InvalidExpressionException(funcExp.getSourceLocation(), funcName, 1, le,
+                    throw new InvalidExpressionException(funcExp.getSourceLocation(), funcId, 1, le,
                             LogicalExpressionTag.CONSTANT, LogicalExpressionTag.FUNCTION_CALL);
             }
         }
@@ -153,14 +156,14 @@
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
             IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
         AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expression;
-        String funcName = funcExpr.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = funcExpr.getFunctionIdentifier();
 
         IAType type0 = (IAType) env.getType(funcExpr.getArguments().get(0).getValue());
         List<List<String>> pathList = new ArrayList<>();
         Set<String> fieldNameSet = new HashSet<>();
         Deque<String> fieldPathStack = new ArrayDeque<>();
 
-        ARecordType inputRecordType = getRecordTypeFromType(funcName, type0, funcExpr.getSourceLocation());
+        ARecordType inputRecordType = getRecordTypeFromType(funcId, type0, funcExpr.getSourceLocation());
         if (inputRecordType == null) {
             return BuiltinType.ANY;
         }
@@ -169,7 +172,7 @@
         IAType inputListType = (IAType) env.getType(arg1);
         AOrderedListType inputOrderedListType = TypeComputeUtils.extractOrderedListType(inputListType);
         if (inputOrderedListType == null) {
-            throw new TypeMismatchException(funcExpr.getSourceLocation(), funcName, 1, inputListType.getTypeTag(),
+            throw new TypeMismatchException(funcExpr.getSourceLocation(), funcId, 1, inputListType.getTypeTag(),
                     ATypeTag.ARRAY);
         }
 
@@ -181,7 +184,7 @@
                 return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
             }
         } else { // tt == ATypeTag.ANY, meaning the list is nested
-            computeTypeFromNonConstantExpression(funcName, arg1, fieldNameSet, pathList);
+            computeTypeFromNonConstantExpression(funcId, arg1, fieldNameSet, pathList);
             IAType resultType = buildOutputType(fieldPathStack, inputRecordType, fieldNameSet, pathList);
             return resultType;
         }
@@ -321,7 +324,7 @@
                 destFieldTypes.toArray(new IAType[n]), isOpen);
     }
 
-    private static ARecordType getRecordTypeFromType(String funcName, IAType type0, SourceLocation sourceLoc)
+    private static ARecordType getRecordTypeFromType(FunctionIdentifier funcId, IAType type0, SourceLocation sourceLoc)
             throws AlgebricksException {
         switch (type0.getTypeTag()) {
             case OBJECT:
@@ -337,7 +340,7 @@
                 }
                 // Falls through for other cases.
             default:
-                throw new TypeMismatchException(sourceLoc, funcName, 0, type0.getTypeTag(), ATypeTag.OBJECT);
+                throw new TypeMismatchException(sourceLoc, funcId, 0, type0.getTypeTag(), ATypeTag.OBJECT);
         }
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
index 07c79ad..fd1e136 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
@@ -27,6 +27,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class ScalarVersionOfAggregateResultType extends AbstractResultTypeComputer {
@@ -37,11 +38,11 @@
     }
 
     @Override
-    public void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    public void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         if (tag != ATypeTag.ANY && tag != ATypeTag.ARRAY && tag != ATypeTag.MULTISET) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.ARRAY, ATypeTag.MULTISET);
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.ARRAY, ATypeTag.MULTISET);
         }
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SleepTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SleepTypeComputer.java
index c05b085..16d5789 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SleepTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SleepTypeComputer.java
@@ -24,13 +24,14 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class SleepTypeComputer extends AbstractResultTypeComputer {
     public static final SleepTypeComputer INSTANCE = new SleepTypeComputer();
 
     @Override
-    public void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    public void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         if (argIndex == 1) {
             switch (type.getTypeTag()) {
@@ -40,7 +41,7 @@
                 case BIGINT:
                     break;
                 default:
-                    throw new TypeMismatchException(sourceLoc, funcName, argIndex, type.getTypeTag(), ATypeTag.TINYINT,
+                    throw new TypeMismatchException(sourceLoc, funcId, argIndex, type.getTypeTag(), ATypeTag.TINYINT,
                             ATypeTag.SMALLINT, ATypeTag.INTEGER, ATypeTag.BIGINT);
             }
         }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringIntToStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringIntToStringTypeComputer.java
index b2c95c5..4499e31 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringIntToStringTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringIntToStringTypeComputer.java
@@ -29,6 +29,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class StringIntToStringTypeComputer extends AbstractResultTypeComputer {
@@ -63,7 +64,7 @@
     }
 
     @Override
-    public void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    public void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         boolean expectedStringType = false;
@@ -86,7 +87,7 @@
             expectedIntType = true;
         }
 
-        throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag,
+        throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag,
                 getExpectedTypes(expectedStringType, expectedIntType));
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java
index 5655454..99e3b4f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java
@@ -29,6 +29,7 @@
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
 import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
 
 public class SubsetCollectionTypeComputer implements IResultTypeComputer {
@@ -42,7 +43,7 @@
     public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env, IMetadataProvider<?, ?> mp)
             throws AlgebricksException {
         AbstractFunctionCallExpression fun = (AbstractFunctionCallExpression) expression;
-        String funcName = fun.getFunctionIdentifier().getName();
+        FunctionIdentifier funcId = fun.getFunctionIdentifier();
 
         IAType t = (IAType) env.getType(fun.getArguments().get(0).getValue());
         ATypeTag actualTypeTag = t.getTypeTag();
@@ -55,7 +56,7 @@
             case UNION: {
                 AUnionType ut = (AUnionType) t;
                 if (!ut.isUnknownableType()) {
-                    throw new TypeMismatchException(fun.getSourceLocation(), funcName, 0, actualTypeTag,
+                    throw new TypeMismatchException(fun.getSourceLocation(), funcId, 0, actualTypeTag,
                             ATypeTag.MULTISET, ATypeTag.ARRAY);
                 }
                 IAType t2 = ut.getActualType();
@@ -64,13 +65,13 @@
                     AbstractCollectionType act = (AbstractCollectionType) t2;
                     return act.getItemType();
                 }
-                throw new TypeMismatchException(fun.getSourceLocation(), funcName, 0, actualTypeTag, ATypeTag.MULTISET,
+                throw new TypeMismatchException(fun.getSourceLocation(), funcId, 0, actualTypeTag, ATypeTag.MULTISET,
                         ATypeTag.ARRAY);
             }
             case ANY:
                 return BuiltinType.ANY;
             default:
-                throw new TypeMismatchException(fun.getSourceLocation(), funcName, 0, actualTypeTag, ATypeTag.MULTISET,
+                throw new TypeMismatchException(fun.getSourceLocation(), funcId, 0, actualTypeTag, ATypeTag.MULTISET,
                         ATypeTag.ARRAY);
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java
index aa31942..ab0b159 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java
@@ -26,17 +26,18 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class SubstringTypeComputer extends AbstractResultTypeComputer {
     public static final SubstringTypeComputer INSTANCE = new SubstringTypeComputer();
 
     @Override
-    public void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    public void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         if (argIndex == 0 && tag != ATypeTag.STRING) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.STRING);
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.STRING);
         }
         if (argIndex > 0 && argIndex <= 2) {
             switch (tag) {
@@ -46,7 +47,7 @@
                 case BIGINT:
                     break;
                 default:
-                    throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.TINYINT,
+                    throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.TINYINT,
                             ATypeTag.SMALLINT, ATypeTag.INTEGER, ATypeTag.BIGINT);
             }
         }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64TypeComputer.java
index 911e4d1..bc4e59c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64TypeComputer.java
@@ -26,6 +26,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class UnaryBinaryInt64TypeComputer extends AbstractResultTypeComputer {
@@ -35,11 +36,11 @@
     }
 
     @Override
-    public void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    public void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         if (tag != ATypeTag.BINARY) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.BINARY);
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.BINARY);
         }
     }
 
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryMinusTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryMinusTypeComputer.java
index 3066a22..cae6664 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryMinusTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryMinusTypeComputer.java
@@ -24,6 +24,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class UnaryMinusTypeComputer extends AbstractResultTypeComputer {
@@ -34,7 +35,7 @@
     }
 
     @Override
-    public void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    public void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         switch (tag) {
@@ -46,7 +47,7 @@
             case DOUBLE:
                 break;
             default:
-                throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
+                throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.TINYINT, ATypeTag.SMALLINT,
                         ATypeTag.INTEGER, ATypeTag.BIGINT, ATypeTag.FLOAT, ATypeTag.DOUBLE);
         }
     }
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64TypeComputer.java
index 5535890..344da43 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64TypeComputer.java
@@ -25,6 +25,7 @@
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.api.exceptions.SourceLocation;
 
 public class UnaryStringInt64TypeComputer extends AbstractResultTypeComputer {
@@ -35,11 +36,11 @@
     }
 
     @Override
-    public void checkArgType(String funcName, int argIndex, IAType type, SourceLocation sourceLoc)
+    public void checkArgType(FunctionIdentifier funcId, int argIndex, IAType type, SourceLocation sourceLoc)
             throws AlgebricksException {
         ATypeTag tag = type.getTypeTag();
         if (tag != ATypeTag.STRING) {
-            throw new TypeMismatchException(sourceLoc, funcName, argIndex, tag, ATypeTag.STRING);
+            throw new TypeMismatchException(sourceLoc, funcId, argIndex, tag, ATypeTag.STRING);
         }
     }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java
index dbe2e05..40308fd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CodePointToStringDescriptor.java
@@ -81,7 +81,7 @@
                             int size;
 
                             if (ATypeTag.VALUE_TYPE_MAPPING[serOrderedList[offset]] != ATypeTag.ARRAY) {
-                                throw new TypeMismatchException(getIdentifier().getName(), 0, serOrderedList[offset]);
+                                throw new TypeMismatchException(sourceLoc, getIdentifier(), 0, serOrderedList[offset]);
                             } else {
                                 switch (ATypeTag.VALUE_TYPE_MAPPING[serOrderedList[offset + 1]]) {
                                     case TINYINT:
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
index df875a0..ca567ba 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/InjectFailureDescriptor.java
@@ -82,7 +82,8 @@
                                     argPtr.getStartOffset() + 1);
                             if (argResult) {
                                 LOGGER.log(Level.ERROR, ctx.getTaskAttemptId() + " injecting failure");
-                                throw new RuntimeDataException(ErrorCode.INJECTED_FAILURE, sourceLoc, getIdentifier());
+                                throw new RuntimeDataException(ErrorCode.INJECTED_FAILURE, sourceLoc,
+                                        getIdentifier().getName());
                             }
                         }
 
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java
index 90f4e35..068ab71 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRepeatDescriptor.java
@@ -87,8 +87,8 @@
                                 ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 1, bytes, offset);
                         // Checks repeatingTimes. It should be a non-negative value.
                         if (repeatingTimes < 0) {
-                            throw new RuntimeDataException(ErrorCode.NEGATIVE_VALUE, sourceLoc, getIdentifier(), 1,
-                                    repeatingTimes);
+                            throw new RuntimeDataException(ErrorCode.NEGATIVE_VALUE, sourceLoc,
+                                    getIdentifier().getName(), 1, repeatingTimes);
                         }
 
                         // Gets the input string.
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java
index 81a6adb..5ab78c7 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java
@@ -24,6 +24,7 @@
 import org.apache.asterix.runtime.exceptions.TypeMismatchException;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
+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;
@@ -39,26 +40,29 @@
     protected DataOutput dataOutput = resultStorage.getDataOutput();
     protected IPointable[] pointables;
     protected IScalarEvaluator[] evaluators;
-    protected SourceLocation sourceLoc;
+    // Function ID, for error reporting.
+    protected final FunctionIdentifier funcId;
+    protected final SourceLocation sourceLoc;
 
     public AbstractBinaryScalarEvaluator(IHyracksTaskContext context,
-            final IScalarEvaluatorFactory[] evaluatorFactories, SourceLocation sourceLoc) throws HyracksDataException {
+            final IScalarEvaluatorFactory[] evaluatorFactories, FunctionIdentifier funcId, SourceLocation sourceLoc)
+            throws HyracksDataException {
         pointables = new IPointable[evaluatorFactories.length];
         evaluators = new IScalarEvaluator[evaluatorFactories.length];
         for (int i = 0; i < evaluators.length; ++i) {
             pointables[i] = new VoidPointable();
             evaluators[i] = evaluatorFactories[i].createScalarEvaluator(context);
         }
+        this.funcId = funcId;
         this.sourceLoc = sourceLoc;
     }
 
-    protected void checkTypeMachingThrowsIfNot(String title, ATypeTag[] expected, ATypeTag... actual)
-            throws HyracksDataException {
+    protected void checkTypeMachingThrowsIfNot(ATypeTag[] expected, ATypeTag... actual) throws HyracksDataException {
         for (int i = 0; i < expected.length; i++) {
             if (expected[i] != actual[i]) {
                 if (!ATypeHierarchy.canPromote(actual[i], expected[i])
                         && !ATypeHierarchy.canPromote(expected[i], actual[i])) {
-                    throw new TypeMismatchException(sourceLoc, title, i, actual[i].serialize(),
+                    throw new TypeMismatchException(sourceLoc, funcId, i, actual[i].serialize(),
                             expected[i].serialize());
                 }
             }
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java
index 1637130..6cd1cef 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java
@@ -24,6 +24,7 @@
 import org.apache.asterix.om.base.AMutableInt64;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.BuiltinType;
+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;
@@ -37,7 +38,6 @@
 
     private static final ATypeTag[] EXPECTED_INPUT_TAG = { ATypeTag.BINARY, ATypeTag.BINARY };
     protected final int baseOffset;
-    protected final String functionName;
     protected final AMutableInt64 result = new AMutableInt64(-1);
     protected final ByteArrayPointable textPtr = new ByteArrayPointable();
     protected final ByteArrayPointable wordPtr = new ByteArrayPointable();
@@ -47,10 +47,9 @@
             SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
 
     public AbstractFindBinaryEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory[] copyEvaluatorFactories,
-            int baseOffset, String functionName, SourceLocation sourceLoc) throws HyracksDataException {
-        super(context, copyEvaluatorFactories, sourceLoc);
+            int baseOffset, FunctionIdentifier funcId, SourceLocation sourceLoc) throws HyracksDataException {
+        super(context, copyEvaluatorFactories, funcId, sourceLoc);
         this.baseOffset = baseOffset;
-        this.functionName = functionName;
     }
 
     @Override
@@ -64,7 +63,7 @@
         ATypeTag textTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0].getStartOffset()]];
         ATypeTag wordTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1].getStartOffset()]];
 
-        checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAG, textTag, wordTag);
+        checkTypeMachingThrowsIfNot(EXPECTED_INPUT_TAG, textTag, wordTag);
         textPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1, pointables[0].getLength() - 1);
         wordPtr.set(pointables[1].getByteArray(), pointables[0].getStartOffset() + 1, pointables[1].getLength() - 1);
         int pos = indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(), textPtr.getContentLength(),
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
index 391df5e..f49f06b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
@@ -24,6 +24,7 @@
 import org.apache.asterix.om.functions.BuiltinFunctions;
 import org.apache.asterix.om.types.ATypeTag;
 import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
+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;
@@ -38,15 +39,13 @@
     private ByteArrayPointable byteArrayPointable = new ByteArrayPointable();
     private byte[] metaBuffer = new byte[5];
     protected final int baseOffset;
-    protected final String functionName;
 
     private static final ATypeTag[] EXPECTED_INPUT_TAGS = { ATypeTag.BINARY, ATypeTag.INTEGER };
 
     public AbstractSubBinaryEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory[] copyEvaluatorFactories,
-            int baseOffset, String functionName, SourceLocation sourceLoc) throws HyracksDataException {
-        super(context, copyEvaluatorFactories, sourceLoc);
+            int baseOffset, FunctionIdentifier funcId, SourceLocation sourceLoc) throws HyracksDataException {
+        super(context, copyEvaluatorFactories, funcId, sourceLoc);
         this.baseOffset = baseOffset;
-        this.functionName = functionName;
     }
 
     @Override
@@ -61,7 +60,7 @@
                     ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0].getStartOffset()]];
             ATypeTag argTag1 =
                     ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1].getStartOffset()]];
-            checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAGS, argTag0, argTag1);
+            checkTypeMachingThrowsIfNot(EXPECTED_INPUT_TAGS, argTag0, argTag1);
 
             byteArrayPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
                     pointables[0].getLength() - 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
index 4eaa1d1..152801d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
@@ -66,7 +66,7 @@
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                return new AbstractBinaryScalarEvaluator(ctx, args, sourceLoc) {
+                return new AbstractBinaryScalarEvaluator(ctx, args, getIdentifier(), sourceLoc) {
 
                     private final ListAccessor listAccessor = new ListAccessor();
                     private final byte[] metaBuffer = new byte[5];
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
index dc8edbe..031eca9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
@@ -56,7 +56,7 @@
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                return new AbstractBinaryScalarEvaluator(ctx, args, sourceLoc) {
+                return new AbstractBinaryScalarEvaluator(ctx, args, getIdentifier(), sourceLoc) {
 
                     private AMutableInt64 result = new AMutableInt64(0);
                     @SuppressWarnings("unchecked")
@@ -70,7 +70,7 @@
                         evaluators[0].evaluate(tuple, pointables[0]);
                         ATypeTag tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
                                 .getStartOffset()]];
-                        checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_TAGS, tag);
+                        checkTypeMachingThrowsIfNot(EXPECTED_TAGS, tag);
                         int len = ByteArrayPointable.getContentLength(pointables[0].getByteArray(),
                                 pointables[0].getStartOffset() + 1);
                         result.setValue(len);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
index f83f092..fb4075b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
@@ -60,7 +60,7 @@
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                return new AbstractFindBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName(), sourceLoc) {
+                return new AbstractFindBinaryEvaluator(ctx, args, baseOffset, getIdentifier(), sourceLoc) {
                     @Override
                     protected int getFromOffset(IFrameTupleReference tuple) {
                         return 0;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
index fff7ca5..874a2dd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
@@ -62,7 +62,7 @@
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                return new AbstractFindBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName(), sourceLoc) {
+                return new AbstractFindBinaryEvaluator(ctx, args, baseOffset, getIdentifier(), sourceLoc) {
                     @Override
                     protected int getFromOffset(IFrameTupleReference tuple) throws HyracksDataException {
                         return ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 2,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
index 35e7fba..b2ea044 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
@@ -67,7 +67,7 @@
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                return new AbstractBinaryScalarEvaluator(ctx, args, sourceLoc) {
+                return new AbstractBinaryScalarEvaluator(ctx, args, getIdentifier(), sourceLoc) {
 
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ABinary> binarySerde =
@@ -91,8 +91,7 @@
 
                         ATypeTag formatTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
                                 .getStartOffset()]];
-                        checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_INPUT_TAGS, binaryTag,
-                                formatTag);
+                        checkTypeMachingThrowsIfNot(EXPECTED_INPUT_TAGS, binaryTag, formatTag);
                         stringPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
                                 pointables[0].getLength());
                         formatPointable.set(pointables[1].getByteArray(), pointables[1].getStartOffset() + 1,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
index c141e88..7f61d39 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
@@ -66,7 +66,7 @@
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                return new AbstractBinaryScalarEvaluator(ctx, args, sourceLoc) {
+                return new AbstractBinaryScalarEvaluator(ctx, args, getIdentifier(), sourceLoc) {
 
                     private StringBuilder stringBuilder = new StringBuilder();
                     private final ByteArrayPointable byteArrayPtr = new ByteArrayPointable();
@@ -84,8 +84,7 @@
                                     .getStartOffset()]];
                             ATypeTag arg1Tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
                                     .getStartOffset()]];
-                            checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_INPUT_TAGS, arg0Tag,
-                                    arg1Tag);
+                            checkTypeMachingThrowsIfNot(EXPECTED_INPUT_TAGS, arg0Tag, arg1Tag);
 
                             byteArrayPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
                                     pointables[0].getLength());
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
index c2fcdab..2b0228d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
@@ -60,7 +60,7 @@
 
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
-                return new AbstractSubBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName(), sourceLoc) {
+                return new AbstractSubBinaryEvaluator(ctx, args, baseOffset, getIdentifier(), sourceLoc) {
                     @Override
                     protected int getSubLength(IFrameTupleReference tuple) {
                         return Integer.MAX_VALUE;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
index a9c4c46..b7573c5 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
@@ -62,7 +62,7 @@
             @Override
             public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException {
 
-                return new AbstractSubBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName(), sourceLoc) {
+                return new AbstractSubBinaryEvaluator(ctx, args, baseOffset, getIdentifier(), sourceLoc) {
                     @Override
                     protected int getSubLength(IFrameTupleReference tuple) throws HyracksDataException {
                         return ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 2,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
index ac2e06a..9426104 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
@@ -187,7 +187,7 @@
                                         + ((totalChronon < 0 && totalChronon % dayTime != 0) ? -1 : 0);
                                 break;
                             default:
-                                throw new TypeMismatchException(getIdentifier().getName(), 2, bytes2[offset2],
+                                throw new TypeMismatchException(sourceLoc, getIdentifier(), 2, bytes2[offset2],
                                         ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG,
                                         ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG);
                         }
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 d5472d0..5e1087e 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
@@ -47,6 +47,14 @@
     }
 
     // Function parameter type mismatch.
+    public TypeMismatchException(SourceLocation sourceLoc, FunctionIdentifier fid, Integer i, byte actualTypeTag,
+            String expectedType) {
+        super(ErrorCode.TYPE_MISMATCH_FUNCTION, sourceLoc, fid.getName(), indexToPosition(i), expectedType,
+                EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
+    }
+
+    // Function parameter type mismatch.
+    @Deprecated
     public TypeMismatchException(String functionName, Integer i, byte actualTypeTag, byte... expectedTypeTags) {
         super(ErrorCode.TYPE_MISMATCH_FUNCTION, functionName, indexToPosition(i),
                 toExpectedTypeString(expectedTypeTags),
@@ -54,6 +62,7 @@
     }
 
     // Function parameter type mismatch.
+    @Deprecated
     public TypeMismatchException(SourceLocation sourceLoc, String functionName, Integer i, byte actualTypeTag,
             byte... expectedTypeTags) {
         super(ErrorCode.TYPE_MISMATCH_FUNCTION, sourceLoc, functionName, indexToPosition(i),
@@ -61,13 +70,6 @@
                 EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(actualTypeTag));
     }
 
-    // Function parameter type mismatch.
-    public TypeMismatchException(SourceLocation sourceLoc, FunctionIdentifier fid, Integer i, byte actualTypeTag,
-            String 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),
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
index cd06490..65e89c4 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
@@ -99,7 +99,7 @@
 
                             if (typeTag != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
                                     && typeTag != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
-                                throw new RuntimeDataException(ErrorCode.COERCION, getIdentifier());
+                                throw new RuntimeDataException(ErrorCode.COERCION, getIdentifier().getName());
                             }
                             if (typeTag == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
                                 numItemsMax = AOrderedListSerializerDeserializer.getNumberOfItems(serList, offset);