op:uda( $outCol as item(), $inCol as item(), $module-path as xs:string, $func-name as xs:string, [$options as map:map?] ) as map:map
This function processes the values of column for each row in the group or row set with the specified user-defined aggregate as implemented by an aggregate user-defined function (UDF) plugin. The UDF plugin must be installed on each host. The result is used for building the parameters used by the op:group-by function.
For more information on UDF functions, see Aggregate User-Defined Functions in the Application Developer's Guide.
xquery version '1.0-ml'; import module namespace op = 'http://marklogic.com/optic' at 'MarkLogic/optic.xqy'; let $plan1 := op:from-view('main', 'employees') => op:order-by(op:schema-col('main', 'employees', 'EmployeeID')) let $plan2 := op:from-view('main', 'expenses') => op:order-by(op:schema-col('main', 'expenses' , 'EmployeeID')) return op:join-inner($plan1, $plan2) => op:where( op:eq( op:schema-col('main', 'employees' , 'EmployeeID'), op:schema-col('main', 'expenses', 'EmployeeID') ) ) => op:group-by(op:schema-col('main', 'employees', 'EmployeeID'), op:uda('DetailSum', op:schema-col('main', 'expenses', 'Amount'), 'sampleplugin/sampleplugin', 'sum')) => op:order-by(op:desc(op:col('DetailSum'))) => op:result()