Skip to content

Commit 28e45c0

Browse files
committed
fix: TypeError: Cannot read property \'replace\' of null for scheduledRefresh: true
Fixes #558
1 parent af07865 commit 28e45c0

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

packages/cubejs-schema-compiler/adapter/BaseQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,8 +1681,8 @@ class BaseQuery {
16811681
const timeDimension = this.newTimeDimension(references.timeDimensions[0]);
16821682

16831683
return this.evaluateSymbolSqlWithContext(() => [
1684-
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.cube(), timeDimension, 'min')),
1685-
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.cube(), timeDimension, 'max'))
1684+
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.path()[0], timeDimension, 'min')),
1685+
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.path()[0], timeDimension, 'max'))
16861686
], { preAggregationQuery: true });
16871687
}
16881688

packages/cubejs-schema-compiler/test/PreAggregationsTest.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ describe('PreAggregations', function test() {
178178
auto: {
179179
type: 'autoRollup',
180180
maxPreAggregations: 20
181+
},
182+
partitioned: {
183+
type: 'rollup',
184+
measureReferences: [count],
185+
timeDimensionReference: EveryHourVisitors.createdAt,
186+
granularity: 'day',
187+
partitionGranularity: 'month',
188+
scheduledRefresh: true,
189+
refreshKey: {
190+
every: '1 hour',
191+
incremental: true,
192+
updateWindow: '1 day'
193+
}
181194
}
182195
}
183196
})
@@ -471,6 +484,40 @@ describe('PreAggregations', function test() {
471484
});
472485
});
473486

487+
it('partitioned scheduled refresh', () => {
488+
return compiler.compile().then(async () => {
489+
const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
490+
measures: [
491+
'visitor_checkins.count'
492+
],
493+
timeDimensions: [{
494+
dimension: 'EveryHourVisitors.createdAt',
495+
granularity: 'day',
496+
dateRange: ['2017-01-01', '2017-01-25']
497+
}],
498+
timezone: 'America/Los_Angeles',
499+
order: [{
500+
id: 'EveryHourVisitors.createdAt'
501+
}],
502+
preAggregationsSchema: ''
503+
});
504+
505+
const preAggregations = cubeEvaluator.scheduledPreAggregations();
506+
const partitionedPreAgg =
507+
preAggregations.find(p => p.preAggregationName === 'partitioned' && p.cube === 'visitor_checkins');
508+
509+
const minMaxQueries = query.preAggregationStartEndQueries('visitor_checkins', partitionedPreAgg.preAggregation);
510+
511+
console.log(minMaxQueries);
512+
513+
const res = await dbRunner.testQueries(minMaxQueries);
514+
515+
res.should.be.deepEqual(
516+
[{ max: '2017-01-06T00:00:00.000Z' }]
517+
);
518+
});
519+
});
520+
474521
it('mutable partition default refreshKey', () => {
475522
return compiler.compile().then(() => {
476523
const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {

0 commit comments

Comments
 (0)