Skip to content

Allow aggregators to work on dimensions #3004

@vogievetsky

Description

@vogievetsky

I have a numeric dimension commentLength (it is encoded as a string but all the values are numbers)

see: https://github.com/implydata/datazoo/blob/master/druid/wikipedia-index.json#L29

I want to compute the min and max of it but doing this:

    {
      "name": "MaxCommentLength",
      "type": "doubleMax",
      "fieldName": "commentLength"
    }

Gives 0.

Instead I have to do this: (I am not even mad because I ❤️ JS)

    {
      "name": "MaxCommentLength",
      "type": "javascript",
      "fieldNames": [
        "commentLength"
      ],
      "fnAggregate": "function(_c,commentLength) { return Math.max(_c,commentLength); }",
      "fnCombine": "function(a,b) { return Math.max(a,b); }",
      "fnReset": "function() { return -Infinity; }"
    }

Is it possible to have native aggregators auto parse strings as numbers if they are invoked on a dimension?

PS. the motivation for getting the min and max are contentious dimension controls like this:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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