@malloydata/malloy 0.0.427 → 0.0.429

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.
Files changed (129) hide show
  1. package/dist/api/foundation/build_targets.d.ts +50 -0
  2. package/dist/api/foundation/build_targets.js +221 -0
  3. package/dist/api/foundation/core.d.ts +54 -10
  4. package/dist/api/foundation/core.js +80 -17
  5. package/dist/api/foundation/index.d.ts +1 -1
  6. package/dist/api/foundation/runtime.d.ts +18 -1
  7. package/dist/api/foundation/runtime.js +35 -0
  8. package/dist/api/foundation/types.d.ts +93 -6
  9. package/dist/index.d.ts +1 -1
  10. package/dist/lang/ast/expressions/apply.d.ts +1 -1
  11. package/dist/lang/ast/expressions/apply.js +2 -2
  12. package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
  13. package/dist/lang/ast/expressions/binary-boolean.js +1 -1
  14. package/dist/lang/ast/expressions/binary-numeric.d.ts +1 -1
  15. package/dist/lang/ast/expressions/binary-numeric.js +1 -1
  16. package/dist/lang/ast/expressions/boolean.d.ts +1 -1
  17. package/dist/lang/ast/expressions/boolean.js +1 -1
  18. package/dist/lang/ast/expressions/case.d.ts +1 -1
  19. package/dist/lang/ast/expressions/case.js +1 -1
  20. package/dist/lang/ast/expressions/constant-expression.d.ts +2 -1
  21. package/dist/lang/ast/expressions/constant-expression.js +6 -1
  22. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +1 -1
  23. package/dist/lang/ast/expressions/expr-aggregate-function.js +14 -7
  24. package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +1 -1
  25. package/dist/lang/ast/expressions/expr-alternation-tree.js +1 -1
  26. package/dist/lang/ast/expressions/expr-array-literal.d.ts +1 -1
  27. package/dist/lang/ast/expressions/expr-array-literal.js +1 -1
  28. package/dist/lang/ast/expressions/expr-cast.d.ts +1 -1
  29. package/dist/lang/ast/expressions/expr-cast.js +1 -1
  30. package/dist/lang/ast/expressions/expr-coalesce.d.ts +1 -1
  31. package/dist/lang/ast/expressions/expr-coalesce.js +1 -1
  32. package/dist/lang/ast/expressions/expr-compare.d.ts +4 -4
  33. package/dist/lang/ast/expressions/expr-compare.js +4 -4
  34. package/dist/lang/ast/expressions/expr-count.d.ts +1 -1
  35. package/dist/lang/ast/expressions/expr-count.js +1 -1
  36. package/dist/lang/ast/expressions/expr-filter-expr.d.ts +1 -1
  37. package/dist/lang/ast/expressions/expr-filter-expr.js +1 -1
  38. package/dist/lang/ast/expressions/expr-func.d.ts +1 -1
  39. package/dist/lang/ast/expressions/expr-func.js +1 -1
  40. package/dist/lang/ast/expressions/expr-given.d.ts +1 -1
  41. package/dist/lang/ast/expressions/expr-given.js +1 -1
  42. package/dist/lang/ast/expressions/expr-granular-time.d.ts +1 -1
  43. package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
  44. package/dist/lang/ast/expressions/expr-id-reference.d.ts +1 -1
  45. package/dist/lang/ast/expressions/expr-id-reference.js +1 -1
  46. package/dist/lang/ast/expressions/expr-minus.d.ts +1 -1
  47. package/dist/lang/ast/expressions/expr-minus.js +1 -1
  48. package/dist/lang/ast/expressions/expr-not.d.ts +1 -1
  49. package/dist/lang/ast/expressions/expr-not.js +1 -1
  50. package/dist/lang/ast/expressions/expr-now.d.ts +1 -1
  51. package/dist/lang/ast/expressions/expr-now.js +1 -1
  52. package/dist/lang/ast/expressions/expr-null.d.ts +3 -3
  53. package/dist/lang/ast/expressions/expr-null.js +14 -9
  54. package/dist/lang/ast/expressions/expr-number.d.ts +1 -1
  55. package/dist/lang/ast/expressions/expr-number.js +1 -1
  56. package/dist/lang/ast/expressions/expr-parens.d.ts +1 -1
  57. package/dist/lang/ast/expressions/expr-parens.js +5 -2
  58. package/dist/lang/ast/expressions/expr-props.d.ts +1 -1
  59. package/dist/lang/ast/expressions/expr-props.js +1 -1
  60. package/dist/lang/ast/expressions/expr-record-literal.d.ts +1 -1
  61. package/dist/lang/ast/expressions/expr-record-literal.js +1 -1
  62. package/dist/lang/ast/expressions/expr-regex.d.ts +1 -1
  63. package/dist/lang/ast/expressions/expr-regex.js +1 -1
  64. package/dist/lang/ast/expressions/expr-string.d.ts +1 -1
  65. package/dist/lang/ast/expressions/expr-string.js +1 -1
  66. package/dist/lang/ast/expressions/expr-time-extract.d.ts +1 -1
  67. package/dist/lang/ast/expressions/expr-time-extract.js +1 -1
  68. package/dist/lang/ast/expressions/expr-time.d.ts +1 -1
  69. package/dist/lang/ast/expressions/expr-time.js +1 -1
  70. package/dist/lang/ast/expressions/expr-ungroup.d.ts +1 -1
  71. package/dist/lang/ast/expressions/expr-ungroup.js +1 -1
  72. package/dist/lang/ast/expressions/for-range.d.ts +1 -1
  73. package/dist/lang/ast/expressions/for-range.js +1 -1
  74. package/dist/lang/ast/expressions/partial-compare.d.ts +1 -1
  75. package/dist/lang/ast/expressions/partial-compare.js +1 -1
  76. package/dist/lang/ast/expressions/pick-when.d.ts +1 -1
  77. package/dist/lang/ast/expressions/pick-when.js +1 -1
  78. package/dist/lang/ast/expressions/range.d.ts +1 -1
  79. package/dist/lang/ast/expressions/range.js +1 -1
  80. package/dist/lang/ast/expressions/time-literal.d.ts +2 -2
  81. package/dist/lang/ast/expressions/time-literal.js +2 -2
  82. package/dist/lang/ast/field-space/dynamic-space.js +20 -3
  83. package/dist/lang/ast/field-space/parameter-space.d.ts +1 -0
  84. package/dist/lang/ast/field-space/parameter-space.js +6 -0
  85. package/dist/lang/ast/field-space/passthrough-space.d.ts +1 -0
  86. package/dist/lang/ast/field-space/passthrough-space.js +3 -0
  87. package/dist/lang/ast/field-space/static-space.d.ts +8 -0
  88. package/dist/lang/ast/field-space/static-space.js +14 -0
  89. package/dist/lang/ast/query-builders/index-builder.js +1 -1
  90. package/dist/lang/ast/query-elements/query-arrow.d.ts +1 -1
  91. package/dist/lang/ast/query-elements/query-arrow.js +10 -4
  92. package/dist/lang/ast/query-elements/query-base.d.ts +1 -1
  93. package/dist/lang/ast/query-elements/query-base.js +1 -6
  94. package/dist/lang/ast/query-elements/query-raw.d.ts +1 -1
  95. package/dist/lang/ast/query-elements/query-raw.js +4 -2
  96. package/dist/lang/ast/query-elements/query-reference.d.ts +1 -1
  97. package/dist/lang/ast/query-elements/query-reference.js +9 -3
  98. package/dist/lang/ast/query-elements/query-refine.d.ts +1 -1
  99. package/dist/lang/ast/query-elements/query-refine.js +10 -4
  100. package/dist/lang/ast/query-properties/drill.d.ts +1 -1
  101. package/dist/lang/ast/query-properties/drill.js +1 -1
  102. package/dist/lang/ast/source-elements/query-source.js +1 -1
  103. package/dist/lang/ast/source-elements/sql-source.js +2 -2
  104. package/dist/lang/ast/source-query-elements/source-query-element.d.ts +27 -0
  105. package/dist/lang/ast/source-query-elements/source-query-element.js +33 -0
  106. package/dist/lang/ast/source-query-elements/sq-arrow.d.ts +2 -0
  107. package/dist/lang/ast/source-query-elements/sq-arrow.js +12 -6
  108. package/dist/lang/ast/source-query-elements/sq-refine.d.ts +2 -0
  109. package/dist/lang/ast/source-query-elements/sq-refine.js +12 -6
  110. package/dist/lang/ast/source-query-elements/sq-source.d.ts +1 -0
  111. package/dist/lang/ast/source-query-elements/sq-source.js +6 -3
  112. package/dist/lang/ast/sql-elements/sql-string.d.ts +1 -1
  113. package/dist/lang/ast/sql-elements/sql-string.js +25 -5
  114. package/dist/lang/ast/statements/import-statement.js +7 -10
  115. package/dist/lang/ast/types/expression-def.d.ts +50 -23
  116. package/dist/lang/ast/types/expression-def.js +127 -65
  117. package/dist/lang/ast/types/field-space.d.ts +14 -0
  118. package/dist/lang/ast/types/field-space.js +36 -0
  119. package/dist/lang/ast/types/query-element.d.ts +15 -1
  120. package/dist/lang/parse-log.d.ts +2 -0
  121. package/dist/lang/test/test-translator.d.ts +17 -0
  122. package/dist/lang/test/test-translator.js +46 -2
  123. package/dist/model/malloy_types.d.ts +0 -13
  124. package/dist/model/malloy_types.js +0 -19
  125. package/dist/model/persist_utils.d.ts +61 -10
  126. package/dist/model/persist_utils.js +172 -63
  127. package/dist/version.d.ts +1 -1
  128. package/dist/version.js +1 -1
  129. package/package.json +4 -4
