Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Understanding Druid Plywood queries for filtering, binning aggregating data

Ganesh Iyer edited this page Feb 5, 2018 · 2 revisions

Filtering

    for(var f in query){
        var filterval = query[f];

        if(typeof filterval == "string"){
            F = F.and($(f).is(filterval)); //exact match
        } else if (typeof filterval == "object") {
            F = F.and($(f).in(filterval)); //range match
        }

    }
    var filters =     $('wiki').filter(F); //apply filters

Categorical aggregations


    for(var i in aggregations){
        var attribute = aggregations[i];
        ex = ex.apply(attribute, $('wiki').split("$"+attribute, attribute)
                .apply("Count", $('wiki').count()).sort('$Count', 'descending').limit(10));
    }   
    //ex = ex.apply("added",$("wiki").apply("ad", ($('added').numberBucket(10))));

Binning aggregation

to bin an attribute with a given binFactor

.split(("$"+attribute, attribute).numberBucket(binFactor), attribute)