Skip to content

Commit

Permalink
fix: TypeError: Cannot read property \'replace\' of null for `schedul…
Browse files Browse the repository at this point in the history
…edRefresh: true`

Fixes #558
  • Loading branch information
paveltiunov committed Apr 2, 2020
1 parent af07865 commit 28e45c0
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/cubejs-schema-compiler/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -1681,8 +1681,8 @@ class BaseQuery {
const timeDimension = this.newTimeDimension(references.timeDimensions[0]);

return this.evaluateSymbolSqlWithContext(() => [
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.cube(), timeDimension, 'min')),
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.cube(), timeDimension, 'max'))
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.path()[0], timeDimension, 'min')),
this.paramAllocator.buildSqlAndParams(this.aggSelectForDimension(timeDimension.path()[0], timeDimension, 'max'))
], { preAggregationQuery: true });
}

Expand Down
47 changes: 47 additions & 0 deletions packages/cubejs-schema-compiler/test/PreAggregationsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ describe('PreAggregations', function test() {
auto: {
type: 'autoRollup',
maxPreAggregations: 20
},
partitioned: {
type: 'rollup',
measureReferences: [count],
timeDimensionReference: EveryHourVisitors.createdAt,
granularity: 'day',
partitionGranularity: 'month',
scheduledRefresh: true,
refreshKey: {
every: '1 hour',
incremental: true,
updateWindow: '1 day'
}
}
}
})
Expand Down Expand Up @@ -471,6 +484,40 @@ describe('PreAggregations', function test() {
});
});

it('partitioned scheduled refresh', () => {
return compiler.compile().then(async () => {
const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
measures: [
'visitor_checkins.count'
],
timeDimensions: [{
dimension: 'EveryHourVisitors.createdAt',
granularity: 'day',
dateRange: ['2017-01-01', '2017-01-25']
}],
timezone: 'America/Los_Angeles',
order: [{
id: 'EveryHourVisitors.createdAt'
}],
preAggregationsSchema: ''
});

const preAggregations = cubeEvaluator.scheduledPreAggregations();
const partitionedPreAgg =
preAggregations.find(p => p.preAggregationName === 'partitioned' && p.cube === 'visitor_checkins');

const minMaxQueries = query.preAggregationStartEndQueries('visitor_checkins', partitionedPreAgg.preAggregation);

console.log(minMaxQueries);

const res = await dbRunner.testQueries(minMaxQueries);

res.should.be.deepEqual(
[{ max: '2017-01-06T00:00:00.000Z' }]
);
});
});

it('mutable partition default refreshKey', () => {
return compiler.compile().then(() => {
const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
Expand Down

0 comments on commit 28e45c0

Please sign in to comment.