Skip to content

Commit 667e95b

Browse files
authored
fix(query-orchestrator): Range intersection for 6 digits timestamp, fix #8320 (#8322)
1 parent b72e77b commit 667e95b

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

packages/cubejs-query-orchestrator/src/orchestrator/PreAggregations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ export class PreAggregationPartitionRangeLoader {
18981898
throw new Error(`Date range expected to be a string array but ${range} found`);
18991899
}
19001900

1901-
if (range[0].length !== 23 || range[1].length !== 23) {
1901+
if ((range[0].length !== 23 && range[0].length !== 26) || (range[1].length !== 23 && range[0].length !== 26)) {
19021902
throw new Error(`Date range expected to be in YYYY-MM-DDTHH:mm:ss.SSS format but ${range} found`);
19031903
}
19041904
}

packages/cubejs-query-orchestrator/test/unit/PreAggregations.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable global-require */
22
/* globals describe, jest, beforeEach, test, expect */
33
import R from 'ramda';
4+
import { PreAggregationPartitionRangeLoader } from '../../src';
45

56
class MockDriver {
67
constructor() {
@@ -369,4 +370,31 @@ describe('PreAggregations', () => {
369370
expect(result[0][1].lastUpdatedAt).toEqual(1893709044209);
370371
});
371372
});
373+
374+
describe('intersectDateRanges', () => {
375+
test('6 timestamps - valid intersection', () => {
376+
expect(PreAggregationPartitionRangeLoader.intersectDateRanges(
377+
['2024-01-05T00:00:00.000000', '2024-01-05T23:59:59.999999'],
378+
['2024-01-01T00:00:00.000000', '2024-01-31T23:59:59.999999'],
379+
)).toEqual(
380+
['2024-01-05T00:00:00.000000', '2024-01-05T23:59:59.999999']
381+
);
382+
383+
expect(PreAggregationPartitionRangeLoader.intersectDateRanges(
384+
['2024-01-20T00:00:00.000000', '2024-02-05T23:59:59.999999'],
385+
['2024-01-01T00:00:00.000000', '2024-01-31T23:59:59.999999'],
386+
)).toEqual(
387+
['2024-01-20T00:00:00.000000', '2024-01-31T23:59:59.999999']
388+
);
389+
});
390+
391+
test('3 timestamps - valid intersection', () => {
392+
expect(PreAggregationPartitionRangeLoader.intersectDateRanges(
393+
['2024-01-05T00:00:00.000', '2024-01-05T23:59:59.999'],
394+
['2024-01-01T00:00:00.000', '2024-01-31T23:59:59.999'],
395+
)).toEqual(
396+
['2024-01-05T00:00:00.000', '2024-01-05T23:59:59.999']
397+
);
398+
});
399+
});
372400
});

packages/cubejs-testing-drivers/fixtures/bigquery.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@
143143
"---------------------------------------",
144144
"Full tests ",
145145
"---------------------------------------",
146-
"must built pre-aggregations",
147146
"querying Customers: dimentions + order + total + offset",
148147
"querying ECommerce: dimentions + order + total + offset",
149148

0 commit comments

Comments
 (0)