@malloydata/malloy 0.0.98 → 0.0.99-dev231101201548
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.
|
@@ -89,6 +89,9 @@ class ReferenceField extends space_field_1.SpaceField {
|
|
|
89
89
|
e: [{ type: 'field', path }],
|
|
90
90
|
annotation,
|
|
91
91
|
};
|
|
92
|
+
if ((0, malloy_types_1.hasExpression)(origFd)) {
|
|
93
|
+
newField.expressionType = origFd.expressionType;
|
|
94
|
+
}
|
|
92
95
|
return newField;
|
|
93
96
|
}
|
|
94
97
|
// maybe ok, this likely is some field which cannot be referenced
|
|
@@ -616,5 +616,26 @@ describe('query operation annotations', () => {
|
|
|
616
616
|
expect(note_b === null || note_b === void 0 ? void 0 : note_b.annotation).matchesAnnotation({ inherits: defaultTags });
|
|
617
617
|
}
|
|
618
618
|
});
|
|
619
|
+
test('annotated references to measures on join preserve expression type', () => {
|
|
620
|
+
const m = (0, test_translator_1.model) `
|
|
621
|
+
source: na is a extend {
|
|
622
|
+
measure:
|
|
623
|
+
one_count is sum(pick 1 when ai = 1 else 0)
|
|
624
|
+
pct_one is one_count / count();
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
run: na extend {
|
|
628
|
+
join_many: na on ai = na.ai
|
|
629
|
+
} -> {
|
|
630
|
+
group_by: ai
|
|
631
|
+
aggregate:
|
|
632
|
+
# percent
|
|
633
|
+
na.pct_one
|
|
634
|
+
}`;
|
|
635
|
+
expect(m).toTranslate();
|
|
636
|
+
const q = m.translator.queryList[0];
|
|
637
|
+
const fields = q.pipeline[0].fields;
|
|
638
|
+
expect(fields[1]).toMatchObject({ expressionType: 'aggregate' });
|
|
639
|
+
});
|
|
619
640
|
});
|
|
620
641
|
//# sourceMappingURL=annotation.spec.js.map
|
|
@@ -269,10 +269,9 @@ export declare function expressionIsAnalytic(e: ExpressionType | undefined): boo
|
|
|
269
269
|
export declare function isExpressionTypeLEQ(e1: ExpressionType, e2: ExpressionType): boolean;
|
|
270
270
|
export declare function maxExpressionType(e1: ExpressionType, e2: ExpressionType): ExpressionType;
|
|
271
271
|
export declare function maxOfExpressionTypes(types: ExpressionType[]): ExpressionType;
|
|
272
|
-
|
|
272
|
+
type HasExpression = FieldDef & Expression & {
|
|
273
273
|
e: Expr;
|
|
274
|
-
}
|
|
275
|
-
type HasExpression = FieldDef & JustExpression;
|
|
274
|
+
};
|
|
276
275
|
/** Grants access to the expression property of a FieldDef */
|
|
277
276
|
export declare function hasExpression(f: FieldDef): f is HasExpression;
|
|
278
277
|
export type TimeFieldType = 'date' | 'timestamp';
|