@malloydata/malloy 0.0.427 → 0.0.428

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 (90) hide show
  1. package/dist/lang/ast/expressions/apply.d.ts +1 -1
  2. package/dist/lang/ast/expressions/apply.js +2 -2
  3. package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
  4. package/dist/lang/ast/expressions/binary-boolean.js +1 -1
  5. package/dist/lang/ast/expressions/binary-numeric.d.ts +1 -1
  6. package/dist/lang/ast/expressions/binary-numeric.js +1 -1
  7. package/dist/lang/ast/expressions/boolean.d.ts +1 -1
  8. package/dist/lang/ast/expressions/boolean.js +1 -1
  9. package/dist/lang/ast/expressions/case.d.ts +1 -1
  10. package/dist/lang/ast/expressions/case.js +1 -1
  11. package/dist/lang/ast/expressions/constant-expression.d.ts +2 -1
  12. package/dist/lang/ast/expressions/constant-expression.js +6 -1
  13. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +1 -1
  14. package/dist/lang/ast/expressions/expr-aggregate-function.js +14 -7
  15. package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +1 -1
  16. package/dist/lang/ast/expressions/expr-alternation-tree.js +1 -1
  17. package/dist/lang/ast/expressions/expr-array-literal.d.ts +1 -1
  18. package/dist/lang/ast/expressions/expr-array-literal.js +1 -1
  19. package/dist/lang/ast/expressions/expr-cast.d.ts +1 -1
  20. package/dist/lang/ast/expressions/expr-cast.js +1 -1
  21. package/dist/lang/ast/expressions/expr-coalesce.d.ts +1 -1
  22. package/dist/lang/ast/expressions/expr-coalesce.js +1 -1
  23. package/dist/lang/ast/expressions/expr-compare.d.ts +4 -4
  24. package/dist/lang/ast/expressions/expr-compare.js +4 -4
  25. package/dist/lang/ast/expressions/expr-count.d.ts +1 -1
  26. package/dist/lang/ast/expressions/expr-count.js +1 -1
  27. package/dist/lang/ast/expressions/expr-filter-expr.d.ts +1 -1
  28. package/dist/lang/ast/expressions/expr-filter-expr.js +1 -1
  29. package/dist/lang/ast/expressions/expr-func.d.ts +1 -1
  30. package/dist/lang/ast/expressions/expr-func.js +1 -1
  31. package/dist/lang/ast/expressions/expr-given.d.ts +1 -1
  32. package/dist/lang/ast/expressions/expr-given.js +1 -1
  33. package/dist/lang/ast/expressions/expr-granular-time.d.ts +1 -1
  34. package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
  35. package/dist/lang/ast/expressions/expr-id-reference.d.ts +1 -1
  36. package/dist/lang/ast/expressions/expr-id-reference.js +1 -1
  37. package/dist/lang/ast/expressions/expr-minus.d.ts +1 -1
  38. package/dist/lang/ast/expressions/expr-minus.js +1 -1
  39. package/dist/lang/ast/expressions/expr-not.d.ts +1 -1
  40. package/dist/lang/ast/expressions/expr-not.js +1 -1
  41. package/dist/lang/ast/expressions/expr-now.d.ts +1 -1
  42. package/dist/lang/ast/expressions/expr-now.js +1 -1
  43. package/dist/lang/ast/expressions/expr-null.d.ts +3 -3
  44. package/dist/lang/ast/expressions/expr-null.js +14 -9
  45. package/dist/lang/ast/expressions/expr-number.d.ts +1 -1
  46. package/dist/lang/ast/expressions/expr-number.js +1 -1
  47. package/dist/lang/ast/expressions/expr-parens.d.ts +1 -1
  48. package/dist/lang/ast/expressions/expr-parens.js +5 -2
  49. package/dist/lang/ast/expressions/expr-props.d.ts +1 -1
  50. package/dist/lang/ast/expressions/expr-props.js +1 -1
  51. package/dist/lang/ast/expressions/expr-record-literal.d.ts +1 -1
  52. package/dist/lang/ast/expressions/expr-record-literal.js +1 -1
  53. package/dist/lang/ast/expressions/expr-regex.d.ts +1 -1
  54. package/dist/lang/ast/expressions/expr-regex.js +1 -1
  55. package/dist/lang/ast/expressions/expr-string.d.ts +1 -1
  56. package/dist/lang/ast/expressions/expr-string.js +1 -1
  57. package/dist/lang/ast/expressions/expr-time-extract.d.ts +1 -1
  58. package/dist/lang/ast/expressions/expr-time-extract.js +1 -1
  59. package/dist/lang/ast/expressions/expr-time.d.ts +1 -1
  60. package/dist/lang/ast/expressions/expr-time.js +1 -1
  61. package/dist/lang/ast/expressions/expr-ungroup.d.ts +1 -1
  62. package/dist/lang/ast/expressions/expr-ungroup.js +1 -1
  63. package/dist/lang/ast/expressions/for-range.d.ts +1 -1
  64. package/dist/lang/ast/expressions/for-range.js +1 -1
  65. package/dist/lang/ast/expressions/partial-compare.d.ts +1 -1
  66. package/dist/lang/ast/expressions/partial-compare.js +1 -1
  67. package/dist/lang/ast/expressions/pick-when.d.ts +1 -1
  68. package/dist/lang/ast/expressions/pick-when.js +1 -1
  69. package/dist/lang/ast/expressions/range.d.ts +1 -1
  70. package/dist/lang/ast/expressions/range.js +1 -1
  71. package/dist/lang/ast/expressions/time-literal.d.ts +2 -2
  72. package/dist/lang/ast/expressions/time-literal.js +2 -2
  73. package/dist/lang/ast/field-space/parameter-space.d.ts +1 -0
  74. package/dist/lang/ast/field-space/parameter-space.js +6 -0
  75. package/dist/lang/ast/field-space/passthrough-space.d.ts +1 -0
  76. package/dist/lang/ast/field-space/passthrough-space.js +3 -0
  77. package/dist/lang/ast/field-space/static-space.d.ts +8 -0
  78. package/dist/lang/ast/field-space/static-space.js +14 -0
  79. package/dist/lang/ast/query-builders/index-builder.js +1 -1
  80. package/dist/lang/ast/query-properties/drill.d.ts +1 -1
  81. package/dist/lang/ast/query-properties/drill.js +1 -1
  82. package/dist/lang/ast/types/expression-def.d.ts +50 -23
  83. package/dist/lang/ast/types/expression-def.js +127 -65
  84. package/dist/lang/ast/types/field-space.d.ts +14 -0
  85. package/dist/lang/ast/types/field-space.js +36 -0
  86. package/dist/model/malloy_types.d.ts +0 -13
  87. package/dist/model/malloy_types.js +0 -19
  88. package/dist/version.d.ts +1 -1
  89. package/dist/version.js +1 -1
  90. package/package.json +4 -4
