Skip to content

Commit 882a7df

Browse files
committed
fix: Real time partitions seal just after created
1 parent bd45720 commit 882a7df

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,12 +1571,12 @@ export class PreAggregationPartitionRangeLoader {
15711571
);
15721572
const [_, buildRangeEnd] = buildRange;
15731573
const loadRange: [string, string] = [...range];
1574-
if (buildRangeEnd < range[1]) {
1575-
loadRange[1] = buildRangeEnd;
1576-
}
15771574
const sealAt = addSecondsToLocalTimestamp(
15781575
loadRange[1], this.preAggregation.timezone, this.preAggregation.updateWindowSeconds || 0
15791576
).toISOString();
1577+
if (buildRangeEnd < range[1]) {
1578+
loadRange[1] = buildRangeEnd;
1579+
}
15801580
return {
15811581
...this.preAggregation,
15821582
tableName: partitionTableName,

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ class ExternalMockDriver extends MockDriver {
130130
}
131131

132132
async uploadTableWithIndexes(table, columns, tableData, indexesSql, uniqueKeyColumns, queryTracingObj, externalOptions) {
133-
this.tablesObj.push({ tableName: table.substring(0, 100), buildRangeEnd: queryTracingObj?.buildRangeEnd });
133+
this.tablesObj.push({
134+
tableName: table.substring(0, 100),
135+
buildRangeEnd: queryTracingObj?.buildRangeEnd,
136+
sealAt: externalOptions?.sealAt
137+
});
134138
if (tableData.csvFile) {
135139
this.csvFiles.push(tableData.csvFile);
136140
}
@@ -1224,6 +1228,7 @@ describe('QueryOrchestrator', () => {
12241228
expect(result.data[0]).not.toMatch(/orders_h2021053000/);
12251229
expect(result.data[0]).toMatch(/orders_h2021053100/);
12261230
expect(result.data[0]).toMatch(/orders_h2021060100_uozkyaur_d004iq51/);
1231+
expect(externalMockDriver.tablesObj.find(t => t.tableName.indexOf('stb_pre_aggregations.orders_h2021060100') !== -1).sealAt).toBe('2021-06-01T00:59:59.999Z');
12271232

12281233
result = await queryOrchestrator.fetchQuery(query(['2021-05-31T00:00:00.000', '2021-05-31T23:59:59.999']));
12291234
console.log(JSON.stringify(result, null, 2));

0 commit comments

Comments
 (0)