olabusayoT commented on a change in pull request #273: WIP: Add User Defined 
Functions Capability
URL: https://github.com/apache/incubator-daffodil/pull/273#discussion_r336066715
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/dpath/Expression.scala
 ##########
 @@ -1870,7 +1870,32 @@ case class FunctionCallExpression(functionQNameString: 
String, expressions: List
       case (RefQName(_, "unsignedByte", XSD), args) =>
         XSConverterExpr(functionQNameString, functionQName, args, 
NodeInfo.UnsignedByte)
 
-      case _ => SDE("Unsupported function: %s", functionQName)
+      case (_: RefQName, args) => {
+        val namespace = functionQName.namespace.toString()
+        val fName = functionQName.local
+
+        val udfCallingInfo = 
UserDefinedFunctionService.lookupUDFCallingInfo(namespace, fName)
+
+        if (udfCallingInfo.isEmpty) {
+          SDE(s"Error calling $namespace:$fName")
+        } else {
+          /*
+           * Attempting assignnment by tuple matching results in a scala 
existentials error in SBT
+           * so we do it this way instead
+           */
+          val udfci = udfCallingInfo.get
+          val udf = udfci._1
+          val evaluateMethod = udfci._2
+          val paramTypes = udfci._3
+          val retType = udfci._4
+
+          val evaluateParamTypes: List[NodeInfo.Kind] = paramTypes.map { c => 
NodeInfo.fromClass(c) }.toList
+          val evaluateReturnType = NodeInfo.fromClass(retType)
 
 Review comment:
   This is my concern as well. 
   
   As far as I know the Expression compiler does type checking of its types of 
the values (i.e the args or the return) and compares NodeInfo.Kind to 
NodeInfo.Kind. We are attempting to convert the type of the UDF params i.e in 
the example above MyCustomType to NodeInfo.Kind, since type checking doesn't do 
Class[_] to NodeInfo.Kind. If we fail to do the conversion (which is what the 
proposed solution is referencing), we won't even get to the type checking of 
the param/return value types the expression compiler does. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to