{ "type": "javascript",
"name": "<output_name>",
"fieldNames" : [ <column1>, <column2>, ... ],
"fnAggregate" : "function(current, column1, column2, ...) {
<updates partial aggregate (current) based on the current row values>
return <updated partial aggregate>
}",
"fnCombine" : "function(partialA, partialB) { return <combined partial results>; }",
"fnReset" : "function() { return <initial value>; }"
postAggregation : {
"type" : "arithmetic",
"name" : "metricC",
"fn" : "*",
"fields": [ {"type": "fieldAccess","name": "metricA","fieldName": "metricA"},
{"type": "fieldAccess","name": "metricB","fieldName": "metricB"}
]
}
{
"type": "lessThan",
"aggregation": "Amount",
"value": 500
}
"filter": { "type": "selector", "dimension": "weekday", "value": "Monday"}
postAggregation : {
"type": "javascript",
"name": <output_name>,
"fieldNames" : [<aggregator_name>, <aggregator_name>, ...],
"function": <javascript function>
}a littel below you can find an example
{
"type": "javascript",
"name": "absPercent",
"fieldNames": ["delta", "total"],
"function": "function(delta, total) { return 100 * Math.abs(delta) / total; }"
}--
You received this message because you are subscribed to a topic in the Google Groups "Druid User" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/druid-user/GYXS8LMTOuc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to druid-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/druid-user/91f3bc16-cb89-4044-aaed-b7ac3c85c6c6%40googlegroups.com.
{
"type": "javascript",
"name": "sum(log(x)*y) + 10",
"fieldNames": ["x", "y"],
"fnAggregate" : "function(current, a, b) { return current + (Math.log(a) * b); }",
"fnCombine" : "function(partialA, partialB) { return partialA + partialB; }",
"fnReset" : "function() { return 10; }"
}Let me try to create a JavaScript Aggregator for your example:
{
"type": "javascript",
"name": "revenue_Sum('price/unit' * units)",
"fieldNames": ["price/unit", "units"],
"fnAggregate" : "function(current, a, b) { return current + ('price/unit' * 'units'); }",
"fnCombine" : "function(partialA, partialB) { return partialA + partialB; }",
"fnReset" : "function() { return 0; }"
}I hope I finally could help you a little bit.