Skip to content

Commit

Permalink
fix(schema-compiler): throw an error for the empty pre-aggs (#5392)
Browse files Browse the repository at this point in the history
  • Loading branch information
buntarb authored Sep 30, 2022
1 parent 94b6509 commit 4afd604
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions packages/cubejs-schema-compiler/src/compiler/CubeSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,28 @@ export class CubeSymbols {
transformPreAggregations(preAggregations) {
// eslint-disable-next-line no-restricted-syntax
for (const preAggregation of Object.values(preAggregations)) {
// Rollup is a default type for pre-aggregations
if (!preAggregation.type) {
preAggregation.type = 'rollup';
}
// We don't want to set the defaults for the empty pre-aggs because
// we want to throw instead.
if (Object.keys(preAggregation).length > 0) {
// Rollup is a default type for pre-aggregations
if (!preAggregation.type) {
preAggregation.type = 'rollup';
}

if (preAggregation.scheduledRefresh === undefined && preAggregation.type !== 'rollupJoin' && preAggregation.type !== 'rollupLambda') {
preAggregation.scheduledRefresh = getEnv('scheduledRefreshDefault');
}
if (preAggregation.scheduledRefresh === undefined && preAggregation.type !== 'rollupJoin' && preAggregation.type !== 'rollupLambda') {
preAggregation.scheduledRefresh = getEnv('scheduledRefreshDefault');
}

if (preAggregation.external === undefined && preAggregation.type !== 'rollupLambda') {
preAggregation.external =
// TODO remove rollupJoin from this list and update validation
['rollup', 'rollupJoin'].includes(preAggregation.type) &&
getEnv('externalDefault');
}
if (preAggregation.external === undefined && preAggregation.type !== 'rollupLambda') {
preAggregation.external =
// TODO remove rollupJoin from this list and update validation
['rollup', 'rollupJoin'].includes(preAggregation.type) &&
getEnv('externalDefault');
}

if (preAggregation.indexes) {
this.transformPreAggregationIndexes(preAggregation.indexes);
if (preAggregation.indexes) {
this.transformPreAggregationIndexes(preAggregation.indexes);
}
}
}
}
Expand Down

0 comments on commit 4afd604

Please sign in to comment.