Fields in Post-Aggregates

190 views
Skip to first unread message

Brian O'Neill

unread,
Aug 19, 2013, 2:03:00 PM8/19/13
to druid-de...@googlegroups.com
Can you use any field name in a post-aggregation or just aggregates?

iI have this event coming back as the result of a query:
{
  "version" : "v1",
  "timestamp" : "2013-08-19T00:00:00.000Z",
  "event" : {
    "totalcount" : 92918,
    "searchphrase" : "apple jobs",
    "relevance" : 1.0,
    "word" : "your",
    "baseline" : "834953"
  }


I'm trying to divide totalcount by baseline w/ the following:
"postAggregations": [{
       "type": "arithmetic",
       "name": "relevance",
       "fn": "/",
       "fields": [
            { "type": "fieldAccess", "fieldName": "totalcount" },
            { "type": "fieldAccess", "fieldName": "baseline" }
       ]
     }],

This results in:
Instantiation of [simple type, class com.metamx.druid.query.group.GroupByQuery] value failed: Missing fields [[baseline]] for postAggregator [relevance]

But the same works if I s/baseline/totalcount/g.
What am I missing?  It looks like the type of baseline might be a String?  (is that the issue?)

I'm constructing the row with:
        Long baseline = (Long) tuple.getValue(3);
        theMap.put("baseline", baseline);

-brian

--
Brian ONeill
Chief Architect, Health Market Science (http://healthmarketscience.com)
mobile:215.588.6024
blog: http://brianoneill.blogspot.com/
twitter: @boneill42

Brian O'Neill

unread,
Aug 19, 2013, 2:21:17 PM8/19/13
to druid-de...@googlegroups.com
BTW -- this isn't an issue for me. 
When I create an aggregate called baseline, things work as expected.

It just might confuse people.  When users create rows that contain a dimension which has a numeric value and they see it in the rows returned by a query, they may get confused as to why they can't use it in a post-aggregation.

-brian

Fangjin Yang

unread,
Aug 19, 2013, 2:38:14 PM8/19/13
to druid-de...@googlegroups.com
Right now for post aggregations you must include the aggregations you want to use in the post aggregation as part of the query. Druid will thrown an exception otherwise. You also cannot use a dimension value as part of the post aggregation, you can only use aggregators.

-- FJ


--
You received this message because you are subscribed to the Google Groups "Druid Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to druid-developm...@googlegroups.com.
To post to this group, send email to druid-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/druid-development/CAJHHpg2xaOMfzb1q%2B8KqVE6VQhBCSRc-Gj30T_62_0VXrq3UMw%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages