1

我想在 DolphinDB 的流聚合器中使用用户定义的函数。

但是它返回一个异常,我不知道如何处理它:

def mymid(vec){
    return (first(vec) + last(vec))/2
}
share streamTable(10000:0, `time`device`metric, [TIMESTAMP, SYMBOL, DOUBLE] as sensor
output = table(10000:0, `time`mymid, [TIMESTAMP, DOUBLE]);
aggregator = createStreamAggregator("aggregator", 120, 60, <mymid(metric)>, sensor, output, `time)


execution was completed with exception
Usage: createStreamAggregator(name, windowSize, step, metrics, dummyTable, outputTable, timeColumn, [useSystemTime=false], [keyColumn], [garbageSize]). 
the outermost meta code must be aggregated functions.

显然mymid是一个聚合函数。我的问题是如何在 DolphinDB 中创建聚合的用户定义函数?

4

1 回答 1

0

使用关键字defg而不是关键字def来表示聚合函数

defg mymid(vec){
    return (first(vec) + last(vec))/2
}
于 2019-06-07T04:06:50.740 回答