Skip to content

SQL: Support Expressions inside Aggregate Functions #29980

@elasticmachine

Description

@elasticmachine

Original comment by @gingerwizard:

Example:

SELECT AVG(population/number_of_owner_occupied_units) FROM morgages_mapped WHERE state_abbr = 'CA'

This should be achievable by a bucket script agg. This currently fails with:

{
  "error": {
    "root_cause": [
      {
        "type": "sql_illegal_argument_exception",
        "reason": "Does not know how to convert argument Div[] for function Avg[]"
      }
    ],
    "type": "sql_illegal_argument_exception",
    "reason": "Does not know how to convert argument Div[] for function Avg[]"
  },
  "status": 500
}

This potentially unlocks a can of worms so its a placeholder only for discussion.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions