Skip to content

Commit

Permalink
fix(schema-compiler): Warn when COUNT(*) is referenced in a view wh…
Browse files Browse the repository at this point in the history
…ere `count` is not defined
  • Loading branch information
MazterQyou committed Sep 11, 2024
1 parent cdfbd1e commit 56488a5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,9 @@ export class BaseQuery {
if (m.expressionName && !collectedMeasures.length && !m.isMemberExpression) {
throw new UserError(`Subquery dimension ${m.expressionName} should reference at least one measure`);
}
if (!collectedMeasures.length && m.isMemberExpression && m.query.allCubeNames.length > 1 && m.measureSql() === "COUNT(*)") {
throw new UserError('COUNT(*) is referenced in a view where `count` is not defined');
}
return [m.measure, collectedMeasures];
}));
}
Expand Down

0 comments on commit 56488a5

Please sign in to comment.