implydata / plywood

A toolkit for querying and interacting with Big Data

Home Page:https://plywood.imply.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plywood and Druid zero-fill on timeseries queries

viniciusbo opened this issue · comments

Hi! I'm new to Plywood framework. I'm using it to query a Druid database.

Suppose I want to count how many clicks certain link had from day 2019-10-1 until 2019-10-07 but some days don't have any data to show. How could I fill those missing days? I initially thought the operator.timeRange() would achieve that, but I guess I was wrong.

Any help is appreciated. Thanks in advance.

Edit: as I can see zero-filling is done by Druid, but I can't get those values returned from Plywood.

This is what I've been trying so far:

const { $, External } = require('plywood');
const { druidRequesterFactory } = require('plywood-druid-requester');

const druidRequester = druidRequesterFactory({
  host: '192.168.0.108:8082',
});

const dataset = External.fromJS({
  engine: 'druid',
  source: 'clicks',
  timeAttribute: '__time',
  query: {
    queryType: 'timeseries',
  },
  context: {
    skipEmptyBuckets: false,
  }
}, druidRequester);

const context = { clicks: dataset };

const ex = $('clicks')
  .filter($('__time').in({
    start: new Date('2019-10-01T00:00:00Z'),
    end: new Date('2019-11-01T00:00:00Z'),
  }))
  .split($('__time').timeBucket('P1D'), 'day')
  .apply('count', $('clicks').sum($('count')))

As plywood-druid-requester docs seems outdated I was wondering how to send timeseries queries to Druid. Is this right?