@malloydata/malloy 0.0.205-dev241028163321 → 0.0.205-dev241028173215

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 (88) hide show
  1. package/dist/dialect/functions/util.d.ts +16 -16
  2. package/dist/dialect/functions/util.js +16 -48
  3. package/dist/index.d.ts +1 -1
  4. package/dist/lang/ast/ast-utils.js +1 -1
  5. package/dist/lang/ast/expressions/binary-boolean.js +27 -4
  6. package/dist/lang/ast/expressions/binary-numeric.js +25 -2
  7. package/dist/lang/ast/expressions/boolean.js +25 -2
  8. package/dist/lang/ast/expressions/case.js +41 -20
  9. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +2 -2
  10. package/dist/lang/ast/expressions/expr-aggregate-function.js +30 -10
  11. package/dist/lang/ast/expressions/expr-alternation-tree.js +2 -2
  12. package/dist/lang/ast/expressions/expr-asymmetric.d.ts +2 -0
  13. package/dist/lang/ast/expressions/expr-asymmetric.js +3 -0
  14. package/dist/lang/ast/expressions/expr-cast.js +4 -6
  15. package/dist/lang/ast/expressions/expr-coalesce.js +30 -7
  16. package/dist/lang/ast/expressions/expr-compare.js +33 -10
  17. package/dist/lang/ast/expressions/expr-count-distinct.d.ts +2 -0
  18. package/dist/lang/ast/expressions/expr-count-distinct.js +34 -2
  19. package/dist/lang/ast/expressions/expr-count.d.ts +1 -0
  20. package/dist/lang/ast/expressions/expr-count.js +11 -1
  21. package/dist/lang/ast/expressions/expr-func.d.ts +3 -3
  22. package/dist/lang/ast/expressions/expr-func.js +41 -15
  23. package/dist/lang/ast/expressions/expr-granular-time.js +36 -14
  24. package/dist/lang/ast/expressions/expr-logical-op.js +25 -2
  25. package/dist/lang/ast/expressions/expr-max.d.ts +3 -4
  26. package/dist/lang/ast/expressions/expr-max.js +27 -4
  27. package/dist/lang/ast/expressions/expr-min.d.ts +3 -4
  28. package/dist/lang/ast/expressions/expr-min.js +27 -4
  29. package/dist/lang/ast/expressions/expr-minus.js +27 -4
  30. package/dist/lang/ast/expressions/expr-not.js +26 -3
  31. package/dist/lang/ast/expressions/expr-now.js +1 -1
  32. package/dist/lang/ast/expressions/expr-null.js +1 -1
  33. package/dist/lang/ast/expressions/expr-number.js +5 -1
  34. package/dist/lang/ast/expressions/expr-props.js +25 -2
  35. package/dist/lang/ast/expressions/expr-regex.js +1 -1
  36. package/dist/lang/ast/expressions/expr-string.js +1 -1
  37. package/dist/lang/ast/expressions/expr-time-extract.js +18 -18
  38. package/dist/lang/ast/expressions/expr-time.js +4 -4
  39. package/dist/lang/ast/expressions/expr-ungroup.d.ts +0 -2
  40. package/dist/lang/ast/expressions/expr-ungroup.js +26 -6
  41. package/dist/lang/ast/expressions/for-range.js +32 -9
  42. package/dist/lang/ast/expressions/pick-when.js +46 -25
  43. package/dist/lang/ast/expressions/range.js +1 -1
  44. package/dist/lang/ast/expressions/time-literal.js +9 -4
  45. package/dist/lang/ast/field-space/index-field-space.js +1 -3
  46. package/dist/lang/ast/field-space/project-field-space.d.ts +1 -1
  47. package/dist/lang/ast/field-space/project-field-space.js +2 -1
  48. package/dist/lang/ast/field-space/query-spaces.d.ts +1 -1
  49. package/dist/lang/ast/field-space/query-spaces.js +4 -3
  50. package/dist/lang/ast/field-space/reference-field.js +43 -10
  51. package/dist/lang/ast/field-space/rename-space-field.d.ts +2 -2
  52. package/dist/lang/ast/field-space/static-space.js +1 -1
  53. package/dist/lang/ast/field-space/struct-space-field-base.d.ts +2 -2
  54. package/dist/lang/ast/field-space/struct-space-field-base.js +40 -8
  55. package/dist/lang/ast/field-space/view-field.d.ts +2 -2
  56. package/dist/lang/ast/field-space/view-field.js +25 -1
  57. package/dist/lang/ast/parameters/has-parameter.d.ts +1 -1
  58. package/dist/lang/ast/parameters/has-parameter.js +8 -8
  59. package/dist/lang/ast/query-items/field-declaration.d.ts +2 -1
  60. package/dist/lang/ast/query-items/field-declaration.js +34 -9
  61. package/dist/lang/ast/query-items/typecheck_utils.js +11 -13
  62. package/dist/lang/ast/query-properties/filters.js +1 -1
  63. package/dist/lang/ast/source-elements/named-source.js +2 -2
  64. package/dist/lang/ast/source-properties/join.js +3 -3
  65. package/dist/lang/ast/time-utils.d.ts +2 -2
  66. package/dist/lang/ast/time-utils.js +6 -1
  67. package/dist/lang/ast/typedesc-utils.d.ts +48 -0
  68. package/dist/lang/ast/typedesc-utils.js +157 -0
  69. package/dist/lang/ast/types/expr-result.d.ts +2 -1
  70. package/dist/lang/ast/types/expr-value.d.ts +11 -36
  71. package/dist/lang/ast/types/expr-value.js +27 -13
  72. package/dist/lang/ast/types/expression-def.d.ts +3 -2
  73. package/dist/lang/ast/types/expression-def.js +84 -60
  74. package/dist/lang/ast/types/global-name-space.js +2 -2
  75. package/dist/lang/ast/types/granular-result.d.ts +2 -2
  76. package/dist/lang/ast/types/granular-result.js +1 -1
  77. package/dist/lang/ast/types/space-field.js +2 -13
  78. package/dist/lang/ast/types/space-param.d.ts +3 -1
  79. package/dist/lang/ast/types/space-param.js +36 -4
  80. package/dist/lang/ast/types/time-result.d.ts +3 -4
  81. package/dist/lang/parse-log.d.ts +15 -15
  82. package/dist/lang/test/literals.spec.js +1 -1
  83. package/dist/lang/test/parse-expects.js +2 -2
  84. package/dist/model/malloy_types.d.ts +30 -32
  85. package/dist/model/malloy_types.js +25 -16
  86. package/package.json +1 -1
  87. package/dist/lang/ast/fragtype-utils.d.ts +0 -46
  88. package/dist/lang/ast/fragtype-utils.js +0 -115
