Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added expression support to some aggregators #135

Merged
merged 6 commits into from
Mar 22, 2020

Conversation

tunix
Copy link
Contributor

@tunix tunix commented Mar 2, 2020

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:

{
  "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"
  }
}

@abhi-zapr
Copy link
Contributor

Hey, thanks for your contribution.

Next steps :

@abhi-zapr abhi-zapr self-assigned this Mar 14, 2020
@abhi-zapr abhi-zapr added this to the v3.1 milestone Mar 14, 2020
@tunix
Copy link
Contributor Author

tunix commented Mar 17, 2020

@abhi-zapr thanks for your comments. I've updated the PR as you requested. Please check.

@abhi-zapr abhi-zapr merged commit 32ecbbe into zapr-oss:develop Mar 22, 2020
@tunix tunix deleted the expression branch March 23, 2020 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants