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

Date equality works on Druid but not locally

darabos opened this issue · comments

I noticed this while writing a unit test.

const someDataset = plywood.Dataset.fromJS([
  { cut: 'Good',  price: 400, time: new Date('2015-10-01T00:00:00Z') },
]);
const ex = $('data').filter($('time').is(new Date('2015-10-01T00:00:00Z'))).count();
const r = await ex.compute({ data: someDataset });
console.log(r); // --> 0

I tried sharing the date object between the query and the dataset but it's the same.

const d = new Date('2015-10-01T00:00:00Z');
const someDataset = plywood.Dataset.fromJS([
  { cut: 'Good',  price: 400, time: d },
]);
const ex = $('data').filter($('time').is(d)).count();
const r = await ex.compute({ data: someDataset });
console.log(r); // --> 0

I get the same with equals(new Date(...)) or in([new Date(...)]). But in() works if you share the Date object!

const d = new Date('2015-10-01T00:00:00Z');
const someDataset = plywood.Dataset.fromJS([
  { cut: 'Good',  price: 400, time: d },
]);
const ex = $('data').filter($('time').in([d])).count();
const r = await ex.compute({ data: someDataset });
console.log(r); // --> 1

I think these all work with a Druid backend. I'm not sure what's the right way to do this in unit tests. Thanks for any advice!