Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ export class YamlCompiler {
if (memberType === 'preAggregation' && indexes) {
indexes = this.yamlArrayToObj(indexes || [], `${memberType}.index`, errorsReport);
}

if (!name) {
errorsReport.error(`name isn't defined for ${memberType}: ${YAML.stringify(rest)}`);
errorsReport.error(`name isn't defined for ${memberType}: ${JSON.stringify(rest)}`);
return {};
} else if (indexes) {
return { [name]: { indexes, ...rest } };
Expand Down
21 changes: 21 additions & 0 deletions packages/cubejs-schema-compiler/test/unit/yaml-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,25 @@ describe('Yaml Schema Testing', () => {
expect(e.message).toContain('Unexpected input during yaml transpiling: null');
}
});

it('unammed measure', async () => {
const { compiler } = prepareYamlCompiler(
`cubes:
- name: Users
sql: SELECT * FROM e2e.users
dimensions:
- sql: id
type: number
primaryKey: true
`
);

try {
await compiler.compile();

throw new Error('compile must return an error');
} catch (e: any) {
expect(e.message).toContain('name isn\'t defined for dimension: ');
}
});
});