Numeric histogram: Test when start and end are provided but not bins
This commit is contained in:
@@ -108,6 +108,7 @@ module.exports = class NumericHistogram extends BaseHistogram {
|
||||
ctx.irq = `percentile_disc(0.75) within group (order by ${ctx.column})
|
||||
- percentile_disc(0.25) within group (order by ${ctx.column})`;
|
||||
extra_groupby += `, __cdb_basics.__cdb_bins_number`;
|
||||
extra_tables = `, __cdb_basics`;
|
||||
extra_queries = `WITH ${irqQueryTpl(ctx)}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,26 @@ describe('histogram-dataview', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should work with min >= start and max <= end, autodetect bins', function(done) {
|
||||
var params = {
|
||||
start: 50,
|
||||
end: 500
|
||||
};
|
||||
|
||||
this.testClient = new TestClient(mapConfig, 1234);
|
||||
this.testClient.getDataview('pop_max_histogram', params, function(err, dataview) {
|
||||
assert.ok(!err, err);
|
||||
|
||||
assert.ok(6 === dataview.bins_count, 'Unexpected bin count: ' + dataview.bins_count);
|
||||
assert.ok(6 === dataview.bins.length, 'Unexpected number of bins: ' + dataview.bins.length);
|
||||
dataview.bins.forEach(function(bin) {
|
||||
assert.ok(bin.min >= params.start, 'bin min < start: ' + JSON.stringify(bin));
|
||||
assert.ok(bin.max <= params.end, 'bin max > end: ' + JSON.stringify(bin));
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get bin_width right when max > min in filter', function(done) {
|
||||
var params = {
|
||||
bins: 10,
|
||||
|
||||
Reference in New Issue
Block a user