
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.
| Parameters | |
|---|---|
| $outCol | The name to be used for the aggregated column. |
| $inCol | The column to be aggregated. The column can be named with a string or a column function such as op:col, op:view-col, or op:schema-col, or constructed from an expression with the op:as function. |
| $module-path | The path to the installed plugin module. |
| $func-name | The name of the UDF function. |
| $options |
The options can take a values key with a 'distinct' value to aggregate the distinct
values of the column and an arg key specifying an argument for the
user-defined aggregate. The value can be a string or placeholder parameter.
|
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()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.