@malloydata/malloy 0.0.81-dev230910191735 → 0.0.81-dev230910202545

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.
@@ -124,7 +124,7 @@ class ExprAggregateFunction extends expression_def_1.ExpressionDef {
124
124
  const noJoinField = !this.source && joinUsage.every(usage => usage.length === 0);
125
125
  if (!noJoinField && !this.isSymmetricFunction()) {
126
126
  const usagePaths = getJoinUsagePaths(sourceRelationship, joinUsage);
127
- const joinError = validateUsagePaths(this.elementType, usagePaths);
127
+ const joinError = validateUsagePaths(usagePaths);
128
128
  const message = sourceSpecified
129
129
  ? joinError
130
130
  : 'Join path is required for this calculation';
@@ -254,19 +254,14 @@ function getJoinUsagePaths(sourceRelationship, joinUsage) {
254
254
  }
255
255
  return sourceToUsagePaths;
256
256
  }
257
- function validateUsagePaths(functionName, usagePaths) {
257
+ function validateUsagePaths(usagePaths) {
258
258
  for (const path of usagePaths) {
259
259
  for (const step of path) {
260
260
  if (step.structRelationship.type === 'cross') {
261
- return `Cannot compute \`${functionName}\` across \`join_cross\` relationship \`${step.name}\``;
261
+ return `Cannot compute asymmetric aggregate across \`join_cross\` relationship \`${step.name}\``;
262
262
  }
263
263
  else if (step.structRelationship.type === 'many' && !step.reverse) {
264
- return `Cannot compute \`${functionName}\` across \`join_many\` relationship \`${step.name}\``;
265
- }
266
- else if (step.structRelationship.type === 'nested' &&
267
- step.structRelationship.isArray &&
268
- !step.reverse) {
269
- return `Cannot compute \`${functionName}\` across repeated relationship \`${step.name}\``;
264
+ return `Cannot compute asymmetric aggregate across forward \`join_many\` relationship \`${step.name}\``;
270
265
  }
271
266
  }
272
267
  }
@@ -288,7 +283,7 @@ function suggestNewVersion(joinError, joinUsage, expr, func) {
288
283
  }
289
284
  }
290
285
  const usagePaths = getJoinUsagePaths(longestOverlap, joinUsage);
291
- const usageError = validateUsagePaths(func, usagePaths);
286
+ const usageError = validateUsagePaths(usagePaths);
292
287
  // get rid of everything after the last many/cross
293
288
  const indexFromEndOfLastMany = longestOverlap
294
289
  .slice()
@@ -300,7 +295,7 @@ function suggestNewVersion(joinError, joinUsage, expr, func) {
300
295
  : longestOverlap.length - indexFromEndOfLastMany;
301
296
  const shortestOverlapWithMany = longestOverlap.slice(0, numJoinsToLastMany);
302
297
  const shortUsagePaths = getJoinUsagePaths(shortestOverlapWithMany, joinUsage);
303
- const shortUsageError = validateUsagePaths(func, shortUsagePaths);
298
+ const shortUsageError = validateUsagePaths(shortUsagePaths);
304
299
  const longLocality = longestOverlap.length > 0
305
300
  ? longestOverlap.map(r => r.name).join('.')
306
301
  : 'source';
@@ -176,8 +176,6 @@ describe('expressions', () => {
176
176
  source: root is a {
177
177
  rename: column is ai
178
178
  rename: nested is astruct
179
- rename: inline is aninline
180
- rename: inline2 is anonrepeatedstruct
181
179
  dimension: field is column * 2
182
180
  dimension: many_field is many.column * 2
183
181
  dimension: many_one_field is many.column + one.column
@@ -279,7 +277,7 @@ describe('expressions', () => {
279
277
  expect(modelX `sum(many.column)`).translationToFailWith('Join path is required for this calculation; use `many.column.sum()`');
280
278
  });
281
279
  test('source.sum(many.column)', () => {
282
- expect(modelX `source.sum(many.column)`).translationToFailWith('Cannot compute `sum` across `join_many` relationship `many`; use `many.column.sum()`');
280
+ expect(modelX `source.sum(many.column)`).translationToFailWith('Cannot compute asymmetric aggregate across forward `join_many` relationship `many`; use `many.column.sum()`');
283
281
  });
284
282
  test('many.column.sum()', () => {
285
283
  expect(modelX `many.column.sum()`).toTranslate();
@@ -297,37 +295,19 @@ describe('expressions', () => {
297
295
  expect(modelX `source.sum(many.constant)`).toTranslate();
298
296
  });
299
297
  test('sum(nested.column)', () => {
300
- expect(modelX `sum(nested.column)`).translationToFailWith('Join path is required for this calculation; use `nested.column.sum()`');
298
+ expect(modelX `sum(nested.column)`).toTranslateWithWarnings('Join path is required for this calculation; use `nested.column.sum()` or `source.sum(nested.column)` to get a result weighted with respect to `source`');
301
299
  });
302
300
  test('nested.column.sum()', () => {
303
301
  expect(modelX `nested.column.sum()`).toTranslate();
304
302
  });
305
303
  test('source.sum(nested.column)', () => {
306
- expect(modelX `source.sum(nested.column)`).translationToFailWith('Cannot compute `sum` across repeated relationship `nested`; use `nested.column.sum()`');
307
- });
308
- test('sum(inline.column)', () => {
309
- expect(modelX `sum(inline.column)`).toTranslateWithWarnings('Join path is required for this calculation; use `inline.column.sum()` or `source.sum(inline.column)` to get a result weighted with respect to `source`');
310
- });
311
- test('inline.column.sum()', () => {
312
- expect(modelX `inline.column.sum()`).toTranslate();
313
- });
314
- test('source.sum(inline.column)', () => {
315
- expect(modelX `source.sum(inline.column)`).toTranslate();
316
- });
317
- test('sum(inline2.column)', () => {
318
- expect(modelX `sum(inline2.column)`).toTranslateWithWarnings('Join path is required for this calculation; use `inline2.column.sum()` or `source.sum(inline2.column)` to get a result weighted with respect to `source`');
319
- });
320
- test('inline2.column.sum()', () => {
321
- expect(modelX `inline2.column.sum()`).toTranslate();
322
- });
323
- test('source.sum(inline2.column)', () => {
324
- expect(modelX `source.sum(inline2.column)`).toTranslate();
304
+ expect(modelX `source.sum(nested.column)`).toTranslate();
325
305
  });
326
306
  test('sum(many.field)', () => {
327
307
  expect(modelX `sum(many.field)`).translationToFailWith('Join path is required for this calculation; use `many.field.sum()`');
328
308
  });
329
309
  test('source.sum(many.field)', () => {
330
- expect(modelX `source.sum(many.field)`).translationToFailWith('Cannot compute `sum` across `join_many` relationship `many`; use `many.field.sum()`');
310
+ expect(modelX `source.sum(many.field)`).translationToFailWith('Cannot compute asymmetric aggregate across forward `join_many` relationship `many`; use `many.field.sum()`');
331
311
  });
332
312
  test('many.field.sum()', () => {
333
313
  expect(modelX `many.field.sum()`).toTranslate();
@@ -339,7 +319,7 @@ describe('expressions', () => {
339
319
  expect(modelX `sum(many.field + many.field)`).translationToFailWith('Join path is required for this calculation; use `many.sum(many.field + many.field)`');
340
320
  });
341
321
  test('source.sum(many.field + many.field)', () => {
342
- expect(modelX `source.sum(many.field + many.field)`).translationToFailWith('Cannot compute `sum` across `join_many` relationship `many`; use `many.sum(many.field + many.field)`');
322
+ expect(modelX `source.sum(many.field + many.field)`).translationToFailWith('Cannot compute asymmetric aggregate across forward `join_many` relationship `many`; use `many.sum(many.field + many.field)`');
343
323
  });
344
324
  test('many.field + many.field.sum()', () => {
345
325
  expect(modelX `many.field + many.field.sum()`).toTranslate();
@@ -351,7 +331,7 @@ describe('expressions', () => {
351
331
  expect(modelX `sum(many_field)`).translationToFailWith('Join path is required for this calculation; use `many_field.sum()`');
352
332
  });
353
333
  test('source.sum(many_field)', () => {
354
- expect(modelX `source.sum(many_field)`).translationToFailWith('Cannot compute `sum` across `join_many` relationship `many`; use `many_field.sum()`');
334
+ expect(modelX `source.sum(many_field)`).translationToFailWith('Cannot compute asymmetric aggregate across forward `join_many` relationship `many`; use `many_field.sum()`');
355
335
  });
356
336
  test('many_field.sum()', () => {
357
337
  expect(modelX `many_field.sum()`).toTranslate();
@@ -363,7 +343,7 @@ describe('expressions', () => {
363
343
  expect(modelX `sum(one.many_field)`).translationToFailWith('Join path is required for this calculation; use `one.many_field.sum()`');
364
344
  });
365
345
  test('source.sum(one.many_field)', () => {
366
- expect(modelX `source.sum(one.many_field)`).translationToFailWith('Cannot compute `sum` across `join_many` relationship `many`; use `one.many_field.sum()`');
346
+ expect(modelX `source.sum(one.many_field)`).translationToFailWith('Cannot compute asymmetric aggregate across forward `join_many` relationship `many`; use `one.many_field.sum()`');
367
347
  });
368
348
  test('one.many_field.sum()', () => {
369
349
  expect(modelX `one.many_field.sum()`).toTranslate();
@@ -402,7 +382,7 @@ describe('expressions', () => {
402
382
  expect(modelX `one.avg(field)`).toTranslate();
403
383
  });
404
384
  test('cross.avg(field)', () => {
405
- expect(modelX `cross.avg(field)`).translationToFailWith('Cannot compute `avg` across `join_cross` relationship `cross`; use `field.avg()`');
385
+ expect(modelX `cross.avg(field)`).translationToFailWith('Cannot compute asymmetric aggregate across `join_cross` relationship `cross`; use `field.avg()`');
406
386
  });
407
387
  test('cross.avg(cross.field)', () => {
408
388
  expect(modelX `cross.avg(cross.field)`).toTranslate();
@@ -55,22 +55,6 @@ const mockSchema = {
55
55
  type: 'struct',
56
56
  name: 'astruct',
57
57
  structSource: { type: 'nested' },
58
- structRelationship: { type: 'nested', isArray: true, field: 'foo' },
59
- fields: [{ type: 'number', name: 'column', numberType: 'integer' }],
60
- dialect: 'standardsql',
61
- },
62
- {
63
- type: 'struct',
64
- name: 'anonrepeatedstruct',
65
- structSource: { type: 'nested' },
66
- structRelationship: { type: 'nested', isArray: false, field: 'foo' },
67
- fields: [{ type: 'number', name: 'column', numberType: 'integer' }],
68
- dialect: 'standardsql',
69
- },
70
- {
71
- type: 'struct',
72
- name: 'aninline',
73
- structSource: { type: 'nested' },
74
58
  structRelationship: { type: 'inline' },
75
59
  fields: [{ type: 'number', name: 'column', numberType: 'integer' }],
76
60
  dialect: 'standardsql',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.81-dev230910191735",
3
+ "version": "0.0.81-dev230910202545",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",