Skip to content

Commit

Permalink
fix: Return single table for one partition queries
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Mar 29, 2020
1 parent bf8b648 commit 54083ef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/cubejs-schema-compiler/adapter/PreAggregations.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,18 @@ class PreAggregations {
partitionUnion(preAggregationForQuery, withoutAlias) {
const { dimension, partitionDimension } = this.partitionDimension(preAggregationForQuery);

const union = partitionDimension.timeSeries().map(range => {
const tables = partitionDimension.timeSeries().map(range => {
const preAggregation = this.addPartitionRangeTo(preAggregationForQuery, dimension, range);
return this.preAggregationTableName(
preAggregationForQuery.cube,
preAggregationForQuery.preAggregationName,
preAggregation.preAggregation
);
}).map(table => `SELECT * FROM ${table}`).join(" UNION ALL ");
});
if (tables.length === 1) {
return tables[0];
}
const union = tables.map(table => `SELECT * FROM ${table}`).join(" UNION ALL ");
return `(${union})${withoutAlias ? '' : ' as partition_union'}`;
}
}
Expand Down

0 comments on commit 54083ef

Please sign in to comment.