@malloydata/malloy 0.0.315 → 0.0.317

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.
@@ -59,6 +59,7 @@ exports.ExprCoalesce = void 0;
59
59
  const model_1 = require("../../../model");
60
60
  const TDU = __importStar(require("../typedesc-utils"));
61
61
  const expression_def_1 = require("../types/expression-def");
62
+ const composite_source_utils_1 = require("../../composite-source-utils");
62
63
  class ExprCoalesce extends expression_def_1.ExpressionDef {
63
64
  constructor(expr, altExpr) {
64
65
  super({ expr, altExpr });
@@ -68,6 +69,7 @@ class ExprCoalesce extends expression_def_1.ExpressionDef {
68
69
  this.legalChildTypes = TDU.anyAtomicT;
69
70
  }
70
71
  getExpression(fs) {
72
+ var _a;
71
73
  const maybeNull = this.expr.getExpression(fs);
72
74
  const whenNull = this.altExpr.getExpression(fs);
73
75
  if (maybeNull.type === 'null') {
@@ -93,6 +95,7 @@ class ExprCoalesce extends expression_def_1.ExpressionDef {
93
95
  kids: { left: maybeNull.value, right: whenNull.value },
94
96
  },
95
97
  evalSpace: (0, model_1.mergeEvalSpaces)(maybeNull.evalSpace, whenNull.evalSpace),
98
+ fieldUsage: (_a = (0, composite_source_utils_1.mergeFieldUsage)(maybeNull.fieldUsage, whenNull.fieldUsage)) !== null && _a !== void 0 ? _a : [],
96
99
  };
97
100
  }
98
101
  }
@@ -20,7 +20,6 @@ type TranslatedQueryField = {
20
20
  * created and paired when a QueryOperationSpace is created.
21
21
  */
22
22
  export declare abstract class QueryOperationSpace extends RefinedSpace implements QueryFieldSpace {
23
- readonly queryInputSpace: SourceFieldSpace;
24
23
  readonly nestParent: QueryOperationSpace | undefined;
25
24
  readonly astEl: MalloyElement;
26
25
  protected exprSpace: QueryInputSpace;
@@ -83,7 +83,6 @@ class QueryOperationSpace extends refined_space_1.RefinedSpace {
83
83
  }
84
84
  constructor(queryInputSpace, refineThis, nestParent, astEl) {
85
85
  super(queryInputSpace.emptyStructDef());
86
- this.queryInputSpace = queryInputSpace;
87
86
  this.nestParent = nestParent;
88
87
  this.astEl = astEl;
89
88
  this.expandedWild = {};
@@ -260,7 +259,7 @@ class QuerySpace extends QueryOperationSpace {
260
259
  if (typeDesc.type === 'turtle') {
261
260
  const pipeline = typeDesc.pipeline;
262
261
  const lastSegment = pipeline[pipeline.length - 1];
263
- const outputStruct = (_b = lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.outputStruct) !== null && _b !== void 0 ? _b : error_factory_1.ErrorFactory.structDef;
262
+ const outputStruct = (_b = lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.outputStruct) !== null && _b !== void 0 ? _b : this.exprSpace.emptyStructDef();
264
263
  const isRepeated = lastSegment
265
264
  ? model.isQuerySegment(lastSegment)
266
265
  ? lastSegment.isRepeated
@@ -71,22 +71,36 @@ function refine(logTo, refineTo, refineFrom) {
71
71
  : undefined;
72
72
  if ((0, model_1.isQuerySegment)(from) && (0, model_1.isQuerySegment)(to)) {
73
73
  const overlappingFields = [];
74
- const nonOverlappingFields = [];
74
+ const missingOut = [];
75
75
  const existingNames = new Map(to.queryFields.map((f) => [
76
76
  (0, field_utils_1.nameFromDef)(f),
77
77
  f,
78
78
  ]));
79
+ const outputFields = [...to.outputStruct.fields];
80
+ const queryFields = [...to.queryFields];
79
81
  for (const field of from.queryFields) {
80
- if (existingNames.has((0, field_utils_1.nameFromDef)(field))) {
81
- overlappingFields.push(field);
82
+ const fieldName = (0, field_utils_1.nameFromDef)(field);
83
+ if (existingNames.has(fieldName)) {
84
+ overlappingFields.push(fieldName);
82
85
  }
83
86
  else {
84
- nonOverlappingFields.push(field);
87
+ queryFields.push(field);
88
+ const outField = from.outputStruct.fields.find(f => f.name === fieldName);
89
+ if (outField) {
90
+ outputFields.push(outField);
91
+ }
92
+ else {
93
+ missingOut.push(fieldName);
94
+ }
85
95
  }
86
96
  }
87
- to.queryFields = [...to.queryFields, ...nonOverlappingFields];
97
+ to.queryFields = queryFields;
98
+ to.outputStruct.fields = outputFields;
88
99
  if (overlappingFields.length > 0) {
89
- logTo.logError('name-conflict-in-refinement', `overlapping fields in refinement: ${overlappingFields.map(field_utils_1.nameFromDef)}`);
100
+ logTo.logError('name-conflict-in-refinement', `overlapping fields in refinement: ${overlappingFields.join(', ')}`);
101
+ }
102
+ if (missingOut.length > 0) {
103
+ logTo.logError('name-conflict-in-refinement', `missing output fields in refinement: ${missingOut.join(', ')}`);
90
104
  }
91
105
  to.fieldUsage = (0, composite_source_utils_1.mergeFieldUsage)(to.fieldUsage, from.fieldUsage);
92
106
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.315";
1
+ export declare const MALLOY_VERSION = "0.0.317";
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.315';
5
+ exports.MALLOY_VERSION = '0.0.317';
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.315",
3
+ "version": "0.0.317",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -41,9 +41,9 @@
41
41
  "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"
42
42
  },
43
43
  "dependencies": {
44
- "@malloydata/malloy-filter": "0.0.315",
45
- "@malloydata/malloy-interfaces": "0.0.315",
46
- "@malloydata/malloy-tag": "0.0.315",
44
+ "@malloydata/malloy-filter": "0.0.317",
45
+ "@malloydata/malloy-interfaces": "0.0.317",
46
+ "@malloydata/malloy-tag": "0.0.317",
47
47
  "antlr4ts": "^0.5.0-alpha.4",
48
48
  "assert": "^2.0.0",
49
49
  "jaro-winkler": "^0.2.8",