Skip to content

Commit eaec97d

Browse files
authored
fix: Support indexes in pre-aggs in yaml (#6587)
* fix: support indexes in pre-aggs in yaml * naming nitpicking
1 parent 803e4a0 commit eaec97d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/cubejs-schema-compiler/src/compiler/YamlCompiler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class YamlCompiler {
7373
cubeObj.measures = this.yamlArrayToObj(cubeObj.measures || [], 'measure', errorsReport);
7474
cubeObj.dimensions = this.yamlArrayToObj(cubeObj.dimensions || [], 'dimension', errorsReport);
7575
cubeObj.segments = this.yamlArrayToObj(cubeObj.segments || [], 'segment', errorsReport);
76-
cubeObj.preAggregations = this.yamlArrayToObj(cubeObj.preAggregations || [], 'segment', errorsReport);
76+
cubeObj.preAggregations = this.yamlArrayToObj(cubeObj.preAggregations || [], 'preAggregation', errorsReport);
7777
cubeObj.joins = this.yamlArrayToObj(cubeObj.joins || [], 'join', errorsReport);
7878

7979
return this.transpileYaml(cubeObj, [], cubeObj.name, errorsReport);
@@ -222,7 +222,10 @@ export class YamlCompiler {
222222
return {};
223223
}
224224

225-
const remapped = yamlArray.map(({ name, ...rest }) => {
225+
const remapped = yamlArray.map(({ name, indexes, ...rest }) => {
226+
if (memberType === 'preAggregation' && indexes) {
227+
indexes = this.yamlArrayToObj(indexes || [], `${memberType}.index`, errorsReport);
228+
}
226229
if (!name) {
227230
errorsReport.error(`name isn't defined for ${memberType}: ${YAML.stringify(rest)}`);
228231
return {};

packages/cubejs-schema-compiler/test/integration/postgres/yaml-compiler.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ cubes:
203203
measures:
204204
- weeklyActive
205205
timeDimension: time
206+
indexes:
207+
- name: weeklyActive
208+
columns:
209+
- weeklyActive
206210
granularity: day
207211
`);
208212
await compiler.compile();

0 commit comments

Comments
 (0)