Skip to content

Commit

Permalink
[fix] Time filter: Add padding if min/max values are the same (UN-245…
Browse files Browse the repository at this point in the history
…8) (#409)

* [fix] Time filter: Add padding if min/max values are the same (UN-2458)

Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
mletic authored and igorDykhta committed Oct 17, 2022
1 parent 791bbe2 commit f9eee7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/table/src/filter-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,10 @@ export function getTimestampFieldDomain(
let step = 0.01;

const diff = domain[1] - domain[0];
// in case equal timestamp add 1 second padding to prevent break
if (!diff) {
domain[1] = domain[0] + 1000;
}
const entry = TimestampStepMap.find(f => f.max >= diff);
if (entry) {
step = entry.step;
Expand Down
2 changes: 1 addition & 1 deletion test/node/utils/filter-utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ test('filterUtils -> getTimestampFieldDomain', t => {
zero: {
input: ['2016-10-01 09:45:39', '2016-10-01 09:45:39'],
expect: {
domain: [1475315139000, 1475315139000],
domain: [1475315139000, 1475315140000],
mappedValue: [1475315139000, 1475315139000],
histogram: [{count: 2, x0: 1475315139000, x1: 1475315139000}],
enlargedHistogram: [{count: 2, x0: 1475315139000, x1: 1475315139000}],
Expand Down

0 comments on commit f9eee7c

Please sign in to comment.