Skip to content

Commit

Permalink
fix notes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Feb 24, 2025
1 parent 84743f7 commit 063c5fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -1485,23 +1485,22 @@ export class BaseQuery {
}

// We can't do meaningful query if few time dimensions with different ranges passed,
// it won't be possible to join them together without loosing some rows.
// it won't be possible to join them together without losing some rows.
const rangedTimeDimensions = this.timeDimensions.filter(d => d.dateRange && d.granularity);
const uniqTimeDimensionWithRanges = R.uniqBy(d => d.dateRange, rangedTimeDimensions);
if (uniqTimeDimensionWithRanges.length > 1) {
throw new Error('Can\'t build query for time dimensions with different date ranges');
}

// We need to generate time series table for the lowest granularity among all time dimensions
let dateSeriesDimension;
const dateSeriesGranularity = this.timeDimensions.filter(d => d.granularity)
.reduce((acc, d) => {
const mg = this.minGranularity(acc, d.resolvedGranularity());
const [dateSeriesDimension, dateSeriesGranularity] = this.timeDimensions.filter(d => d.granularity)
.reduce(([prevDim, prevGran], d) => {
const mg = this.minGranularity(prevGran, d.resolvedGranularity());
if (mg === d.resolvedGranularity()) {
dateSeriesDimension = d;
return [d, mg];
}
return mg;
}, undefined);
return [prevDim, mg];
}, [null, null]);

const dateSeriesSql = this.dateSeriesSql(dateSeriesDimension);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class BaseTimeDimension extends BaseFilter {
return this.query.escapeColumnName(`${this.dimension}_series`);
}

public dateSeriesSelectColumn(dateSeriesAliasName: string, dateSeriesGranularity: string) {
public dateSeriesSelectColumn(dateSeriesAliasName: string | null, dateSeriesGranularity?: string) {
if (!this.granularityObj) {
return null;
}
Expand Down

0 comments on commit 063c5fe

Please sign in to comment.