Skip to content

Commit cb6f4bb

Browse files
committed
chore(schema-compiler)!: Drop support for top-level includes/excludes in views
1 parent 452633c commit cb6f4bb

File tree

3 files changed

+4
-68
lines changed

3 files changed

+4
-68
lines changed

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

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export class CubeSymbols {
273273
}
274274

275275
protected prepareIncludes(cube: CubeDefinition, errorReporter: ErrorReporter, splitViews: SplitViews) {
276-
if (!cube.includes && !cube.cubes) {
276+
if (!cube.cubes) {
277277
return;
278278
}
279279

@@ -314,18 +314,8 @@ export class CubeSymbols {
314314
cubeIncludes = this.membersFromCubes(cube, cubes, type, errorReporter, splitViews, memberSets) || [];
315315
}
316316

317-
// This is the deprecated approach
318-
const includes = cube.includes && this.membersFromIncludeExclude(cube.includes, cube.name, type) || [];
319-
const excludes = cube.excludes && this.membersFromIncludeExclude(cube.excludes, cube.name, type) || [];
320-
321-
// cube includes will take precedence in case of member clash
322-
const finalIncludes = this.diffByMember(
323-
this.diffByMember(includes, cubeIncludes).concat(cubeIncludes),
324-
excludes
325-
);
326-
327317
if (type === 'hierarchies') {
328-
for (const member of finalIncludes) {
318+
for (const member of cubeIncludes) {
329319
const path = member.member.split('.');
330320
const cubeName = path[path.length - 2];
331321
const hierarchyName = path[path.length - 1];
@@ -339,10 +329,10 @@ export class CubeSymbols {
339329
}
340330
}
341331

342-
const includeMembers = this.generateIncludeMembers(finalIncludes, cube.name, type);
332+
const includeMembers = this.generateIncludeMembers(cubeIncludes, cube.name, type);
343333
this.applyIncludeMembers(includeMembers, cube, type, errorReporter);
344334

345-
cube.includedMembers = [...(cube.includedMembers || []), ...Array.from(new Set(finalIncludes.map((it: any) => {
335+
cube.includedMembers = [...(cube.includedMembers || []), ...Array.from(new Set(cubeIncludes.map((it: any) => {
346336
const split = it.member.split('.');
347337
const memberPath = this.pathFromArray([split[split.length - 2], split[split.length - 1]]);
348338
return {
@@ -453,22 +443,6 @@ export class CubeSymbols {
453443
return includes.filter(include => !excludesMap.has(include.member));
454444
}
455445

456-
protected membersFromIncludeExclude(referencesFn: any, cubeName: string, type: string) {
457-
const references = this.evaluateReferences(cubeName, referencesFn);
458-
return R.unnest(references.map((ref: string) => {
459-
const path = ref.split('.');
460-
if (path.length === 1) {
461-
const membersObj = this.symbols[path[0]]?.cubeObj()?.[type] || {};
462-
return Object.keys(membersObj).map(memberName => ({ member: `${ref}.${memberName}` }));
463-
} else if (path.length === 2) {
464-
const resolvedMember = this.getResolvedMember(type, path[0], path[1]);
465-
return resolvedMember ? [{ member: ref }] : undefined;
466-
} else {
467-
throw new Error(`Unexpected path length ${path.length} for ${ref}`);
468-
}
469-
})).filter(Boolean);
470-
}
471-
472446
protected getResolvedMember(type: string, cubeName: string, memberName: string) {
473447
return this.symbols[cubeName]?.cubeObj()?.[type]?.[memberName];
474448
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,6 @@ const cubeSchema = inherit(baseSchema, {
779779

780780
const viewSchema = inherit(baseSchema, {
781781
isView: Joi.boolean().strict(),
782-
includes: Joi.func(),
783-
excludes: Joi.func(),
784782
cubes: Joi.array().items(
785783
Joi.object().keys({
786784
joinPath: Joi.func().required(),

packages/cubejs-schema-compiler/test/unit/views.test.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -391,42 +391,6 @@ describe('Views YAML', () => {
391391
});
392392
});
393393

394-
it('includes * (legacy)', async () => {
395-
const { cubeEvaluator } = await schemaCompile([{
396-
name: 'simple_view',
397-
includes: [
398-
'CubeA.id',
399-
// conflict
400-
// 'CubeB.id',
401-
'CubeB.other_id',
402-
]
403-
}]);
404-
405-
expect(cubeEvaluator.getCubeDefinition('simple_view').dimensions).toEqual({
406-
id: dimensionFixtureForCube('CubeA.id'),
407-
other_id: dimensionFixtureForCube('CubeB.other_id'),
408-
});
409-
});
410-
411-
it('includes * (legacy) + exclude b.id', async () => {
412-
const { cubeEvaluator } = await schemaCompile([{
413-
name: 'simple_view',
414-
includes: [
415-
'CubeA.id',
416-
'CubeB.id',
417-
'CubeB.other_id',
418-
],
419-
excludes: [
420-
'CubeB.id'
421-
]
422-
}]);
423-
424-
expect(cubeEvaluator.getCubeDefinition('simple_view').dimensions).toEqual({
425-
id: dimensionFixtureForCube('CubeA.id'),
426-
other_id: dimensionFixtureForCube('CubeB.other_id'),
427-
});
428-
});
429-
430394
it('throws error for unresolved members', async () => {
431395
const { compiler } = prepareYamlCompiler(`
432396
cubes:

0 commit comments

Comments
 (0)