@@ -21,24 +21,47 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
24
47
  Object.defineProperty(exports, "__esModule", { value: true });
25
48
  exports.ExprMinus = void 0;
26
49
  const ast_utils_1 = require("../ast-utils");
27
- const fragtype_utils_1 = require("../fragtype-utils");
50
+ const TDU = __importStar(require("../typedesc-utils"));
28
51
  const expression_def_1 = require("../types/expression-def");
29
52
  class ExprMinus extends expression_def_1.ExpressionDef {
30
53
  constructor(expr) {
31
54
  super({ expr: expr });
32
55
  this.expr = expr;
33
56
  this.elementType = 'unary minus';
34
- this.legalChildTypes = [fragtype_utils_1.FT.numberT];
57
+ this.legalChildTypes = [TDU.numberT];
35
58
  }
36
59
  getExpression(fs) {
37
60
  const expr = this.expr.getExpression(fs);
38
- if (fragtype_utils_1.FT.typeIn(expr, this.legalChildTypes)) {
61
+ if (TDU.typeIn(expr, this.legalChildTypes)) {
39
62
  return {
40
63
  ...expr,
41
- dataType: 'number',
64
+ type: 'number',
42
65
  value: { node: 'unary-', e: expr.value },
43
66
  };
44
67
  }
@@ -21,22 +21,45 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
24
47
  Object.defineProperty(exports, "__esModule", { value: true });
25
48
  exports.ExprNot = void 0;
26
- const fragtype_utils_1 = require("../fragtype-utils");
49
+ const TDU = __importStar(require("../typedesc-utils"));
27
50
  const unary_1 = require("./unary");
28
51
  class ExprNot extends unary_1.Unary {
29
52
  constructor(expr) {
30
53
  super(expr);
31
54
  this.elementType = 'not';
32
- this.legalChildTypes = [fragtype_utils_1.FT.boolT, fragtype_utils_1.FT.nullT];
55
+ this.legalChildTypes = [TDU.boolT, TDU.nullT];
33
56
  }
34
57
  getExpression(fs) {
35
58
  const notThis = this.expr.getExpression(fs);
36
59
  const doNot = this.typeCheck(this.expr, notThis);
37
60
  return {
38
61
  ...notThis,
39
- dataType: 'boolean',
62
+ type: 'boolean',
40
63
  value: { node: 'not', e: doNot ? notThis.value : { node: 'false' } },
41
64
  };
42
65
  }
@@ -31,7 +31,7 @@ class ExprNow extends expression_def_1.ExpressionDef {
31
31
  }
32
32
  getExpression(_fs) {
33
33
  return {
34
- dataType: 'timestamp',
34
+ type: 'timestamp',
35
35
  expressionType: 'scalar',
36
36
  // `now` is considered to be a constant, at least in the dialects we support today
37
37
  evalSpace: 'constant',
@@ -32,7 +32,7 @@ class ExprNULL extends expression_def_1.ExpressionDef {
32
32
  }
33
33
  getExpression() {
34
34
  return (0, expr_value_1.literalExprValue)({
35
- dataType: 'null',
35
+ dataType: { type: 'null' },
36
36
  value: { node: 'null' },
37
37
  });
38
38
  }
@@ -35,8 +35,12 @@ class ExprNumber extends expression_def_1.ExpressionDef {
35
35
  return this.constantExpression();
36
36
  }
37
37
  constantExpression() {
38
+ const n = Number(this.n);
39
+ const dataType = Number.isNaN(n)
40
+ ? { type: 'number' }
41
+ : { type: 'number', numberType: Number.isInteger(n) ? 'integer' : 'float' };
38
42
  return (0, expr_value_1.literalExprValue)({
39
- dataType: 'number',
43
+ dataType,
40
44
  value: { node: 'numberLiteral', literal: this.n },
41
45
  });
42
46
  }
@@ -21,11 +21,34 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
24
47
  Object.defineProperty(exports, "__esModule", { value: true });
25
48
  exports.ExprProps = void 0;
26
49
  const malloy_types_1 = require("../../../model/malloy_types");
27
50
  const ast_utils_1 = require("../ast-utils");
28
- const fragtype_utils_1 = require("../fragtype-utils");
51
+ const TDU = __importStar(require("../typedesc-utils"));
29
52
  const function_ordering_1 = require("./function-ordering");
30
53
  const limit_1 = require("../query-properties/limit");
31
54
  const partition_by_1 = require("./partition_by");
@@ -37,7 +60,7 @@ class ExprProps extends expression_def_1.ExpressionDef {
37
60
  this.expr = expr;
38
61
  this.statements = statements;
39
62
  this.elementType = 'expression with props';
40
- this.legalChildTypes = fragtype_utils_1.FT.anyAtomicT;
63
+ this.legalChildTypes = TDU.anyAtomicT;
41
64
  }
42
65
  getFilteredExpression(fs, expr, wheres) {
43
66
  if (wheres.length > 0) {
@@ -33,7 +33,7 @@ class ExprRegEx extends expression_def_1.ExpressionDef {
33
33
  }
34
34
  getExpression() {
35
35
  return (0, expr_value_1.literalExprValue)({
36
- dataType: 'regular expression',
36
+ dataType: { type: 'regular expression' },
37
37
  value: { node: 'regexpLiteral', literal: this.regex },
38
38
  });
39
39
  }
@@ -33,7 +33,7 @@ class ExprString extends expression_def_1.ExpressionDef {
33
33
  }
34
34
  getExpression(_fs) {
35
35
  return (0, expr_value_1.literalExprValue)({
36
- dataType: 'string',
36
+ dataType: { type: 'string' },
37
37
  value: { node: 'stringLiteral', literal: this.value },
38
38
  });
39
39
  }
@@ -53,24 +53,24 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
53
53
  if (from instanceof range_1.Range) {
54
54
  let first = from.first.getExpression(fs);
55
55
  let last = from.last.getExpression(fs);
56
- if (first.dataType === 'error' || last.dataType === 'error') {
56
+ if (first.type === 'error' || last.type === 'error') {
57
57
  return (0, expr_value_1.computedErrorExprValue)({
58
- dataType: 'number',
58
+ dataType: { type: 'number' },
59
59
  error: 'extract from error',
60
60
  from: [first, last],
61
61
  });
62
62
  }
63
- if (!(0, malloy_types_1.isTemporalField)(first.dataType)) {
64
- return from.first.loggedErrorExpr('invalid-type-for-time-extraction', `Can't extract ${extractTo} from '${first.dataType}'`);
63
+ if (!(0, malloy_types_1.isTemporalField)(first.type)) {
64
+ return from.first.loggedErrorExpr('invalid-type-for-time-extraction', `Can't extract ${extractTo} from '${first.type}'`);
65
65
  }
66
- if (!(0, malloy_types_1.isTemporalField)(last.dataType)) {
67
- return from.last.loggedErrorExpr('invalid-type-for-time-extraction', `Cannot extract ${extractTo} from '${last.dataType}'`);
66
+ if (!(0, malloy_types_1.isTemporalField)(last.type)) {
67
+ return from.last.loggedErrorExpr('invalid-type-for-time-extraction', `Cannot extract ${extractTo} from '${last.type}'`);
68
68
  }
69
- let valueType = first.dataType;
70
- if (first.dataType !== last.dataType) {
69
+ let valueType = first.type;
70
+ if (!malloy_types_1.TD.eq(first, last)) {
71
71
  let cannotMeasure = true;
72
72
  valueType = 'timestamp';
73
- if (first.dataType === 'date') {
73
+ if (first.type === 'date') {
74
74
  const newFirst = (0, expression_def_1.getMorphicValue)(first, 'timestamp');
75
75
  if (newFirst) {
76
76
  first = newFirst;
@@ -85,7 +85,7 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
85
85
  }
86
86
  }
87
87
  if (cannotMeasure) {
88
- return from.first.loggedErrorExpr('invalid-types-for-time-measurement', `Cannot measure from ${first.dataType} to ${last.dataType}`);
88
+ return from.first.loggedErrorExpr('invalid-types-for-time-measurement', `Cannot measure from ${first.type} to ${last.type}`);
89
89
  }
90
90
  }
91
91
  if (['week', 'month', 'quarter', 'year'].includes(extractTo)) {
@@ -95,7 +95,7 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
95
95
  return this.loggedErrorExpr('invalid-time-extraction-unit', `Cannot extract ${extractTo} from a range`);
96
96
  }
97
97
  return (0, expr_value_1.computedExprValue)({
98
- dataType: 'number',
98
+ dataType: { type: 'number', numberType: 'integer' },
99
99
  value: {
100
100
  node: 'timeDiff',
101
101
  units: extractTo,
@@ -109,23 +109,23 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
109
109
  }
110
110
  else {
111
111
  const argV = from.getExpression(fs);
112
- if ((0, malloy_types_1.isTemporalField)(argV.dataType)) {
112
+ if ((0, malloy_types_1.isTemporalField)(argV.type)) {
113
113
  return (0, expr_value_1.computedExprValue)({
114
- dataType: 'number',
114
+ dataType: { type: 'number', numberType: 'integer' },
115
115
  value: {
116
116
  node: 'extract',
117
- e: (0, malloy_types_1.mkTemporal)(argV.value, argV.dataType),
117
+ e: (0, malloy_types_1.mkTemporal)(argV.value, argV.type),
118
118
  units: extractTo,
119
119
  },
120
120
  from: [argV],
121
121
  });
122
122
  }
123
- if (argV.dataType !== 'error') {
124
- this.logError('unsupported-type-for-time-extraction', `${this.extractText}() requires time type, not '${argV.dataType}'`);
123
+ if (argV.type !== 'error') {
124
+ this.logError('unsupported-type-for-time-extraction', `${this.extractText}() requires time type, not '${argV.type}'`);
125
125
  }
126
126
  return (0, expr_value_1.computedErrorExprValue)({
127
- dataType: 'number',
128
- error: `${this.extractText} bad type ${argV.dataType}`,
127
+ dataType: { type: 'number', numberType: 'integer' },
128
+ error: `${this.extractText} bad type ${argV.type}`,
129
129
  from: [argV],
130
130
  });
131
131
  }
@@ -32,7 +32,7 @@ class ExprTime extends expression_def_1.ExpressionDef {
32
32
  this.elementType = 'timestampOrDate';
33
33
  this.elementType = timeType;
34
34
  this.translationValue = (0, expr_value_1.computedExprValue)({
35
- dataType: timeType,
35
+ dataType: { type: timeType },
36
36
  value,
37
37
  from: from !== null && from !== void 0 ? from : [],
38
38
  });
@@ -42,15 +42,15 @@ class ExprTime extends expression_def_1.ExpressionDef {
42
42
  }
43
43
  static fromValue(timeType, expr) {
44
44
  let value = expr.value;
45
- if (timeType !== expr.dataType) {
45
+ if (timeType !== expr.type) {
46
46
  const toTs = {
47
47
  node: 'cast',
48
48
  safe: false,
49
49
  dstType: { type: timeType },
50
50
  e: expr.value,
51
51
  };
52
- if ((0, malloy_types_1.isTemporalField)(expr.dataType)) {
53
- toTs.srcType = { type: expr.dataType };
52
+ if ((0, malloy_types_1.isTemporalField)(expr.type)) {
53
+ toTs.srcType = { type: expr.type };
54
54
  }
55
55
  value = toTs;
56
56
  }
@@ -1,4 +1,3 @@
1
- import { FieldValueType } from '../../../model/malloy_types';
2
1
  import { ExprValue } from '../types/expr-value';
3
2
  import { ExpressionDef } from '../types/expression-def';
4
3
  import { FieldName, FieldSpace } from '../types/field-space';
@@ -9,6 +8,5 @@ export declare class ExprUngroup extends ExpressionDef {
9
8
  legalChildTypes: import("../../../model/malloy_types").TypeDesc[];
10
9
  elementType: string;
11
10
  constructor(control: 'all' | 'exclude', expr: ExpressionDef, fields: FieldName[]);
12
- returns(_forExpression: ExprValue): FieldValueType;
13
11
  getExpression(fs: FieldSpace): ExprValue;
14
12
  }
@@ -21,11 +21,34 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
24
47
  Object.defineProperty(exports, "__esModule", { value: true });
25
48
  exports.ExprUngroup = void 0;
26
49
  const malloy_types_1 = require("../../../model/malloy_types");
27
50
  const query_spaces_1 = require("../field-space/query-spaces");
28
- const fragtype_utils_1 = require("../fragtype-utils");
51
+ const TDU = __importStar(require("../typedesc-utils"));
29
52
  const expression_def_1 = require("../types/expression-def");
30
53
  class ExprUngroup extends expression_def_1.ExpressionDef {
31
54
  constructor(control, expr, fields) {
@@ -33,12 +56,9 @@ class ExprUngroup extends expression_def_1.ExpressionDef {
33
56
  this.control = control;
34
57
  this.expr = expr;
35
58
  this.fields = fields;
36
- this.legalChildTypes = fragtype_utils_1.FT.anyAtomicT;
59
+ this.legalChildTypes = TDU.anyAtomicT;
37
60
  this.elementType = 'ungroup';
38
61
  }
39
- returns(_forExpression) {
40
- return 'number';
41
- }
42
62
  getExpression(fs) {
43
63
  const exprVal = this.expr.getExpression(fs);
44
64
  if (!(0, malloy_types_1.expressionIsAggregate)(exprVal.expressionType)) {
@@ -82,7 +102,7 @@ class ExprUngroup extends expression_def_1.ExpressionDef {
82
102
  ungroup.fields = dstFields;
83
103
  }
84
104
  return {
85
- dataType: this.returns(exprVal),
105
+ ...TDU.atomicDef(exprVal),
86
106
  expressionType: 'ungrouped_aggregate',
87
107
  value: ungroup,
88
108
  evalSpace: 'output',
@@ -21,10 +21,33 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
24
47
  Object.defineProperty(exports, "__esModule", { value: true });
25
48
  exports.ForRange = void 0;
26
49
  const ast_utils_1 = require("../ast-utils");
27
- const fragtype_utils_1 = require("../fragtype-utils");
50
+ const TDU = __importStar(require("../typedesc-utils"));
28
51
  const time_utils_1 = require("../time-utils");
29
52
  const expr_value_1 = require("../types/expr-value");
30
53
  const expression_def_1 = require("../types/expression-def");
@@ -37,7 +60,7 @@ class ForRange extends expression_def_1.ExpressionDef {
37
60
  this.duration = duration;
38
61
  this.timeframe = timeframe;
39
62
  this.elementType = 'forRange';
40
- this.legalChildTypes = [fragtype_utils_1.FT.timestampT, fragtype_utils_1.FT.dateT];
63
+ this.legalChildTypes = [TDU.timestampT, TDU.dateT];
41
64
  }
42
65
  apply(fs, op, expr) {
43
66
  const startV = this.from.getExpression(fs);
@@ -46,12 +69,12 @@ class ForRange extends expression_def_1.ExpressionDef {
46
69
  return (0, ast_utils_1.errorFor)('no time for range');
47
70
  }
48
71
  const nV = this.duration.getExpression(fs);
49
- if (nV.dataType !== 'number') {
50
- if (nV.dataType !== 'error') {
51
- this.logError('invalid-duration-quantity', `FOR duration count must be a number, not '${nV.dataType}'`);
72
+ if (nV.type !== 'number') {
73
+ if (nV.type !== 'error') {
74
+ this.logError('invalid-duration-quantity', `FOR duration count must be a number, not '${nV.type}'`);
52
75
  }
53
76
  return (0, expr_value_1.computedErrorExprValue)({
54
- dataType: 'boolean',
77
+ dataType: { type: 'boolean' },
55
78
  error: 'for not number',
56
79
  from: [startV, checkV],
57
80
  });
@@ -62,11 +85,11 @@ class ForRange extends expression_def_1.ExpressionDef {
62
85
  let rangeType = (0, time_utils_1.resolution)(units);
63
86
  // Next, if the beginning of the range is a timestamp, then we
64
87
  // also have to do the computation as a timestamp
65
- if (startV.dataType === 'timestamp') {
88
+ if (startV.type === 'timestamp') {
66
89
  rangeType = 'timestamp';
67
90
  }
68
91
  // everything is dates, do date math
69
- if (checkV.dataType === 'date' && rangeType === 'date') {
92
+ if (checkV.type === 'date' && rangeType === 'date') {
70
93
  const rangeStart = this.from;
71
94
  const rangeEndV = (0, time_utils_1.timeOffset)('date', startV.value, '+', nV.value, units);
72
95
  const rangeEnd = new expr_time_1.ExprTime('date', rangeEndV);
@@ -77,7 +100,7 @@ class ForRange extends expression_def_1.ExpressionDef {
77
100
  const applyTo = expr_time_1.ExprTime.fromValue('timestamp', checkV);
78
101
  let rangeStart = this.from;
79
102
  let from = startV.value;
80
- if (startV.dataType === 'date') {
103
+ if (startV.type === 'date') {
81
104
  const tsVersion = startV.morphic && startV.morphic['timestamp'];
82
105
  if (tsVersion) {
83
106
  from = tsVersion;
@@ -21,16 +21,37 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
36
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
37
+ }) : function(o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar = (this && this.__importStar) || function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
24
47
  Object.defineProperty(exports, "__esModule", { value: true });
25
48
  exports.PickWhen = exports.Pick = void 0;
26
- const fragtype_utils_1 = require("../fragtype-utils");
49
+ const TDU = __importStar(require("../typedesc-utils"));
27
50
  const expr_value_1 = require("../types/expr-value");
28
51
  const expression_def_1 = require("../types/expression-def");
29
52
  const malloy_element_1 = require("../types/malloy-element");
30
53
  function typeCoalesce(ev1, ev2) {
31
- return ev1 === undefined ||
32
- ev1.dataType === 'null' ||
33
- ev1.dataType === 'error'
54
+ return ev1 === undefined || ev1.type === 'null' || ev1.type === 'error'
34
55
  ? ev2
35
56
  : ev1;
36
57
  }
@@ -53,7 +74,7 @@ class Pick extends expression_def_1.ExpressionDef {
53
74
  return undefined;
54
75
  }
55
76
  const whenResp = c.when.requestExpression(fs);
56
- if (whenResp === undefined || whenResp.dataType !== 'boolean') {
77
+ if (whenResp === undefined || whenResp.type !== 'boolean') {
57
78
  // If when is not a boolean, we'll treat it like a partial compare
58
79
  return undefined;
59
80
  }
@@ -77,10 +98,10 @@ class Pick extends expression_def_1.ExpressionDef {
77
98
  ? choice.pick.getExpression(fs)
78
99
  : expr.getExpression(fs);
79
100
  dependents.push(whenExpr, thenExpr);
80
- if (returnType && !fragtype_utils_1.FT.typeEq(returnType, thenExpr, true)) {
101
+ if (returnType && !TDU.typeEq(returnType, thenExpr, true)) {
81
102
  return this.loggedErrorExpr('pick-type-does-not-match', {
82
- pickType: thenExpr.dataType,
83
- returnType: returnType.dataType,
103
+ pickType: thenExpr.type,
104
+ returnType: returnType.type,
84
105
  });
85
106
  }
86
107
  returnType = typeCoalesce(returnType, thenExpr);
@@ -93,24 +114,24 @@ class Pick extends expression_def_1.ExpressionDef {
93
114
  if (elseVal)
94
115
  dependents.push(elseVal);
95
116
  const defaultVal = elseVal !== null && elseVal !== void 0 ? elseVal : exprVal;
96
- returnType = typeCoalesce(returnType, defaultVal);
97
- if (!fragtype_utils_1.FT.typeEq(returnType, defaultVal, true)) {
117
+ const definedReturnType = typeCoalesce(returnType, defaultVal);
118
+ if (!TDU.typeEq(definedReturnType, defaultVal, true)) {
98
119
  if (this.elsePick) {
99
120
  return this.loggedErrorExpr('pick-else-type-does-not-match', {
100
- elseType: defaultVal.dataType,
101
- returnType: returnType.dataType,
121
+ elseType: defaultVal.type,
122
+ returnType: definedReturnType.type,
102
123
  });
103
124
  }
104
125
  else {
105
126
  return this.loggedErrorExpr('pick-default-type-does-not-match', {
106
- defaultType: defaultVal.dataType,
107
- returnType: returnType.dataType,
127
+ defaultType: defaultVal.type,
128
+ returnType: definedReturnType.type,
108
129
  });
109
130
  }
110
131
  }
111
132
  caseValue.kids.caseElse = defaultVal.value;
112
133
  return (0, expr_value_1.computedExprValue)({
113
- dataType: returnType.dataType,
134
+ dataType: definedReturnType,
114
135
  value: caseValue,
115
136
  from: dependents,
116
137
  });
@@ -143,15 +164,15 @@ class Pick extends expression_def_1.ExpressionDef {
143
164
  }
144
165
  let returnType;
145
166
  for (const aChoice of choiceValues) {
146
- if (!fragtype_utils_1.FT.typeEq(aChoice.when, fragtype_utils_1.FT.boolT)) {
167
+ if (!TDU.typeEq(aChoice.when, TDU.boolT)) {
147
168
  return this.loggedErrorExpr('pick-when-must-be-boolean', {
148
- whenType: aChoice.when.dataType,
169
+ whenType: aChoice.when.type,
149
170
  });
150
171
  }
151
- if (returnType && !fragtype_utils_1.FT.typeEq(returnType, aChoice.pick, true)) {
172
+ if (returnType && !TDU.typeEq(returnType, aChoice.pick, true)) {
152
173
  return this.loggedErrorExpr('pick-type-does-not-match', {
153
- pickType: aChoice.pick.dataType,
154
- returnType: returnType.dataType,
174
+ pickType: aChoice.pick.type,
175
+ returnType: returnType.type,
155
176
  });
156
177
  }
157
178
  returnType = typeCoalesce(returnType, aChoice.pick);
@@ -160,16 +181,16 @@ class Pick extends expression_def_1.ExpressionDef {
160
181
  }
161
182
  const defVal = this.elsePick.getExpression(fs);
162
183
  dependents.push(defVal);
163
- returnType = typeCoalesce(returnType, defVal);
164
- if (!fragtype_utils_1.FT.typeEq(returnType, defVal, true)) {
184
+ const definedReturnType = typeCoalesce(returnType, defVal);
185
+ if (!TDU.typeEq(definedReturnType, defVal, true)) {
165
186
  return this.elsePick.loggedErrorExpr('pick-else-type-does-not-match', {
166
- elseType: defVal.dataType,
167
- returnType: returnType.dataType,
187
+ elseType: defVal.type,
188
+ returnType: definedReturnType.type,
168
189
  });
169
190
  }
170
191
  pick.kids.caseElse = defVal.value;
171
192
  return (0, expr_value_1.computedExprValue)({
172
- dataType: returnType.dataType,
193
+ dataType: definedReturnType,
173
194
  value: pick,
174
195
  from: dependents,
175
196
  });
@@ -43,7 +43,7 @@ class Range extends expression_def_1.ExpressionDef {
43
43
  const fromValue = this.first.apply(fs, op1, expr);
44
44
  const toValue = this.last.apply(fs, op3, expr);
45
45
  return (0, expr_value_1.computedExprValue)({
46
- dataType: 'boolean',
46
+ dataType: { type: 'boolean' },
47
47
  value: {
48
48
  node: op2,
49
49
  kids: { left: fromValue.value, right: toValue.value },
@@ -82,7 +82,11 @@ class TimeLiteral extends expression_def_1.ExpressionDef {
82
82
  }
83
83
  makeValue(val, dataType) {
84
84
  const value = this.makeLiteral(val, dataType);
85
- return (0, expr_value_1.literalTimeResult)({ value, dataType, timeframe: this.units });
85
+ return (0, expr_value_1.literalTimeResult)({
86
+ value,
87
+ dataType: { type: dataType },
88
+ timeframe: this.units,
89
+ });
86
90
  }
87
91
  getExpression(_fs) {
88
92
  return this.makeValue(this.literalPart, this.timeType);
@@ -150,7 +154,7 @@ class GranularLiteral extends TimeLiteral {
150
154
  let rangeEnd = this.getNext();
151
155
  if (rangeEnd) {
152
156
  const testValue = left.getExpression(fs);
153
- if (testValue.dataType === 'timestamp') {
157
+ if (testValue.type === 'timestamp') {
154
158
  const newStart = (0, expression_def_1.getMorphicValue)(rangeStart, 'timestamp');
155
159
  const newEnd = (0, expression_def_1.getMorphicValue)(rangeEnd, 'timestamp');
156
160
  if (newStart && newEnd) {
@@ -161,8 +165,9 @@ class GranularLiteral extends TimeLiteral {
161
165
  return super.apply(fs, op, left);
162
166
  }
163
167
  }
164
- if ((0, malloy_types_1.isTemporalField)(testValue.dataType)) {
165
- const rangeType = testValue.dataType;
168
+ // Compiler is unsure about rangeEnd = newEnd for some reason
169
+ if (rangeEnd && (0, malloy_types_1.isTemporalField)(testValue.type)) {
170
+ const rangeType = testValue.type;
166
171
  const range = new range_1.Range(new expr_time_1.ExprTime(rangeType, rangeStart.value), new expr_time_1.ExprTime(rangeType, rangeEnd.value));
167
172
  return range.apply(fs, op, left);
168
173
  }