[ASTERIXDB-3483]: Add method for extensions

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

Deatils:
- Override the 'toString' method in Creator class.
- Add 'newExtension' method in EntityDetails.
- Add method to return function name with arity.

Change-Id: I9d9c938c66c500ba0e741f4cf6f361b20e9eacd3
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18951
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
index 419d677..df7d6d8 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/ExpressionUtils.java
@@ -296,7 +296,7 @@
                         if (seenFunctions.add(signature)) {
                             String functionName = signature.getName() + "(" + signature.getArity() + ")";
                             metadataProvider.addAccessedEntity(EntityDetails.newFunction(signature.getDatabaseName(),
-                                    signature.getDataverseName(), functionName, 0));
+                                    signature.getDataverseName(), functionName, signature.getArity()));
                             outFunctionDependencies.add(new DependencyFullyQualifiedName(signature.getDatabaseName(),
                                     signature.getDataverseName(), signature.getName(),
                                     Integer.toString(signature.getArity())));
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppLoadAccessedDataset.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppLoadAccessedDataset.java
index 7981d55..1b1cf83 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppLoadAccessedDataset.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppLoadAccessedDataset.java
@@ -98,9 +98,9 @@
             if (declaredFunctions.containsKey(signature)) {
                 return;
             }
-            String functionName = signature.getName() + "(" + signature.getArity() + ")";
+            String functionName = EntityDetails.getFunctionNameWithArity(signature.getName(), signature.getArity());
             context.getMetadataProvider().addAccessedEntity(EntityDetails.newFunction(signature.getDatabaseName(),
-                    signature.getDataverseName(), functionName, 0));
+                    signature.getDataverseName(), functionName, signature.getArity()));
         }
     }
 }
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/EntityDetails.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/EntityDetails.java
index 23353eb..c7e771b 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/EntityDetails.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/EntityDetails.java
@@ -88,6 +88,10 @@
         return new EntityDetails(databaseName, dataverseName, indexName, EntityType.INDEX);
     }
 
+    public static EntityDetails newExtension(String extensionName) {
+        return new EntityDetails(null, null, extensionName, null);
+    }
+
     public String getDatabaseName() {
         return databaseName;
     }
@@ -107,4 +111,8 @@
     public int getFunctionArity() {
         return functionArity;
     }
+
+    public static String getFunctionNameWithArity(String functionName, int functionArity) {
+        return functionName + "(" + functionArity + ")";
+    }
 }
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/Creator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/Creator.java
index 3cf6567..49fca80f 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/Creator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/Creator.java
@@ -51,6 +51,11 @@
         return uuid;
     }
 
+    @Override
+    public String toString() {
+        return String.format("Creator{name='%s', uuid='%s'}", name, uuid);
+    }
+
     public static Creator createOrDefault(ARecord record) {
         ARecordType recType = record.getType();
         int creatorIndex = recType.getFieldIndex(MetadataRecordTypes.CREATOR_ARECORD_FIELD_NAME);