Closed tunix closed 4 years ago
SELECT AVG(sum_sessionDurationInMs / "count") FROM events WHERE __time >= '2020-02-27' and __time < '2020-02-28'
When above query is translated to native JSON query, it converts sum_sessionDurationInMs / "count" into an expression and sets it into an aggregator:
sum_sessionDurationInMs / "count"
{ "queryType": "timeseries", "dataSource": { "type": "table", "name": "events" }, "intervals": { "type": "intervals", "intervals": [ "2020-02-27T00:00:00.000Z/2020-02-28T00:00:00.000Z" ] }, "descending": false, "virtualColumns": [], "filter": null, "granularity": { "type": "all" }, "aggregations": [ { "type": "longSum", "name": "a0:sum", "fieldName": null, "expression": "(\"sum_sessionDurationInMs\" / \"count\")" }, { "type": "count", "name": "a0:count" } ], "postAggregations": [ { "type": "arithmetic", "name": "a0", "fn": "quotient", "fields": [ { "type": "fieldAccess", "name": null, "fieldName": "a0:sum" }, { "type": "fieldAccess", "name": null, "fieldName": "a0:count" } ], "ordering": null } ], "limit": 2147483647, "context": { "skipEmptyBuckets": true, "sqlOuterLimit": 100, "sqlQueryId": "5f8a13ff-1863-44fd-a2d1-8d96172cfae6" } }
Hey, thanks for your contribution.
Next steps :
@abhi-zapr thanks for your comments. I've updated the PR as you requested. Please check.
When above query is translated to native JSON query, it converts
sum_sessionDurationInMs / "count"
into an expression and sets it into an aggregator: