@malloydata/malloy 0.0.356 → 0.0.358

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.
@@ -33,6 +33,7 @@ class RenameSpaceField extends space_field_1.SpaceField {
33
33
  this.note = note;
34
34
  }
35
35
  fieldDef() {
36
+ var _a;
36
37
  const returnFieldDef = this.otherField.fieldDef();
37
38
  if (returnFieldDef === undefined) {
38
39
  return undefined;
@@ -52,6 +53,15 @@ class RenameSpaceField extends space_field_1.SpaceField {
52
53
  ...returnFieldDef,
53
54
  as: this.newName,
54
55
  location: this.location,
56
+ fieldUsage: (_a = returnFieldDef.fieldUsage) === null || _a === void 0 ? void 0 : _a.map(u => {
57
+ var _a;
58
+ return ({
59
+ ...u,
60
+ path: u.path[0] === ((_a = returnFieldDef.as) !== null && _a !== void 0 ? _a : returnFieldDef.name)
61
+ ? [this.newName, ...u.path.slice(1)]
62
+ : u.path,
63
+ });
64
+ }),
55
65
  };
56
66
  }
57
67
  typeDesc() {
@@ -105,6 +105,13 @@ class IndexBuilder {
105
105
  ? (_a = from.fieldUsage) !== null && _a !== void 0 ? _a : (0, composite_source_utils_1.emptyFieldUsage)()
106
106
  : (0, composite_source_utils_1.emptyFieldUsage)();
107
107
  indexSegment.fieldUsage = (0, composite_source_utils_1.mergeFieldUsage)(fromFieldUsage, this.fieldUsage);
108
+ // Index queries always compute an aggregate for weight (at minimum COUNT(*)).
109
+ // The compiler needs a uniqueKeyRequirement on the base path so that
110
+ // symmetric aggregation is enabled when joins are present.
111
+ indexSegment.fieldUsage.push({
112
+ path: [],
113
+ uniqueKeyRequirement: { isCount: true },
114
+ });
108
115
  return indexSegment;
109
116
  }
110
117
  }
@@ -109,14 +109,17 @@ class ImportStatement extends malloy_element_1.ListOf {
109
109
  importOne.logError('name-conflict-on-selective-import', `Cannot redefine '${dstName}'`);
110
110
  }
111
111
  else {
112
- explicitImport[srcName] = dstName;
112
+ if (explicitImport[srcName] === undefined) {
113
+ explicitImport[srcName] = [];
114
+ }
115
+ explicitImport[srcName].push(dstName);
113
116
  }
114
117
  }
115
118
  const neededSourceIDs = new Set();
116
119
  for (const srcName of importedModel.exports) {
117
- const picked = explicitImport[srcName];
118
- const dstName = picked || srcName;
119
- if (importAll || picked) {
120
+ const pickedNames = explicitImport[srcName];
121
+ const dstNames = pickedNames || (importAll ? [srcName] : []);
122
+ for (const dstName of dstNames) {
120
123
  const importMe = {
121
124
  ...(0, malloy_types_1.safeRecordGet)(importedModel.contents, srcName),
122
125
  };
@@ -335,16 +335,34 @@ function findActiveJoins(dependencies) {
335
335
  * - `activeJoins`: Topologically sorted list of joins needed to resolve these uses
336
336
  */
337
337
  function expandFieldUsage(fieldUsage, fields) {
338
- var _a, _b, _c;
338
+ var _a;
339
339
  const seen = {};
340
340
  const missingFields = [];
341
341
  const toProcess = [];
342
342
  const activeJoinGraph = {};
343
343
  const ungroupings = [];
344
+ function mergeIntoSeen(usage) {
345
+ var _a;
346
+ const key = (0, utils_2.pathToKey)('field', usage.path);
347
+ if (!seen[key]) {
348
+ seen[key] = { ...usage };
349
+ return true;
350
+ }
351
+ const existing = seen[key];
352
+ if (usage.uniqueKeyRequirement) {
353
+ existing.uniqueKeyRequirement = {
354
+ isCount: ((_a = existing.uniqueKeyRequirement) === null || _a === void 0 ? void 0 : _a.isCount) ||
355
+ usage.uniqueKeyRequirement.isCount,
356
+ };
357
+ }
358
+ if (usage.analyticFunctionUse) {
359
+ existing.analyticFunctionUse = true;
360
+ }
361
+ return false;
362
+ }
344
363
  // Initialize: mark original inputs and add them to processing queue
345
364
  for (const usage of fieldUsage) {
346
- const seenKey = (0, utils_2.pathToKey)('field', usage.path);
347
- seen[seenKey] = usage;
365
+ mergeIntoSeen(usage);
348
366
  toProcess.push(usage);
349
367
  }
350
368
  // Process the expanding queue
@@ -363,16 +381,9 @@ function expandFieldUsage(fieldUsage, fields) {
363
381
  // Add the atomic field's dependencies to the queue
364
382
  const refPath = reference.path.slice(0, -1);
365
383
  for (const usage of joinedFieldUsage(refPath, fieldUsage)) {
366
- const key = (0, utils_2.pathToKey)('field', usage.path);
367
- if (!seen[key]) {
368
- seen[key] = usage;
384
+ if (mergeIntoSeen(usage)) {
369
385
  toProcess.push(usage);
370
386
  }
371
- else if (usage.uniqueKeyRequirement) {
372
- seen[key].uniqueKeyRequirement = {
373
- isCount: (_b = usage.uniqueKeyRequirement.isCount) !== null && _b !== void 0 ? _b : (_c = seen[key].uniqueKeyRequirement) === null || _c === void 0 ? void 0 : _c.isCount,
374
- };
375
- }
376
387
  }
377
388
  if (def.ungroupings) {
378
389
  ungroupings.push(...joinedUngroupings(refPath, def.ungroupings));
@@ -121,7 +121,6 @@ class QueryQuery extends query_node_1.QueryField {
121
121
  resultRoot.isComplexQuery = true;
122
122
  resultRoot.queryUsesPartitioning = true;
123
123
  }
124
- continue;
125
124
  }
126
125
  if (usage.uniqueKeyRequirement) {
127
126
  if (usage.path.length === 0) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.356";
1
+ export declare const MALLOY_VERSION = "0.0.358";
package/dist/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MALLOY_VERSION = void 0;
4
4
  // generated with 'generate-version-file' script; do not edit manually
5
- exports.MALLOY_VERSION = '0.0.356';
5
+ exports.MALLOY_VERSION = '0.0.358';
6
6
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.356",
3
+ "version": "0.0.358",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -47,9 +47,9 @@
47
47
  "generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
48
48
  },
49
49
  "dependencies": {
50
- "@malloydata/malloy-filter": "0.0.356",
51
- "@malloydata/malloy-interfaces": "0.0.356",
52
- "@malloydata/malloy-tag": "0.0.356",
50
+ "@malloydata/malloy-filter": "0.0.358",
51
+ "@malloydata/malloy-interfaces": "0.0.358",
52
+ "@malloydata/malloy-tag": "0.0.358",
53
53
  "@noble/hashes": "^1.8.0",
54
54
  "antlr4ts": "^0.5.0-alpha.4",
55
55
  "assert": "^2.0.0",