zapr-oss / druidry

Java based Druid Query Generator library
Apache License 2.0
193 stars 86 forks source link

Is postAggregations type "expression" not supported? #142

Open FuleChu opened 4 years ago

FuleChu commented 4 years ago

Through the 'case when' statement of /console/druid/ page, json is obtained: { "queryType": "groupBy", "dataSource": { "type": "table", "name": "dw_action_sec_data_test" }, "intervals": { "type": "intervals", "intervals": [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ] }, "virtualColumns": [], "filter": null, "granularity": { "type": "all" }, "dimensions": [ { "type": "default", "dimension": "actionId", "outputName": "d0", "outputType": "LONG" }, { "type": "default", "dimension": "applicationId", "outputName": "d1", "outputType": "LONG" } ], "aggregations": [ { "type": "count", "name": "a0" }, { "type": "longSum", "name": "a1", "fieldName": "reqCount", "expression": null }, { "type": "longSum", "name": "a2", "fieldName": "errorCount", "expression": null } ], "postAggregations": [ { "type": "expression", "name": "p0", "expression": "case_searched(((\"a1\" - \"a2\") > 1),1,11110)", "ordering": null } ], "having": null, "limitSpec": { "type": "default", "columns": [], "limit": 100 }, "context": { "sqlOuterLimit": 100, "sqlQueryId": "d45d2637-1a15-43aa-9e6f-fe86a7b281f7" }, "descending": false } It is found that the type of postAggregations is' expression ', but no corresponding type has been found in druidry. Is this type not supported?Or did I not find the right class?

abhi-zapr commented 4 years ago

I was trying to find expression type post aggregator in druid documentation, I was not able to find. May be that's why it's not implemented yet in library.

But then I checked druid sources, it's there at org.apache.druid.query.aggregation.post.ExpressionPostAggregator and we can include it. If you are interested you can raise a patch for expression post aggregator.