@malloydata/malloy 0.0.35 → 0.0.36-dev230524213240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -38,15 +38,12 @@ class ExprFilter extends expression_def_1.ExpressionDef {
|
|
|
38
38
|
getExpression(fs) {
|
|
39
39
|
const testList = this.filter.getFilterList(fs);
|
|
40
40
|
const resultExpr = this.expr.getExpression(fs);
|
|
41
|
-
for (const cond of testList) {
|
|
42
|
-
if ((0, malloy_types_1.expressionIsCalculation)(cond.expressionType)) {
|
|
43
|
-
this.filter.log('Cannot filter a field with an aggregate or analytical computation');
|
|
44
|
-
return (0, ast_utils_1.errorFor)('no filter on aggregate');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
41
|
if (resultExpr.expressionType === 'scalar') {
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
this.expr.log('Filtered expression requires an aggregate computation');
|
|
43
|
+
return resultExpr;
|
|
44
|
+
}
|
|
45
|
+
if (testList.find(cond => (0, malloy_types_1.expressionIsCalculation)(cond.expressionType))) {
|
|
46
|
+
this.filter.log('Cannot filter an expresion with an aggregate or analytical computation');
|
|
50
47
|
return resultExpr;
|
|
51
48
|
}
|
|
52
49
|
if (this.typeCheck(this.expr, { ...resultExpr, expressionType: 'scalar' })) {
|
|
@@ -682,6 +682,10 @@ describe('expressions', () => {
|
|
|
682
682
|
});
|
|
683
683
|
});
|
|
684
684
|
test('filtered measure', exprOK("acount {? astr = 'why?' }"));
|
|
685
|
+
test('correctly flags filtered scalar', () => {
|
|
686
|
+
const e = new test_translator_1.BetaExpression('ai { where: true }');
|
|
687
|
+
expect(e).compileToFailWith('Filtered expression requires an aggregate computation');
|
|
688
|
+
});
|
|
685
689
|
describe('aggregate forms', () => {
|
|
686
690
|
test('count', exprOK('count()'));
|
|
687
691
|
test('count distinct', exprOK('count(distinct astr)'));
|