Skip to content

Commit 54083ef

Browse files
committed
fix: Return single table for one partition queries
1 parent bf8b648 commit 54083ef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,18 @@ class PreAggregations {
540540
partitionUnion(preAggregationForQuery, withoutAlias) {
541541
const { dimension, partitionDimension } = this.partitionDimension(preAggregationForQuery);
542542

543-
const union = partitionDimension.timeSeries().map(range => {
543+
const tables = partitionDimension.timeSeries().map(range => {
544544
const preAggregation = this.addPartitionRangeTo(preAggregationForQuery, dimension, range);
545545
return this.preAggregationTableName(
546546
preAggregationForQuery.cube,
547547
preAggregationForQuery.preAggregationName,
548548
preAggregation.preAggregation
549549
);
550-
}).map(table => `SELECT * FROM ${table}`).join(" UNION ALL ");
550+
});
551+
if (tables.length === 1) {
552+
return tables[0];
553+
}
554+
const union = tables.map(table => `SELECT * FROM ${table}`).join(" UNION ALL ");
551555
return `(${union})${withoutAlias ? '' : ' as partition_union'}`;
552556
}
553557
}

0 commit comments

Comments
 (0)