@malloydata/malloy 0.0.123-dev240209030627 → 0.0.123-dev240209165819

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.
@@ -226,11 +226,12 @@ class ExprFunc extends expression_def_1.ExpressionDef {
226
226
  if (e.found === undefined) {
227
227
  partitionField.log(`${partitionField.refString} is not defined`);
228
228
  }
229
- else if ((0, malloy_types_1.expressionIsScalar)(e.found.typeDesc().expressionType)) {
230
- partitionByFields.push(partitionField.nameString);
229
+ else if ((0, malloy_types_1.expressionIsAnalytic)(e.found.typeDesc().expressionType) ||
230
+ (0, malloy_types_1.expressionIsUngroupedAggregate)(e.found.typeDesc().expressionType)) {
231
+ partitionField.log('Partition expression must be scalar or aggregate');
231
232
  }
232
233
  else {
233
- partitionField.log('Partition expression must be scalar');
234
+ partitionByFields.push(partitionField.nameString);
234
235
  }
235
236
  }
236
237
  }
@@ -215,6 +215,25 @@ describe('expressions', () => {
215
215
  calculate: x is lag(ai) { partition_by: ai; order_by: ai }
216
216
  }
217
217
  `).toTranslate();
218
+ });
219
+ test('partition by works with scalar and aggregate', () => {
220
+ expect((0, test_translator_1.markSource) `
221
+ run: a -> {
222
+ group_by: ai
223
+ aggregate: c is count()
224
+ calculate: x is lag(ai) { partition_by: ai, c }
225
+ }
226
+ `).toTranslate();
227
+ });
228
+ test('partition by fails with analytic and ungrouped aggregate', () => {
229
+ expect((0, test_translator_1.markSource) `
230
+ run: a -> {
231
+ group_by: ai
232
+ aggregate: ac is all(count())
233
+ calculate: x is lag(ai) { partition_by: ac }
234
+ calculate: y is lag(ai) { partition_by: x }
235
+ }
236
+ `).translationToFailWith('Partition expression must be scalar or aggregate', 'Partition expression must be scalar or aggregate');
218
237
  });
219
238
  test('analytics order_by requires expression', () => {
220
239
  expect((0, test_translator_1.markSource) `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.123-dev240209030627",
3
+ "version": "0.0.123-dev240209165819",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",