@@ -11,7 +11,7 @@ class ExprNow extends expression_def_1.ExpressionDef {
11
11
  super(...arguments);
12
12
  this.elementType = 'timestamp';
13
13
  }
14
- getExpression(_fs) {
14
+ computeExpression(_fs) {
15
15
  return {
16
16
  type: 'timestamp',
17
17
  expressionType: 'scalar',
@@ -3,7 +3,7 @@ import type { ExprValue } from '../types/expr-value';
3
3
  import { ATNodeType, ExpressionDef } from '../types/expression-def';
4
4
  export declare class ExprNULL extends ExpressionDef {
5
5
  elementType: string;
6
- getExpression(): ExprValue;
6
+ protected computeExpression(): ExprValue;
7
7
  apply(fs: FieldSpace, op: BinaryMalloyOperator, left: ExpressionDef): ExprValue;
8
8
  }
9
9
  export declare class PartialIsNull extends ExpressionDef {
@@ -12,7 +12,7 @@ export declare class PartialIsNull extends ExpressionDef {
12
12
  constructor(op: '=' | '!=');
13
13
  apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
14
14
  requestExpression(_fs: FieldSpace): ExprValue | undefined;
15
- getExpression(_fs: FieldSpace): ExprValue;
15
+ protected computeExpression(_fs: FieldSpace): ExprValue;
16
16
  atNodeType(): ATNodeType;
17
17
  }
18
18
  export declare class ExprIsNull extends ExpressionDef {
@@ -20,5 +20,5 @@ export declare class ExprIsNull extends ExpressionDef {
20
20
  readonly op: '=' | '!=';
21
21
  elementType: string;
22
22
  constructor(expr: ExpressionDef, op: '=' | '!=');
23
- getExpression(fs: FieldSpace): ExprValue;
23
+ protected computeExpression(fs: FieldSpace): ExprValue;
24
24
  }
@@ -8,20 +8,25 @@ exports.ExprIsNull = exports.PartialIsNull = exports.ExprNULL = void 0;
8
8
  const expr_value_1 = require("../types/expr-value");
9
9
  const expression_def_1 = require("../types/expression-def");
10
10
  function doIsNull(fs, op, expr) {
11
+ // Build a new value rather than retyping the operand's in place: what
12
+ // getExpression hands back is shared, and the operand is usually asked for
13
+ // its value again after this.
11
14
  const nullCmp = expr.getExpression(fs);
12
- nullCmp.type = 'boolean';
13
- nullCmp.value = {
14
- node: op === '=' ? 'is-null' : 'is-not-null',
15
- e: nullCmp.value,
16
- };
17
- return nullCmp;
15
+ return (0, expr_value_1.computedExprValue)({
16
+ dataType: { type: 'boolean' },
17
+ value: {
18
+ node: op === '=' ? 'is-null' : 'is-not-null',
19
+ e: nullCmp.value,
20
+ },
21
+ from: [nullCmp],
22
+ });
18
23
  }
19
24
  class ExprNULL extends expression_def_1.ExpressionDef {
20
25
  constructor() {
21
26
  super(...arguments);
22
27
  this.elementType = 'NULL';
23
28
  }
24
- getExpression() {
29
+ computeExpression() {
25
30
  return (0, expr_value_1.literalExprValue)({
26
31
  dataType: { type: 'null' },
27
32
  value: { node: 'null' },
@@ -47,7 +52,7 @@ class PartialIsNull extends expression_def_1.ExpressionDef {
47
52
  requestExpression(_fs) {
48
53
  return undefined;
49
54
  }
50
- getExpression(_fs) {
55
+ computeExpression(_fs) {
51
56
  return this.loggedErrorExpr('partial-as-value', 'Partial null check does not have a value');
52
57
  }
53
58
  atNodeType() {
@@ -63,7 +68,7 @@ class ExprIsNull extends expression_def_1.ExpressionDef {
63
68
  this.elementType = 'is null';
64
69
  this.has({ expr });
65
70
  }
66
- getExpression(fs) {
71
+ computeExpression(fs) {
67
72
  return doIsNull(fs, this.op, this.expr);
68
73
  }
69
74
  }
@@ -6,7 +6,7 @@ export declare class ExprNumber extends ExpressionDef {
6
6
  readonly n: string;
7
7
  elementType: string;
8
8
  constructor(n: string);
9
- getExpression(fs: FieldSpace): ExprValue;
9
+ protected computeExpression(fs: FieldSpace): ExprValue;
10
10
  /**
11
11
  * Default number type when no dialect is available.
12
12
  * Integers default to bigint for safety, floats to float.
@@ -13,7 +13,7 @@ class ExprNumber extends expression_def_1.ExpressionDef {
13
13
  this.n = n;
14
14
  this.elementType = 'numeric literal';
15
15
  }
16
- getExpression(fs) {
16
+ computeExpression(fs) {
17
17
  var _a;
18
18
  const dialect = fs.dialectObj();
19
19
  const dataType = (_a = dialect === null || dialect === void 0 ? void 0 : dialect.literalNumberType(this.n)) !== null && _a !== void 0 ? _a : this.defaultNumberType();
@@ -7,7 +7,7 @@ export declare class ExprParens extends ExpressionDef {
7
7
  elementType: string;
8
8
  constructor(expr: ExpressionDef);
9
9
  requestExpression(fs: FieldSpace): ExprValue | undefined;
10
- getExpression(fs: FieldSpace): ExprValue;
10
+ protected computeExpression(fs: FieldSpace): ExprValue;
11
11
  apply(fs: FieldSpace, op: BinaryMalloyOperator, left: ExpressionDef, doWarn: boolean): ExprValue;
12
12
  atNodeType(): ATNodeType;
13
13
  atExpr(): ExpressionDef;
@@ -15,15 +15,18 @@ class ExprParens extends expression_def_1.ExpressionDef {
15
15
  requestExpression(fs) {
16
16
  return this.expr.requestExpression(fs);
17
17
  }
18
- getExpression(fs) {
18
+ computeExpression(fs) {
19
19
  const subExpr = this.expr.getExpression(fs);
20
20
  return { ...subExpr, value: { node: '()', e: subExpr.value } };
21
21
  }
22
22
  apply(fs, op, left, doWarn) {
23
23
  if (this.expr.atNodeType() === expression_def_1.ATNodeType.Or) {
24
+ // Parens are invisible to `?`/`=`, so hand the tree the operator and
25
+ // doWarn, which decides whether an un-collapsible `|` list is worth a
26
+ // warning. The base ignores doWarn, which is why it is not passed on.
24
27
  return this.expr.apply(fs, op, left, doWarn);
25
28
  }
26
- return (0, expression_def_1.applyBinary)(fs, left, op, this);
29
+ return super.apply(fs, op, left);
27
30
  }
28
31
  atNodeType() {
29
32
  return this.expr.atNodeType();
@@ -10,7 +10,7 @@ export declare class ExprProps extends ExpressionDef {
10
10
  legalChildTypes: import("../../..").TypeDesc[];
11
11
  constructor(expr: ExpressionDef, statements: FieldPropStatement[]);
12
12
  private getFilteredExpression;
13
- getExpression(fs: FieldSpace): ExprValue;
13
+ protected computeExpression(fs: FieldSpace): ExprValue;
14
14
  getGroupedBys(fs: FieldSpace, expr: ExprValue, groupedBys: GroupedBy[]): {
15
15
  requiresGroupBy: import("../../../model").RequiredGroupBy[] | undefined;
16
16
  type: "string";
@@ -87,7 +87,7 @@ class ExprProps extends expression_def_1.ExpressionDef {
87
87
  }
88
88
  return expr;
89
89
  }
90
- getExpression(fs) {
90
+ computeExpression(fs) {
91
91
  const partitionBys = [];
92
92
  let limit;
93
93
  const orderBys = [];
@@ -19,7 +19,7 @@ export declare class RecordLiteral extends ExpressionDef {
19
19
  readonly pairs: RecordElement[];
20
20
  elementType: string;
21
21
  constructor(pairs: RecordElement[]);
22
- getExpression(fs: FieldSpace): ExprValue;
22
+ protected computeExpression(fs: FieldSpace): ExprValue;
23
23
  getRecord(fs: FieldSpace, kidNames: string[]): ExprValue;
24
24
  getNextElement(fs: FieldSpace, headValue: ExprValue): ExprValue;
25
25
  }
@@ -70,7 +70,7 @@ class RecordLiteral extends expression_def_1.ExpressionDef {
70
70
  this.elementType = 'record literal';
71
71
  this.has({ pairs });
72
72
  }
73
- getExpression(fs) {
73
+ computeExpression(fs) {
74
74
  return this.getRecord(fs, []);
75
75
  }
76
76
  getRecord(fs, kidNames) {
@@ -4,5 +4,5 @@ export declare class ExprRegEx extends ExpressionDef {
4
4
  readonly regex: string;
5
5
  elementType: string;
6
6
  constructor(regex: string);
7
- getExpression(): ExprValue;
7
+ protected computeExpression(): ExprValue;
8
8
  }
@@ -13,7 +13,7 @@ class ExprRegEx extends expression_def_1.ExpressionDef {
13
13
  this.regex = regex;
14
14
  this.elementType = 'regular expression literal';
15
15
  }
16
- getExpression() {
16
+ computeExpression() {
17
17
  return (0, expr_value_1.literalExprValue)({
18
18
  dataType: { type: 'regular expression' },
19
19
  value: { node: 'regexpLiteral', literal: this.regex },
@@ -6,6 +6,6 @@ export declare class ExprString extends ExpressionDef {
6
6
  elementType: string;
7
7
  value: string;
8
8
  constructor(src: string);
9
- getExpression(_fs: FieldSpace): ExprValue;
9
+ protected computeExpression(_fs: FieldSpace): ExprValue;
10
10
  getStableLiteral(): Malloy.LiteralValue;
11
11
  }
@@ -13,7 +13,7 @@ class ExprString extends expression_def_1.ExpressionDef {
13
13
  this.elementType = 'string literal';
14
14
  this.value = src;
15
15
  }
16
- getExpression(_fs) {
16
+ computeExpression(_fs) {
17
17
  return (0, expr_value_1.literalExprValue)({
18
18
  dataType: { type: 'string' },
19
19
  value: { node: 'stringLiteral', literal: this.value },
@@ -9,5 +9,5 @@ export declare class ExprTimeExtract extends ExpressionDef {
9
9
  static pluralMap: Record<string, ExtractUnit>;
10
10
  static extractor(funcName: string): ExtractUnit | undefined;
11
11
  constructor(extractText: string, args: ExpressionDef[]);
12
- getExpression(fs: FieldSpace): ExprValue;
12
+ protected computeExpression(fs: FieldSpace): ExprValue;
13
13
  }
@@ -25,7 +25,7 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
25
25
  this.args = args;
26
26
  this.elementType = 'timeExtract';
27
27
  }
28
- getExpression(fs) {
28
+ computeExpression(fs) {
29
29
  const extractTo = ExprTimeExtract.extractor(this.extractText);
30
30
  if (extractTo) {
31
31
  if (this.args.length !== 1) {
@@ -6,6 +6,6 @@ export declare class ExprTime extends ExpressionDef {
6
6
  elementType: string;
7
7
  readonly translationValue: ExprValue;
8
8
  constructor(timeType: TemporalFieldType, value: Expr, from?: ExprValue[]);
9
- getExpression(_fs: FieldSpace): ExprValue;
9
+ protected computeExpression(_fs: FieldSpace): ExprValue;
10
10
  static fromValue(timeType: TemporalFieldType, expr: ExprValue): ExprTime;
11
11
  }
@@ -19,7 +19,7 @@ class ExprTime extends expression_def_1.ExpressionDef {
19
19
  from: from !== null && from !== void 0 ? from : [],
20
20
  });
21
21
  }
22
- getExpression(_fs) {
22
+ computeExpression(_fs) {
23
23
  return this.translationValue;
24
24
  }
25
25
  static fromValue(timeType, expr) {
@@ -8,5 +8,5 @@ export declare class ExprUngroup extends ExpressionDef {
8
8
  legalChildTypes: import("../../..").TypeDesc[];
9
9
  elementType: string;
10
10
  constructor(control: 'all' | 'exclude', expr: ExpressionDef, fields: FieldName[]);
11
- getExpression(fs: FieldSpace): ExprValue;
11
+ protected computeExpression(fs: FieldSpace): ExprValue;
12
12
  }
@@ -52,7 +52,7 @@ class ExprUngroup extends expression_def_1.ExpressionDef {
52
52
  this.legalChildTypes = TDU.anyAtomicT;
53
53
  this.elementType = 'ungroup';
54
54
  }
55
- getExpression(fs) {
55
+ computeExpression(fs) {
56
56
  var _a;
57
57
  const exprVal = this.expr.getExpression(fs);
58
58
  if (!(0, malloy_types_1.expressionIsAggregate)(exprVal.expressionType)) {
@@ -12,5 +12,5 @@ export declare class ForRange extends ExpressionDef {
12
12
  constructor(from: ExpressionDef, duration: ExpressionDef, timeframe: Timeframe);
13
13
  apply(fs: FieldSpace, op: BinaryMalloyOperator, expr: ExpressionDef): ExprValue;
14
14
  requestExpression(_fs: FieldSpace): undefined;
15
- getExpression(_fs: FieldSpace): ExprValue;
15
+ protected computeExpression(_fs: FieldSpace): ExprValue;
16
16
  }
@@ -110,7 +110,7 @@ class ForRange extends expression_def_1.ExpressionDef {
110
110
  requestExpression(_fs) {
111
111
  return undefined;
112
112
  }
113
- getExpression(_fs) {
113
+ computeExpression(_fs) {
114
114
  return this.loggedErrorExpr('range-as-value', 'A Range is not a value');
115
115
  }
116
116
  }
@@ -10,6 +10,6 @@ export declare class PartialCompare extends ExpressionDef {
10
10
  granular(): boolean;
11
11
  apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
12
12
  requestExpression(_fs: FieldSpace): ExprValue | undefined;
13
- getExpression(_fs: FieldSpace): ExprValue;
13
+ protected computeExpression(_fs: FieldSpace): ExprValue;
14
14
  atNodeType(): ATNodeType;
15
15
  }
@@ -22,7 +22,7 @@ class PartialCompare extends expression_def_1.ExpressionDef {
22
22
  requestExpression(_fs) {
23
23
  return undefined;
24
24
  }
25
- getExpression(_fs) {
25
+ computeExpression(_fs) {
26
26
  return this.loggedErrorExpr('partial-as-value', 'Partial comparison does not have a value');
27
27
  }
28
28
  atNodeType() {
@@ -9,7 +9,7 @@ export declare class Pick extends ExpressionDef {
9
9
  constructor(choices: PickWhen[], elsePick?: ExpressionDef | undefined);
10
10
  requestExpression(fs: FieldSpace): ExprValue | undefined;
11
11
  apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
12
- getExpression(fs: FieldSpace): ExprValue;
12
+ protected computeExpression(fs: FieldSpace): ExprValue;
13
13
  }
14
14
  export declare class PickWhen extends MalloyElement {
15
15
  readonly pick: ExpressionDef | undefined;
@@ -138,7 +138,7 @@ class Pick extends expression_def_1.ExpressionDef {
138
138
  from: dependents,
139
139
  });
140
140
  }
141
- getExpression(fs) {
141
+ computeExpression(fs) {
142
142
  const pick = {
143
143
  node: 'case',
144
144
  kids: {
@@ -9,5 +9,5 @@ export declare class Range extends ExpressionDef {
9
9
  constructor(first: ExpressionDef, last: ExpressionDef);
10
10
  apply(fs: FieldSpace, op: BinaryMalloyOperator, expr: ExpressionDef): ExprValue;
11
11
  requestExpression(_fs: FieldSpace): undefined;
12
- getExpression(_fs: FieldSpace): ExprValue;
12
+ protected computeExpression(_fs: FieldSpace): ExprValue;
13
13
  }
@@ -56,7 +56,7 @@ class Range extends expression_def_1.ExpressionDef {
56
56
  requestExpression(_fs) {
57
57
  return undefined;
58
58
  }
59
- getExpression(_fs) {
59
+ computeExpression(_fs) {
60
60
  this.logError('range-as-value', 'A Range is not a value');
61
61
  return (0, ast_utils_1.errorFor)('a range is not a value');
62
62
  }
@@ -31,7 +31,7 @@ export declare abstract class TimeLiteral extends ExpressionDef {
31
31
  }) | (import("../../../model").TimestamptzTypeDef & import("../../../model").TypeInfo & import("../types/expr-result").WithValue & {
32
32
  timeframe?: TimestampUnit;
33
33
  });
34
- getExpression(fs: FieldSpace): ExprValue;
34
+ protected computeExpression(fs: FieldSpace): ExprValue;
35
35
  getNext(fs: FieldSpace): ExprValue | undefined;
36
36
  granular(): boolean;
37
37
  }
@@ -62,7 +62,7 @@ export declare class LiteralHour extends GranularLiteral {
62
62
  */
63
63
  declare abstract class DateBasedLiteral extends GranularLiteral {
64
64
  constructor(tm: TimeText, units: TimestampUnit, nextLit: string);
65
- getExpression(fs: FieldSpace): ExprValue;
65
+ protected computeExpression(fs: FieldSpace): ExprValue;
66
66
  getNext(fs: FieldSpace): ExprValue | undefined;
67
67
  }
68
68
  export declare class LiteralDay extends DateBasedLiteral {
@@ -107,7 +107,7 @@ class TimeLiteral extends expression_def_1.ExpressionDef {
107
107
  timeframe: this.units,
108
108
  });
109
109
  }
110
- getExpression(fs) {
110
+ computeExpression(fs) {
111
111
  return this.makeValue(fs, this.literalPart, this.timeType);
112
112
  }
113
113
  getNext(fs) {
@@ -249,7 +249,7 @@ class DateBasedLiteral extends GranularLiteral {
249
249
  constructor(tm, units, nextLit) {
250
250
  super(tm, units, 'date', nextLit);
251
251
  }
252
- getExpression(fs) {
252
+ computeExpression(fs) {
253
253
  const dateValue = this.makeValue(fs, this.literalPart, 'date');
254
254
  const timestamp = this.makeLiteral(fs, `${this.literalPart} 00:00:00`, 'timestamp', this.units);
255
255
  return { ...dateValue, morphic: { timestamp }, evalSpace: 'literal' };
@@ -114,10 +114,17 @@ class DynamicSpace extends static_space_1.StaticSpace {
114
114
  }
115
115
  }
116
116
  this.sourceDef = { ...this.fromSource, fields: [] };
117
- // This is a freshly built (modified) source: it presents a new exported
118
- // shape, so it is no longer a reference to the source it was built from.
119
- // DefineSource resets referenceID to this source's own sourceID.
117
+ // A freshly built (modified) source presents a new exported shape, so it
118
+ // is neither a reference to what it was built from nor that source's own
119
+ // definition. Both identities go; `DefineSource` stamps fresh ones if
120
+ // this ends up with a name, and an inline `extend` never does.
121
+ //
122
+ // Dropping `sourceID` also means the persistence walk descends *through*
123
+ // an unnamed modification rather than resolving it by id — which is how
124
+ // an inline `extend` used as a query's structRef stopped hiding the
125
+ // sources it added.
120
126
  delete this.sourceDef.referenceID;
127
+ delete this.sourceDef.sourceID;
121
128
  this.sourceDef.parameters = parameters;
122
129
  const fieldIndices = new Map();
123
130
  // Need to process the entities in specific order
@@ -141,6 +148,16 @@ class DynamicSpace extends static_space_1.StaticSpace {
141
148
  if (field instanceof join_space_field_1.JoinSpaceField) {
142
149
  const joinStruct = field.join.getStructDef(parameterSpace);
143
150
  if (!error_factory_1.ErrorFactory.didCreate(joinStruct)) {
151
+ // A query runs on one connection, so everything reachable from
152
+ // the source it runs on must live on that connection. Record and
153
+ // array joins are part of the row, and so have no connection.
154
+ // A base whose schema could not be fetched has the error
155
+ // connection, which is not worth complaining about twice.
156
+ if (model.isSourceDef(joinStruct) &&
157
+ !error_factory_1.ErrorFactory.didCreate(this.fromSource) &&
158
+ joinStruct.connection !== this.connectionName()) {
159
+ field.join.sourceExpr.logError('join-connection-mismatch', `Cannot join '${name}', which is on connection '${joinStruct.connection}', into a source on connection '${this.connectionName()}'`);
160
+ }
144
161
  fieldIndices.set(name, this.sourceDef.fields.length);
145
162
  this.sourceDef.fields.push(joinStruct);
146
163
  field.join.fixupJoinOn(this, joinStruct);
@@ -18,4 +18,5 @@ export declare class ParameterSpace implements FieldSpace {
18
18
  dialectObj(): Dialect | undefined;
19
19
  isQueryFieldSpace(): this is QueryFieldSpace;
20
20
  accessProtectionLevel(): AccessModifierLabel;
21
+ generation(): number;
21
22
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ParameterSpace = void 0;
8
+ const field_space_1 = require("../types/field-space");
8
9
  const space_param_1 = require("../types/space-param");
9
10
  class ParameterSpace {
10
11
  constructor(parameters) {
@@ -80,6 +81,11 @@ class ParameterSpace {
80
81
  accessProtectionLevel() {
81
82
  return 'private';
82
83
  }
84
+ // Bindings are fixed by the constructor and never change, so this space
85
+ // contributes no invalidation of its own.
86
+ generation() {
87
+ return (0, field_space_1.currentGeneration)();
88
+ }
83
89
  }
84
90
  exports.ParameterSpace = ParameterSpace;
85
91
  //# sourceMappingURL=parameter-space.js.map
@@ -19,4 +19,5 @@ export declare class PassthroughSpace implements FieldSpace {
19
19
  inputSpace(): import("..").SourceFieldSpace;
20
20
  accessProtectionLevel(): AccessModifierLabel;
21
21
  connectionName(): string;
22
+ generation(): number;
22
23
  }
@@ -52,6 +52,9 @@ class PassthroughSpace {
52
52
  connectionName() {
53
53
  return this.realFS.connectionName();
54
54
  }
55
+ generation() {
56
+ return this.realFS.generation();
57
+ }
55
58
  }
56
59
  exports.PassthroughSpace = PassthroughSpace;
57
60
  //# sourceMappingURL=passthrough-space.js.map
@@ -18,6 +18,14 @@ export declare class StaticSpace implements FieldSpace {
18
18
  defToSpaceField(from: FieldDef): SpaceField;
19
19
  private get map();
20
20
  accessProtectionLevel(): AccessModifierLabel;
21
+ /**
22
+ * StaticSpace itself never rebinds anything after construction, but
23
+ * DynamicSpace extends it and the three mutators below are the whole
24
+ * write surface for both -- `memoMap` is private, and every caller
25
+ * goes through these. That is what makes "every rebinding bumps the
26
+ * generation" checkable rather than a hope.
27
+ */
28
+ generation(): number;
21
29
  protected dropEntries(): void;
22
30
  protected dropEntry(name: string): void;
23
31
  entry(name: string): SpaceEntry | undefined;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.StaticSourceSpace = exports.StructSpaceField = exports.StaticSpace = void 0;
8
8
  const dialect_map_1 = require("../../../dialect/dialect_map");
9
9
  const malloy_types_1 = require("../../../model/malloy_types");
10
+ const field_space_1 = require("../types/field-space");
10
11
  const space_param_1 = require("../types/space-param");
11
12
  const space_field_1 = require("../types/space-field");
12
13
  const struct_space_field_base_1 = require("./struct-space-field-base");
@@ -64,10 +65,22 @@ class StaticSpace {
64
65
  accessProtectionLevel() {
65
66
  return 'internal';
66
67
  }
68
+ /**
69
+ * StaticSpace itself never rebinds anything after construction, but
70
+ * DynamicSpace extends it and the three mutators below are the whole
71
+ * write surface for both -- `memoMap` is private, and every caller
72
+ * goes through these. That is what makes "every rebinding bumps the
73
+ * generation" checkable rather than a hope.
74
+ */
75
+ generation() {
76
+ return (0, field_space_1.currentGeneration)();
77
+ }
67
78
  dropEntries() {
79
+ (0, field_space_1.noteRebinding)();
68
80
  this.memoMap = new Map();
69
81
  }
70
82
  dropEntry(name) {
83
+ (0, field_space_1.noteRebinding)();
71
84
  this.map.delete(name);
72
85
  }
73
86
  // TODO this was protected
@@ -75,6 +88,7 @@ class StaticSpace {
75
88
  return this.map.get(name);
76
89
  }
77
90
  setEntry(name, value) {
91
+ (0, field_space_1.noteRebinding)();
78
92
  this.map.set(name, value);
79
93
  }
80
94
  entries() {
@@ -94,7 +94,7 @@ class IndexBuilder {
94
94
  path: [],
95
95
  uniqueKeyRequirement: { isCount: true },
96
96
  });
97
- (0, malloy_types_1.setFieldUsage)(indexSegment, fieldUsage);
97
+ indexSegment.refSummary = { ...indexSegment.refSummary, fieldUsage };
98
98
  return indexSegment;
99
99
  }
100
100
  }
@@ -13,5 +13,5 @@ export declare class QueryArrow extends QueryBase implements QueryElement {
13
13
  readonly view: View;
14
14
  elementType: string;
15
15
  constructor(source: Source | QueryElement, view: View);
16
- queryComp(isRefOk: boolean): QueryComp;
16
+ queryComp(isRefOk: boolean, isPartialOk: boolean): QueryComp;
17
17
  }
@@ -10,6 +10,7 @@ const source_1 = require("../source-elements/source");
10
10
  const static_space_1 = require("../field-space/static-space");
11
11
  const query_base_1 = require("./query-base");
12
12
  const composite_source_utils_1 = require("../../composite-source-utils");
13
+ const query_utils_1 = require("../query-utils");
13
14
  /**
14
15
  * A query operation that adds segments to a LHS source or query.
15
16
  *
@@ -22,7 +23,7 @@ class QueryArrow extends query_base_1.QueryBase {
22
23
  this.view = view;
23
24
  this.elementType = 'arrow';
24
25
  }
25
- queryComp(isRefOk) {
26
+ queryComp(isRefOk, isPartialOk) {
26
27
  var _a;
27
28
  let inputStruct;
28
29
  let queryBase;
@@ -46,7 +47,9 @@ class QueryArrow extends query_base_1.QueryBase {
46
47
  }
47
48
  else {
48
49
  // We are adding a second stage to the given "source" query; we get the query and add a segment
49
- const lhsQuery = this.source.queryComp(isRefOk);
50
+ // The LHS stages are complete stages, nothing will refine them, so they
51
+ // are never allowed to be partial no matter what this caller accepts.
52
+ const lhsQuery = this.source.queryComp(isRefOk, false);
50
53
  queryBase = lhsQuery.query;
51
54
  inputStruct = lhsQuery.outputStruct;
52
55
  fieldSpace = new static_space_1.StaticSourceSpace(lhsQuery.outputStruct, 'public');
@@ -77,12 +80,15 @@ class QueryArrow extends query_base_1.QueryBase {
77
80
  : // Otherwise just use the `inputStruct`
78
81
  inputStruct, rhsPipeline),
79
82
  ];
83
+ const finalPipeline = isPartialOk
84
+ ? pipelineWithExpandedFieldUsage
85
+ : (0, query_utils_1.detectAndRemovePartialStages)(pipelineWithExpandedFieldUsage, this);
80
86
  return {
81
87
  query: {
82
88
  ...query,
83
89
  compositeResolvedSourceDef,
84
- pipeline: pipelineWithExpandedFieldUsage,
85
- givenUsage: (0, composite_source_utils_1.computeQueryGivenUsage)(pipelineWithExpandedFieldUsage),
90
+ pipeline: finalPipeline,
91
+ givenUsage: (0, composite_source_utils_1.computeQueryGivenUsage)(finalPipeline),
86
92
  },
87
93
  outputStruct,
88
94
  inputStruct,
@@ -2,7 +2,7 @@ import { type PipeSegment, type Query, type SourceDef } from '../../../model/mal
2
2
  import { MalloyElement } from '../types/malloy-element';
3
3
  import type { QueryComp } from '../types/query-comp';
4
4
  export declare abstract class QueryBase extends MalloyElement {
5
- abstract queryComp(isRefOk: boolean): QueryComp;
5
+ abstract queryComp(isRefOk: boolean, isPartialOk: boolean): QueryComp;
6
6
  protected expandRefUsage(inputSource: SourceDef, pipeline: PipeSegment[]): PipeSegment[];
7
7
  protected resolveCompositeSource(inputSource: SourceDef, pipeline: PipeSegment[]): SourceDef | undefined;
8
8
  query(isRefOk?: boolean): Query;
@@ -8,7 +8,6 @@ exports.QueryBase = void 0;
8
8
  const composite_source_utils_1 = require("../../composite-source-utils");
9
9
  const malloy_types_1 = require("../../../model/malloy_types");
10
10
  const error_factory_1 = require("../error-factory");
11
- const query_utils_1 = require("../query-utils");
12
11
  const malloy_element_1 = require("../types/malloy-element");
13
12
  class QueryBase extends malloy_element_1.MalloyElement {
14
13
  expandRefUsage(inputSource, pipeline) {
@@ -40,11 +39,7 @@ class QueryBase extends malloy_element_1.MalloyElement {
40
39
  return undefined;
41
40
  }
42
41
  query(isRefOk = true) {
43
- const { query } = this.queryComp(isRefOk);
44
- return {
45
- ...query,
46
- pipeline: (0, query_utils_1.detectAndRemovePartialStages)(query.pipeline, this),
47
- };
42
+ return this.queryComp(isRefOk, false).query;
48
43
  }
49
44
  }
50
45
  exports.QueryBase = QueryBase;
@@ -15,6 +15,6 @@ export declare class QueryRaw extends MalloyElement implements QueryElement {
15
15
  readonly source: Source;
16
16
  elementType: string;
17
17
  constructor(source: Source);
18
- queryComp(isRefOk: boolean): QueryComp;
18
+ queryComp(isRefOk: boolean, _isPartialOk: boolean): QueryComp;
19
19
  query(isRefOk?: boolean): Query;
20
20
  }