@@ -7,5 +7,5 @@ export declare class Apply extends ExprCompare {
7
7
  readonly right: ExpressionDef;
8
8
  elementType: string;
9
9
  constructor(left: ExpressionDef, right: ExpressionDef);
10
- getExpression(fs: FieldSpace): ExprValue;
10
+ protected computeExpression(fs: FieldSpace): ExprValue;
11
11
  }
@@ -15,7 +15,7 @@ class Apply extends expr_compare_1.ExprCompare {
15
15
  this.right = right;
16
16
  this.elementType = 'apply';
17
17
  }
18
- getExpression(fs) {
18
+ computeExpression(fs) {
19
19
  let right = this.right;
20
20
  if (!this.right.granular()) {
21
21
  const rhs = this.right.requestExpression(fs);
@@ -27,7 +27,7 @@ class Apply extends expr_compare_1.ExprCompare {
27
27
  if (right instanceof expr_granular_time_1.ExprGranularTime) {
28
28
  return right.toRange(fs).apply(fs, this.op, this.left);
29
29
  }
30
- return super.getExpression(fs);
30
+ return super.computeExpression(fs);
31
31
  }
32
32
  }
33
33
  exports.Apply = Apply;
@@ -9,5 +9,5 @@ export declare abstract class BinaryBoolean<opType extends BinaryMalloyOperator>
9
9
  elementType: string;
10
10
  legalChildTypes: import("../../..").TypeDesc[];
11
11
  constructor(left: ExpressionDef, op: opType, right: ExpressionDef);
12
- getExpression(fs: FieldSpace): ExprValue;
12
+ protected computeExpression(fs: FieldSpace): ExprValue;
13
13
  }
@@ -52,7 +52,7 @@ class BinaryBoolean extends expression_def_1.ExpressionDef {
52
52
  this.elementType = 'abstract boolean binary';
53
53
  this.legalChildTypes = [TDU.boolT];
54
54
  }
55
- getExpression(fs) {
55
+ computeExpression(fs) {
56
56
  const left = this.left.getExpression(fs);
57
57
  const right = this.right.getExpression(fs);
58
58
  if (this.typeCheck(this.left, left) && this.typeCheck(this.right, right)) {
@@ -8,5 +8,5 @@ export declare abstract class BinaryNumeric<opType extends ArithmeticMalloyOpera
8
8
  readonly right: ExpressionDef;
9
9
  elementType: string;
10
10
  constructor(left: ExpressionDef, op: opType, right: ExpressionDef);
11
- getExpression(fs: FieldSpace): ExprValue;
11
+ protected computeExpression(fs: FieldSpace): ExprValue;
12
12
  }
@@ -49,7 +49,7 @@ class BinaryNumeric extends expression_def_1.ExpressionDef {
49
49
  this.elementType = 'numeric binary abstract';
50
50
  this.legalChildTypes = [TDU.numberT];
51
51
  }
52
- getExpression(fs) {
52
+ computeExpression(fs) {
53
53
  return this.right.apply(fs, this.op, this.left);
54
54
  }
55
55
  }
@@ -5,6 +5,6 @@ export declare class Boolean extends ExpressionDef {
5
5
  readonly value: 'true' | 'false';
6
6
  elementType: string;
7
7
  constructor(value: 'true' | 'false');
8
- getExpression(): ExprValue;
8
+ protected computeExpression(): ExprValue;
9
9
  getStableLiteral(): Malloy.LiteralValue;
10
10
  }
@@ -46,7 +46,7 @@ class Boolean extends expression_def_1.ExpressionDef {
46
46
  this.value = value;
47
47
  this.elementType = 'boolean literal';
48
48
  }
49
- getExpression() {
49
+ computeExpression() {
50
50
  return { ...TDU.boolT, value: { node: this.value } };
51
51
  }
52
52
  getStableLiteral() {
@@ -8,7 +8,7 @@ export declare class Case extends ExpressionDef {
8
8
  readonly elseValue?: ExpressionDef | undefined;
9
9
  elementType: string;
10
10
  constructor(value: ExpressionDef | undefined, choices: CaseWhen[], elseValue?: ExpressionDef | undefined);
11
- getExpression(fs: FieldSpace): ExprValue;
11
+ protected computeExpression(fs: FieldSpace): ExprValue;
12
12
  }
13
13
  export declare class CaseWhen extends MalloyElement {
14
14
  readonly when: ExpressionDef;
@@ -56,7 +56,7 @@ class Case extends expression_def_1.ExpressionDef {
56
56
  this.elementType = 'case';
57
57
  this.has({ elseValue, value });
58
58
  }
59
- getExpression(fs) {
59
+ computeExpression(fs) {
60
60
  const resultExpr = {
61
61
  node: 'case',
62
62
  kids: {
@@ -17,13 +17,14 @@ export declare class ConstantFieldSpace implements FieldSpace {
17
17
  connectionName(): string;
18
18
  isQueryFieldSpace(): this is QueryFieldSpace;
19
19
  accessProtectionLevel(): AccessModifierLabel;
20
+ generation(): number;
20
21
  }
21
22
  export declare class ConstantExpression extends ExpressionDef {
22
23
  readonly expr: ExpressionDef;
23
24
  elementType: string;
24
25
  private cfs?;
25
26
  constructor(expr: ExpressionDef);
26
- getExpression(_fs: FieldSpace): ExprValue;
27
+ protected computeExpression(_fs: FieldSpace): ExprValue;
27
28
  private get constantFs();
28
29
  constantValue(): ExprValue;
29
30
  apply(fs: FieldSpace, op: BinaryMalloyOperator, expr: ExpressionDef): ExprValue;
@@ -6,6 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ConstantExpression = exports.ConstantFieldSpace = void 0;
8
8
  const expression_def_1 = require("../types/expression-def");
9
+ const field_space_1 = require("../types/field-space");
9
10
  class ConstantFieldSpace {
10
11
  constructor() {
11
12
  this.type = 'fieldSpace';
@@ -46,6 +47,10 @@ class ConstantFieldSpace {
46
47
  accessProtectionLevel() {
47
48
  return 'private';
48
49
  }
50
+ // Binds nothing at all -- every lookup is an error.
51
+ generation() {
52
+ return (0, field_space_1.currentGeneration)();
53
+ }
49
54
  }
50
55
  exports.ConstantFieldSpace = ConstantFieldSpace;
51
56
  class ConstantExpression extends expression_def_1.ExpressionDef {
@@ -54,7 +59,7 @@ class ConstantExpression extends expression_def_1.ExpressionDef {
54
59
  this.expr = expr;
55
60
  this.elementType = 'constantExpression';
56
61
  }
57
- getExpression(_fs) {
62
+ computeExpression(_fs) {
58
63
  return this.constantValue();
59
64
  }
60
65
  get constantFs() {
@@ -13,7 +13,7 @@ export declare abstract class ExprAggregateFunction extends ExpressionDef {
13
13
  legalChildTypes: import("../../..").TypeDesc[];
14
14
  constructor(func: AggregateFunctionType, expr?: ExpressionDef, explicitSource?: boolean);
15
15
  abstract returns(fromExpr: ExprValue): ExprValue;
16
- getExpression(fs: FieldSpace): ExprValue;
16
+ protected computeExpression(fs: FieldSpace): ExprValue;
17
17
  isSymmetricFunction(): boolean;
18
18
  getJoinUsage(fs: FieldSpace): JoinPath[];
19
19
  }
@@ -59,7 +59,7 @@ class ExprAggregateFunction extends expression_def_1.ExpressionDef {
59
59
  this.has({ expr: expr });
60
60
  }
61
61
  }
62
- getExpression(fs) {
62
+ computeExpression(fs) {
63
63
  var _a, _b, _c;
64
64
  // It is never useful to use output fields in an aggregate expression
65
65
  // so we don't even allow them to be referenced at all
@@ -162,15 +162,22 @@ class ExprAggregateFunction extends expression_def_1.ExpressionDef {
162
162
  if (structPath && structPath.length > 0) {
163
163
  f.structPath = structPath;
164
164
  }
165
+ // `returns` is identity for sum and a shallow copy for avg, so
166
+ // returnExpr shares the operand's refSummary -- build a new one rather
167
+ // than writing into it.
165
168
  const returnExpr = this.returns(exprVal);
166
- if (!this.isSymmetricFunction()) {
167
- (0, malloy_types_1.setFieldUsage)(returnExpr, [
168
- ...(0, malloy_types_1.fieldUsageFrom)(returnExpr.refSummary),
169
- { path: structPath || [], uniqueKeyRequirement: { isCount: false } },
170
- ]);
171
- }
169
+ const refSummary = this.isSymmetricFunction()
170
+ ? returnExpr.refSummary
171
+ : {
172
+ ...returnExpr.refSummary,
173
+ fieldUsage: [
174
+ ...(0, malloy_types_1.fieldUsageFrom)(returnExpr.refSummary),
175
+ { path: structPath || [], uniqueKeyRequirement: { isCount: false } },
176
+ ],
177
+ };
172
178
  return {
173
179
  ...returnExpr,
180
+ refSummary,
174
181
  expressionType: 'aggregate',
175
182
  value: f,
176
183
  evalSpace: 'output',
@@ -12,6 +12,6 @@ export declare class ExprAlternationTree extends ExpressionDef {
12
12
  equalityList(): ExpressionDef[];
13
13
  apply(fs: FieldSpace, applyOp: BinaryMalloyOperator, expr: ExpressionDef, warnOnComplexTree: boolean): 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
  }
@@ -86,7 +86,7 @@ class ExprAlternationTree extends expression_def_1.ExpressionDef {
86
86
  requestExpression(_fs) {
87
87
  return undefined;
88
88
  }
89
- getExpression(_fs) {
89
+ computeExpression(_fs) {
90
90
  return this.loggedErrorExpr('alternation-as-value', 'Alternation tree has no value');
91
91
  }
92
92
  atNodeType() {
@@ -5,5 +5,5 @@ export declare class ArrayLiteral extends ExpressionDef {
5
5
  readonly elements: ExpressionDef[];
6
6
  elementType: string;
7
7
  constructor(elements: ExpressionDef[]);
8
- getExpression(fs: FieldSpace): ExprValue;
8
+ protected computeExpression(fs: FieldSpace): ExprValue;
9
9
  }
@@ -49,7 +49,7 @@ class ArrayLiteral extends expression_def_1.ExpressionDef {
49
49
  this.elementType = 'array literal';
50
50
  this.has({ elements });
51
51
  }
52
- getExpression(fs) {
52
+ computeExpression(fs) {
53
53
  const values = [];
54
54
  const fromValues = [];
55
55
  let firstValue = undefined;
@@ -12,5 +12,5 @@ export declare class ExprCast extends ExpressionDef {
12
12
  constructor(expr: ExpressionDef, castType: AtomicTypeDef | {
13
13
  raw: string;
14
14
  }, safe?: boolean);
15
- getExpression(fs: FieldSpace): ExprValue;
15
+ protected computeExpression(fs: FieldSpace): ExprValue;
16
16
  }
@@ -18,7 +18,7 @@ class ExprCast extends expression_def_1.ExpressionDef {
18
18
  }
19
19
  // TODO: Validate senseless casts (e.g. scalar to record) at translate time
20
20
  // for better error messages than what the dialect/database produces.
21
- getExpression(fs) {
21
+ computeExpression(fs) {
22
22
  const expr = this.expr.getExpression(fs);
23
23
  let dataType = { type: 'error' };
24
24
  if ('type' in this.castType) {
@@ -7,5 +7,5 @@ export declare class ExprCoalesce extends ExpressionDef {
7
7
  elementType: string;
8
8
  legalChildTypes: import("../../..").TypeDesc[];
9
9
  constructor(expr: ExpressionDef, altExpr: ExpressionDef);
10
- getExpression(fs: FieldSpace): ExprValue;
10
+ protected computeExpression(fs: FieldSpace): ExprValue;
11
11
  }
@@ -50,7 +50,7 @@ class ExprCoalesce extends expression_def_1.ExpressionDef {
50
50
  this.elementType = 'coalesce expression';
51
51
  this.legalChildTypes = TDU.anyAtomicT;
52
52
  }
53
- getExpression(fs) {
53
+ computeExpression(fs) {
54
54
  const maybeNull = this.expr.getExpression(fs);
55
55
  const whenNull = this.altExpr.getExpression(fs);
56
56
  if (maybeNull.type === 'null') {
@@ -7,7 +7,7 @@ import type { GivenReference } from './expr-given';
7
7
  export declare class ExprCompare extends BinaryBoolean<CompareMalloyOperator> {
8
8
  elementType: string;
9
9
  constructor(left: ExpressionDef, op: CompareMalloyOperator, right: ExpressionDef);
10
- getExpression(fs: FieldSpace): ExprValue;
10
+ protected computeExpression(fs: FieldSpace): ExprValue;
11
11
  }
12
12
  /**
13
13
  * The parser makes equality nodes, an application of ?
@@ -18,7 +18,7 @@ export declare class ExprCompare extends BinaryBoolean<CompareMalloyOperator> {
18
18
  export declare class ExprEquality extends ExprCompare {
19
19
  elementType: string;
20
20
  constructor(left: ExpressionDef, op: EqualityMalloyOperator, right: ExpressionDef);
21
- getExpression(fs: FieldSpace): ExprValue;
21
+ protected computeExpression(fs: FieldSpace): ExprValue;
22
22
  apply(fs: FieldSpace, op: BinaryMalloyOperator, left: ExpressionDef): ExprValue;
23
23
  }
24
24
  export declare class ExprLegacyIn extends ExpressionDef {
@@ -27,7 +27,7 @@ export declare class ExprLegacyIn extends ExpressionDef {
27
27
  readonly choices: ExpressionDef[];
28
28
  elementType: string;
29
29
  constructor(expr: ExpressionDef, notIn: boolean, choices: ExpressionDef[]);
30
- getExpression(fs: FieldSpace): ExprValue;
30
+ protected computeExpression(fs: FieldSpace): ExprValue;
31
31
  }
32
32
  /**
33
33
  * `expr in $ARRAY_GIVEN` — runtime test of a basic-typed expression
@@ -41,5 +41,5 @@ export declare class ExprInGiven extends ExpressionDef {
41
41
  readonly givenRef: GivenReference;
42
42
  elementType: string;
43
43
  constructor(expr: ExpressionDef, notIn: boolean, givenRef: GivenReference);
44
- getExpression(fs: FieldSpace): ExprValue;
44
+ protected computeExpression(fs: FieldSpace): ExprValue;
45
45
  }
@@ -61,7 +61,7 @@ class ExprCompare extends binary_boolean_1.BinaryBoolean {
61
61
  this.elementType = 'a<=>b';
62
62
  this.legalChildTypes = compareTypes[op];
63
63
  }
64
- getExpression(fs) {
64
+ computeExpression(fs) {
65
65
  return this.right.apply(fs, this.op, this.left);
66
66
  }
67
67
  }
@@ -77,7 +77,7 @@ class ExprEquality extends ExprCompare {
77
77
  super(left, op, right);
78
78
  this.elementType = 'a~=b';
79
79
  }
80
- getExpression(fs) {
80
+ computeExpression(fs) {
81
81
  return this.right.apply(fs, this.op, this.left, true);
82
82
  }
83
83
  apply(fs, op, left) {
@@ -94,7 +94,7 @@ class ExprLegacyIn extends expression_def_1.ExpressionDef {
94
94
  this.elementType = 'in';
95
95
  this.has({ expr, choices });
96
96
  }
97
- getExpression(fs) {
97
+ computeExpression(fs) {
98
98
  const lookFor = this.expr.getExpression(fs);
99
99
  const oneOf = this.choices.map(e => e.getExpression(fs));
100
100
  return (0, expr_value_2.computedExprValue)({
@@ -124,7 +124,7 @@ class ExprInGiven extends expression_def_1.ExpressionDef {
124
124
  this.elementType = 'inGiven';
125
125
  this.has({ expr, givenRef });
126
126
  }
127
- getExpression(fs) {
127
+ computeExpression(fs) {
128
128
  const lookFor = this.expr.getExpression(fs);
129
129
  const givenVal = this.givenRef.getExpression(fs);
130
130
  // `in` is logically a boolean — every error path returns a
@@ -8,5 +8,5 @@ export declare class ExprCount extends ExprAggregateFunction {
8
8
  constructor(source?: FieldReference | undefined);
9
9
  defaultFieldName(): string | undefined;
10
10
  returns(ev: ExprValue): ExprValue;
11
- getExpression(_fs: FieldSpace): ExprValue;
11
+ protected computeExpression(_fs: FieldSpace): ExprValue;
12
12
  }
@@ -29,7 +29,7 @@ class ExprCount extends expr_aggregate_function_1.ExprAggregateFunction {
29
29
  refSummary: ev.refSummary,
30
30
  };
31
31
  }
32
- getExpression(_fs) {
32
+ computeExpression(_fs) {
33
33
  const ret = {
34
34
  node: 'aggregate',
35
35
  function: 'count',
@@ -4,5 +4,5 @@ export declare class ExprFilterExpression extends ExpressionDef {
4
4
  readonly filterText: string;
5
5
  elementType: string;
6
6
  constructor(filterText: string);
7
- getExpression(): ExprValue;
7
+ protected computeExpression(): ExprValue;
8
8
  }
@@ -12,7 +12,7 @@ class ExprFilterExpression extends expression_def_1.ExpressionDef {
12
12
  this.filterText = filterText;
13
13
  this.elementType = 'filter expression literal';
14
14
  }
15
- getExpression() {
15
+ computeExpression() {
16
16
  return {
17
17
  type: 'filter expression',
18
18
  value: { node: 'filterLiteral', filterSrc: this.filterText },
@@ -17,7 +17,7 @@ export declare class ExprFunc extends ExpressionDef {
17
17
  canSupportPartitionBy(): boolean;
18
18
  canSupportOrderBy(): boolean;
19
19
  canSupportLimit(): boolean;
20
- getExpression(fs: FieldSpace): ExprValue;
20
+ protected computeExpression(fs: FieldSpace): ExprValue;
21
21
  private findFunctionDef;
22
22
  getPropsExpression(fs: FieldSpace, props?: {
23
23
  partitionBys?: PartitionBy[];
@@ -79,7 +79,7 @@ class ExprFunc extends expression_def_1.ExpressionDef {
79
79
  canSupportLimit() {
80
80
  return true;
81
81
  }
82
- getExpression(fs) {
82
+ computeExpression(fs) {
83
83
  if (this.isRaw && this.isRestricted()) {
84
84
  const typeStr = this.explicitType
85
85
  ? (0, utils_1.typeDefToString)(this.explicitType)
@@ -14,5 +14,5 @@ export declare class GivenReference extends ExpressionDef {
14
14
  readonly name: string;
15
15
  elementType: string;
16
16
  constructor(name: string);
17
- getExpression(_fs: FieldSpace): ExprValue;
17
+ protected computeExpression(_fs: FieldSpace): ExprValue;
18
18
  }
@@ -23,7 +23,7 @@ class GivenReference extends expression_def_1.ExpressionDef {
23
23
  this.name = name;
24
24
  this.elementType = 'givenReference';
25
25
  }
26
- getExpression(_fs) {
26
+ computeExpression(_fs) {
27
27
  var _a;
28
28
  const doc = this.document();
29
29
  const entry = (_a = doc === null || doc === void 0 ? void 0 : doc.getEntry(this.name)) === null || _a === void 0 ? void 0 : _a.entry;
@@ -20,6 +20,6 @@ export declare class ExprGranularTime extends ExpressionDef {
20
20
  constructor(expr: ExpressionDef, units: TimestampUnit, truncate: boolean);
21
21
  granular(): boolean;
22
22
  drillExpression(): Malloy.Expression | undefined;
23
- getExpression(fs: FieldSpace): ExprValue;
23
+ protected computeExpression(fs: FieldSpace): ExprValue;
24
24
  toRange(fs: FieldSpace): Range;
25
25
  }
@@ -77,7 +77,7 @@ class ExprGranularTime extends expression_def_1.ExpressionDef {
77
77
  truncation: this.units,
78
78
  };
79
79
  }
80
- getExpression(fs) {
80
+ computeExpression(fs) {
81
81
  var _a;
82
82
  const timeframe = this.units;
83
83
  const exprVal = this.expr.getExpression(fs);
@@ -9,5 +9,5 @@ export declare class ExprIdReference extends ExpressionDef {
9
9
  constructor(fieldReference: FieldReference);
10
10
  get refString(): string;
11
11
  drillExpression(): Malloy.Expression | undefined;
12
- getExpression(fs: FieldSpace): ExprValue;
12
+ protected computeExpression(fs: FieldSpace): ExprValue;
13
13
  }
@@ -24,7 +24,7 @@ class ExprIdReference extends expression_def_1.ExpressionDef {
24
24
  path: this.fieldReference.path.slice(0, -1),
25
25
  };
26
26
  }
27
- getExpression(fs) {
27
+ computeExpression(fs) {
28
28
  const def = this.fieldReference.getField(fs);
29
29
  if (def.found) {
30
30
  // TODO Currently the join usage is always equivalent to the reference path here;
@@ -5,5 +5,5 @@ export declare class ExprMinus extends ExpressionDef {
5
5
  readonly expr: ExpressionDef;
6
6
  elementType: string;
7
7
  constructor(expr: ExpressionDef);
8
- getExpression(fs: FieldSpace): ExprValue;
8
+ protected computeExpression(fs: FieldSpace): ExprValue;
9
9
  }
@@ -48,7 +48,7 @@ class ExprMinus extends expression_def_1.ExpressionDef {
48
48
  this.elementType = 'unary minus';
49
49
  this.legalChildTypes = [TDU.numberT];
50
50
  }
51
- getExpression(fs) {
51
+ computeExpression(fs) {
52
52
  const expr = this.expr.getExpression(fs);
53
53
  if (TDU.typeIn(expr, this.legalChildTypes)) {
54
54
  return {
@@ -6,5 +6,5 @@ export declare class ExprNot extends Unary {
6
6
  elementType: string;
7
7
  legalChildTypes: import("../../..").TypeDesc[];
8
8
  constructor(expr: ExpressionDef);
9
- getExpression(fs: FieldSpace): ExprValue;
9
+ protected computeExpression(fs: FieldSpace): ExprValue;
10
10
  }
@@ -46,7 +46,7 @@ class ExprNot extends unary_1.Unary {
46
46
  this.elementType = 'not';
47
47
  this.legalChildTypes = [TDU.boolT, TDU.nullT];
48
48
  }
49
- getExpression(fs) {
49
+ computeExpression(fs) {
50
50
  var _a;
51
51
  const notThis = this.expr.getExpression(fs);
52
52
  if (((_a = fs.dialectObj()) === null || _a === void 0 ? void 0 : _a.booleanType) !== 'supported') {
@@ -3,5 +3,5 @@ import type { FieldSpace } from '../types/field-space';
3
3
  import { ExpressionDef } from '../types/expression-def';
4
4
  export declare class ExprNow extends ExpressionDef {
5
5
  elementType: string;
6
- getExpression(_fs: FieldSpace): ExprValue;
6
+ protected computeExpression(_fs: FieldSpace): ExprValue;
7
7
  }
@@ -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;