@malloydata/malloy 0.0.39-dev230613161129 → 0.0.39

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 (288) hide show
  1. package/dist/dialect/dialect.d.ts +9 -13
  2. package/dist/dialect/dialect.js +16 -3
  3. package/dist/dialect/dialect_map.d.ts +2 -0
  4. package/dist/dialect/dialect_map.js +61 -1
  5. package/dist/dialect/{duckdb.d.ts → duckdb/duckdb.d.ts} +8 -5
  6. package/dist/dialect/{duckdb.js → duckdb/duckdb.js} +21 -9
  7. package/dist/dialect/duckdb/functions/byte_length.d.ts +2 -0
  8. package/dist/dialect/duckdb/functions/byte_length.js +33 -0
  9. package/dist/dialect/duckdb/functions/div.d.ts +2 -0
  10. package/dist/dialect/duckdb/functions/div.js +38 -0
  11. package/dist/dialect/duckdb/functions/duckdb_functions.d.ts +1 -0
  12. package/dist/dialect/duckdb/functions/duckdb_functions.js +52 -0
  13. package/dist/dialect/duckdb/functions/ends_with.d.ts +2 -0
  14. package/dist/dialect/duckdb/functions/ends_with.js +35 -0
  15. package/dist/dialect/duckdb/functions/greatest_and_least.d.ts +3 -0
  16. package/dist/dialect/duckdb/functions/greatest_and_least.js +58 -0
  17. package/dist/dialect/duckdb/functions/index.d.ts +1 -0
  18. package/dist/dialect/duckdb/functions/index.js +28 -0
  19. package/dist/dialect/duckdb/functions/is_inf.d.ts +2 -0
  20. package/dist/dialect/duckdb/functions/is_inf.js +33 -0
  21. package/dist/dialect/duckdb/functions/is_nan.d.ts +2 -0
  22. package/dist/dialect/duckdb/functions/is_nan.js +33 -0
  23. package/dist/dialect/duckdb/functions/log.d.ts +2 -0
  24. package/dist/dialect/duckdb/functions/log.js +38 -0
  25. package/dist/dialect/duckdb/functions/rand.d.ts +2 -0
  26. package/dist/dialect/duckdb/functions/rand.js +31 -0
  27. package/dist/dialect/duckdb/functions/replace.d.ts +2 -0
  28. package/dist/dialect/duckdb/functions/replace.js +40 -0
  29. package/dist/dialect/duckdb/functions/trunc.d.ts +2 -0
  30. package/dist/dialect/duckdb/functions/trunc.js +39 -0
  31. package/dist/dialect/duckdb/functions/unicode.d.ts +2 -0
  32. package/dist/dialect/duckdb/functions/unicode.js +35 -0
  33. package/dist/dialect/duckdb/index.d.ts +1 -0
  34. package/dist/dialect/duckdb/index.js +40 -0
  35. package/dist/dialect/functions/all_functions.d.ts +8 -0
  36. package/dist/dialect/functions/all_functions.js +135 -0
  37. package/dist/dialect/functions/atan2.d.ts +2 -0
  38. package/dist/dialect/functions/atan2.js +33 -0
  39. package/dist/dialect/functions/avg_moving.d.ts +2 -0
  40. package/dist/dialect/functions/avg_moving.js +46 -0
  41. package/dist/dialect/functions/chr.d.ts +4 -0
  42. package/dist/dialect/functions/chr.js +45 -0
  43. package/dist/dialect/functions/coalesce.d.ts +2 -0
  44. package/dist/dialect/functions/coalesce.js +38 -0
  45. package/dist/dialect/functions/concat.d.ts +2 -0
  46. package/dist/dialect/functions/concat.js +38 -0
  47. package/dist/dialect/functions/div.d.ts +2 -0
  48. package/dist/dialect/functions/div.js +36 -0
  49. package/dist/dialect/functions/first_value_window.d.ts +3 -0
  50. package/dist/dialect/functions/first_value_window.js +49 -0
  51. package/dist/dialect/functions/function_map.d.ts +16 -0
  52. package/dist/dialect/functions/function_map.js +50 -0
  53. package/dist/dialect/functions/greatest_and_least.d.ts +3 -0
  54. package/dist/dialect/functions/greatest_and_least.js +44 -0
  55. package/dist/dialect/functions/ifnull.d.ts +2 -0
  56. package/dist/dialect/functions/ifnull.js +38 -0
  57. package/dist/dialect/functions/index.d.ts +2 -0
  58. package/dist/dialect/functions/index.js +28 -0
  59. package/dist/dialect/functions/is_inf.d.ts +2 -0
  60. package/dist/dialect/functions/is_inf.js +33 -0
  61. package/dist/dialect/functions/is_nan.d.ts +2 -0
  62. package/dist/dialect/functions/is_nan.js +33 -0
  63. package/dist/dialect/functions/lag.d.ts +2 -0
  64. package/dist/dialect/functions/lag.js +53 -0
  65. package/dist/dialect/functions/lead.d.ts +2 -0
  66. package/dist/dialect/functions/lead.js +50 -0
  67. package/dist/dialect/functions/length.d.ts +3 -0
  68. package/dist/dialect/functions/length.js +39 -0
  69. package/dist/dialect/functions/log.d.ts +2 -0
  70. package/dist/dialect/functions/log.js +35 -0
  71. package/dist/dialect/functions/lower.d.ts +2 -0
  72. package/dist/dialect/functions/lower.js +34 -0
  73. package/dist/dialect/functions/nullif.d.ts +2 -0
  74. package/dist/dialect/functions/nullif.js +42 -0
  75. package/dist/dialect/functions/pi.d.ts +2 -0
  76. package/dist/{lang/ast/types/type-desc.js → dialect/functions/pi.js} +7 -1
  77. package/dist/dialect/functions/pow.d.ts +2 -0
  78. package/dist/dialect/functions/pow.js +35 -0
  79. package/dist/dialect/functions/rand.d.ts +2 -0
  80. package/dist/dialect/functions/rand.js +31 -0
  81. package/dist/dialect/functions/rank.d.ts +2 -0
  82. package/dist/dialect/functions/rank.js +36 -0
  83. package/dist/dialect/functions/regexp_extract.d.ts +2 -0
  84. package/dist/dialect/functions/regexp_extract.js +41 -0
  85. package/dist/dialect/functions/repeat.d.ts +2 -0
  86. package/dist/dialect/functions/repeat.js +35 -0
  87. package/dist/dialect/functions/replace.d.ts +2 -0
  88. package/dist/dialect/functions/replace.js +42 -0
  89. package/dist/dialect/functions/reverse.d.ts +2 -0
  90. package/dist/dialect/functions/reverse.js +34 -0
  91. package/dist/dialect/functions/round.d.ts +2 -0
  92. package/dist/dialect/functions/round.js +40 -0
  93. package/dist/dialect/functions/row_number.d.ts +2 -0
  94. package/dist/dialect/functions/row_number.js +40 -0
  95. package/dist/dialect/functions/simple_numeric_functions.d.ts +15 -0
  96. package/dist/dialect/functions/simple_numeric_functions.js +60 -0
  97. package/dist/dialect/functions/starts_ends_with.d.ts +3 -0
  98. package/dist/dialect/functions/starts_ends_with.js +43 -0
  99. package/dist/dialect/functions/stddev.d.ts +2 -0
  100. package/dist/dialect/functions/stddev.js +34 -0
  101. package/dist/dialect/functions/strpos.d.ts +2 -0
  102. package/dist/dialect/functions/strpos.js +35 -0
  103. package/dist/dialect/functions/substr.d.ts +2 -0
  104. package/dist/dialect/functions/substr.js +37 -0
  105. package/dist/dialect/functions/sum_min_max_window.d.ts +7 -0
  106. package/dist/dialect/functions/sum_min_max_window.js +94 -0
  107. package/dist/dialect/functions/trim_functions.d.ts +4 -0
  108. package/dist/dialect/functions/trim_functions.js +42 -0
  109. package/dist/dialect/functions/trunc.d.ts +2 -0
  110. package/dist/dialect/functions/trunc.js +38 -0
  111. package/dist/dialect/functions/upper.d.ts +2 -0
  112. package/dist/dialect/functions/upper.js +34 -0
  113. package/dist/dialect/functions/util.d.ts +45 -0
  114. package/dist/dialect/functions/util.js +187 -0
  115. package/dist/dialect/index.d.ts +1 -1
  116. package/dist/dialect/index.js +2 -1
  117. package/dist/dialect/postgres/functions/byte_length.d.ts +2 -0
  118. package/dist/dialect/postgres/functions/byte_length.js +33 -0
  119. package/dist/dialect/postgres/functions/ends_with.d.ts +2 -0
  120. package/dist/dialect/postgres/functions/ends_with.js +38 -0
  121. package/dist/dialect/postgres/functions/greatest_and_least.d.ts +3 -0
  122. package/dist/dialect/postgres/functions/greatest_and_least.js +45 -0
  123. package/dist/dialect/postgres/functions/ifnull.d.ts +2 -0
  124. package/dist/dialect/postgres/functions/ifnull.js +40 -0
  125. package/dist/dialect/postgres/functions/index.d.ts +1 -0
  126. package/dist/dialect/postgres/functions/index.js +28 -0
  127. package/dist/dialect/postgres/functions/is_inf.d.ts +2 -0
  128. package/dist/dialect/postgres/functions/is_inf.js +34 -0
  129. package/dist/dialect/postgres/functions/is_nan.d.ts +2 -0
  130. package/dist/dialect/postgres/functions/is_nan.js +33 -0
  131. package/dist/dialect/postgres/functions/log.d.ts +2 -0
  132. package/dist/dialect/postgres/functions/log.js +37 -0
  133. package/dist/dialect/postgres/functions/postgres_functions.d.ts +1 -0
  134. package/dist/dialect/postgres/functions/postgres_functions.js +60 -0
  135. package/dist/dialect/postgres/functions/rand.d.ts +2 -0
  136. package/dist/dialect/postgres/functions/rand.js +31 -0
  137. package/dist/dialect/postgres/functions/regexp_extract.d.ts +2 -0
  138. package/dist/dialect/postgres/functions/regexp_extract.js +35 -0
  139. package/dist/dialect/postgres/functions/replace.d.ts +2 -0
  140. package/dist/dialect/postgres/functions/replace.js +40 -0
  141. package/dist/dialect/postgres/functions/round.d.ts +2 -0
  142. package/dist/dialect/postgres/functions/round.js +39 -0
  143. package/dist/dialect/postgres/functions/stddev.d.ts +2 -0
  144. package/dist/dialect/postgres/functions/stddev.js +37 -0
  145. package/dist/dialect/postgres/functions/substr.d.ts +2 -0
  146. package/dist/dialect/postgres/functions/substr.js +38 -0
  147. package/dist/dialect/postgres/functions/trunc.d.ts +2 -0
  148. package/dist/dialect/postgres/functions/trunc.js +40 -0
  149. package/dist/dialect/postgres/functions/unicode.d.ts +2 -0
  150. package/dist/dialect/postgres/functions/unicode.js +34 -0
  151. package/dist/dialect/postgres/index.d.ts +1 -0
  152. package/dist/dialect/postgres/index.js +40 -0
  153. package/dist/dialect/{postgres.d.ts → postgres/postgres.d.ts} +9 -5
  154. package/dist/dialect/{postgres.js → postgres/postgres.js} +24 -10
  155. package/dist/dialect/standardsql/functions/chr.d.ts +2 -0
  156. package/dist/dialect/standardsql/functions/chr.js +37 -0
  157. package/dist/dialect/standardsql/functions/index.d.ts +1 -0
  158. package/dist/dialect/standardsql/functions/index.js +28 -0
  159. package/dist/dialect/standardsql/functions/pi.d.ts +2 -0
  160. package/dist/dialect/standardsql/functions/pi.js +32 -0
  161. package/dist/dialect/standardsql/functions/standardsql_functions.d.ts +1 -0
  162. package/dist/dialect/standardsql/functions/standardsql_functions.js +33 -0
  163. package/dist/dialect/standardsql/index.d.ts +1 -0
  164. package/dist/dialect/standardsql/index.js +40 -0
  165. package/dist/dialect/{standardsql.d.ts → standardsql/standardsql.d.ts} +7 -4
  166. package/dist/dialect/{standardsql.js → standardsql/standardsql.js} +13 -11
  167. package/dist/index.d.ts +1 -1
  168. package/dist/lang/ast/ast-utils.js +1 -0
  169. package/dist/lang/ast/elements/define-query.js +1 -1
  170. package/dist/lang/ast/elements/import-statement.js +6 -1
  171. package/dist/lang/ast/executors/index-executor.d.ts +1 -1
  172. package/dist/lang/ast/executors/index-executor.js +2 -2
  173. package/dist/lang/ast/executors/project-executor.d.ts +1 -1
  174. package/dist/lang/ast/executors/project-executor.js +2 -2
  175. package/dist/lang/ast/executors/reduce-executor.d.ts +2 -4
  176. package/dist/lang/ast/executors/reduce-executor.js +8 -4
  177. package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
  178. package/dist/lang/ast/expressions/binary-boolean.js +2 -0
  179. package/dist/lang/ast/expressions/constant-sub-expression.js +10 -0
  180. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +2 -2
  181. package/dist/lang/ast/expressions/expr-aggregate-function.js +28 -2
  182. package/dist/lang/ast/expressions/expr-alternation-tree.js +1 -0
  183. package/dist/lang/ast/expressions/expr-cast.js +1 -0
  184. package/dist/lang/ast/expressions/expr-coalesce.d.ts +1 -1
  185. package/dist/lang/ast/expressions/expr-coalesce.js +1 -0
  186. package/dist/lang/ast/expressions/expr-count-distinct.d.ts +1 -1
  187. package/dist/lang/ast/expressions/expr-count.js +1 -0
  188. package/dist/lang/ast/expressions/expr-filter.d.ts +1 -1
  189. package/dist/lang/ast/expressions/expr-filter.js +1 -1
  190. package/dist/lang/ast/expressions/expr-func.d.ts +6 -1
  191. package/dist/lang/ast/expressions/expr-func.js +266 -16
  192. package/dist/lang/ast/expressions/expr-granular-time.d.ts +1 -1
  193. package/dist/lang/ast/expressions/expr-id-reference.js +12 -0
  194. package/dist/lang/ast/expressions/expr-logical-op.d.ts +1 -1
  195. package/dist/lang/ast/expressions/expr-max.d.ts +2 -2
  196. package/dist/lang/ast/expressions/expr-min.d.ts +2 -2
  197. package/dist/lang/ast/expressions/expr-not.d.ts +1 -1
  198. package/dist/lang/ast/expressions/expr-now.js +2 -0
  199. package/dist/lang/ast/expressions/expr-null.js +1 -0
  200. package/dist/lang/ast/expressions/expr-number.js +5 -1
  201. package/dist/lang/ast/expressions/expr-regex.js +4 -1
  202. package/dist/lang/ast/expressions/expr-string.js +1 -0
  203. package/dist/lang/ast/expressions/expr-time-extract.js +2 -0
  204. package/dist/lang/ast/expressions/expr-time.js +1 -0
  205. package/dist/lang/ast/expressions/expr-ungroup.d.ts +2 -2
  206. package/dist/lang/ast/expressions/expr-ungroup.js +15 -7
  207. package/dist/lang/ast/expressions/for-range.d.ts +1 -1
  208. package/dist/lang/ast/expressions/pick-when.js +7 -0
  209. package/dist/lang/ast/expressions/range.js +1 -0
  210. package/dist/lang/ast/expressions/time-literal.js +9 -3
  211. package/dist/lang/ast/field-space/column-space-field.d.ts +1 -2
  212. package/dist/lang/ast/field-space/dynamic-space.js +6 -4
  213. package/dist/lang/ast/field-space/field-definition-value.d.ts +1 -1
  214. package/dist/lang/ast/field-space/project-field-space.d.ts +2 -2
  215. package/dist/lang/ast/field-space/project-field-space.js +12 -13
  216. package/dist/lang/ast/field-space/query-space-field.d.ts +1 -2
  217. package/dist/lang/ast/field-space/query-space-field.js +1 -1
  218. package/dist/lang/ast/field-space/query-spaces.d.ts +16 -2
  219. package/dist/lang/ast/field-space/query-spaces.js +175 -10
  220. package/dist/lang/ast/field-space/reference-field.d.ts +3 -2
  221. package/dist/lang/ast/field-space/reference-field.js +8 -1
  222. package/dist/lang/ast/field-space/rename-space-field.d.ts +1 -2
  223. package/dist/lang/ast/field-space/static-space.d.ts +4 -3
  224. package/dist/lang/ast/field-space/static-space.js +4 -0
  225. package/dist/lang/ast/field-space/struct-space-field-base.d.ts +1 -2
  226. package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
  227. package/dist/lang/ast/field-space/wild-space-field.d.ts +1 -2
  228. package/dist/lang/ast/fragtype-utils.d.ts +1 -1
  229. package/dist/lang/ast/fragtype-utils.js +4 -3
  230. package/dist/lang/ast/index.d.ts +1 -0
  231. package/dist/lang/ast/index.js +1 -0
  232. package/dist/lang/ast/query-items/field-declaration.d.ts +40 -4
  233. package/dist/lang/ast/query-items/field-declaration.js +102 -3
  234. package/dist/lang/ast/query-items/field-references.d.ts +44 -2
  235. package/dist/lang/ast/query-items/field-references.js +110 -2
  236. package/dist/lang/ast/query-items/typecheck_utils.d.ts +10 -0
  237. package/dist/lang/ast/query-items/typecheck_utils.js +177 -0
  238. package/dist/lang/ast/query-properties/aggregate.js +0 -6
  239. package/dist/lang/ast/query-properties/calculate.d.ts +5 -0
  240. package/dist/lang/ast/query-properties/calculate.js +33 -0
  241. package/dist/lang/ast/query-properties/dimmensions.js +0 -3
  242. package/dist/lang/ast/query-properties/filters.js +6 -3
  243. package/dist/lang/ast/query-properties/group-by.js +0 -6
  244. package/dist/lang/ast/query-properties/measures.js +0 -3
  245. package/dist/lang/ast/query-properties/nest-reference.d.ts +2 -0
  246. package/dist/lang/ast/query-properties/nest-reference.js +23 -0
  247. package/dist/lang/ast/query-properties/ordering.d.ts +1 -1
  248. package/dist/lang/ast/query-properties/ordering.js +18 -8
  249. package/dist/lang/ast/query-properties/qop-desc.js +8 -4
  250. package/dist/lang/ast/query-properties/top.js +20 -6
  251. package/dist/lang/ast/sources/named-source.js +4 -0
  252. package/dist/lang/ast/sources/sql-source.js +5 -1
  253. package/dist/lang/ast/time-utils.d.ts +1 -2
  254. package/dist/lang/ast/types/expr-result.d.ts +1 -2
  255. package/dist/lang/ast/types/expression-def.d.ts +3 -4
  256. package/dist/lang/ast/types/expression-def.js +10 -2
  257. package/dist/lang/ast/types/field-space.d.ts +7 -0
  258. package/dist/lang/ast/types/global-name-space.d.ts +12 -0
  259. package/dist/lang/ast/types/global-name-space.js +51 -0
  260. package/dist/lang/ast/types/malloy-element.d.ts +1 -0
  261. package/dist/lang/ast/types/malloy-element.js +15 -2
  262. package/dist/lang/ast/types/query-property.d.ts +1 -2
  263. package/dist/lang/ast/types/query-property.js +2 -0
  264. package/dist/lang/ast/types/space-entry.d.ts +1 -1
  265. package/dist/lang/ast/types/space-field.d.ts +1 -2
  266. package/dist/lang/ast/types/space-field.js +5 -1
  267. package/dist/lang/ast/types/space-param.d.ts +1 -2
  268. package/dist/lang/ast/types/space-param.js +10 -2
  269. package/dist/lang/lib/Malloy/MalloyLexer.d.ts +138 -135
  270. package/dist/lang/lib/Malloy/MalloyLexer.js +1135 -1103
  271. package/dist/lang/lib/Malloy/MalloyParser.d.ts +252 -275
  272. package/dist/lang/lib/Malloy/MalloyParser.js +1753 -1905
  273. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +40 -103
  274. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +25 -64
  275. package/dist/lang/malloy-to-ast.d.ts +11 -7
  276. package/dist/lang/malloy-to-ast.js +90 -51
  277. package/dist/lang/parse-tree-walkers/document-symbol-walker.js +5 -2
  278. package/dist/lang/test/parse.spec.js +399 -18
  279. package/dist/lang/test/test-translator.d.ts +1 -0
  280. package/dist/lang/test/test-translator.js +5 -0
  281. package/dist/model/malloy_query.d.ts +13 -4
  282. package/dist/model/malloy_query.js +240 -76
  283. package/dist/model/malloy_types.d.ts +89 -18
  284. package/dist/model/malloy_types.js +88 -61
  285. package/dist/model/utils.d.ts +4 -0
  286. package/dist/model/utils.js +118 -1
  287. package/package.json +1 -1
  288. package/dist/lang/ast/types/type-desc.d.ts +0 -8
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.Calculate = void 0;
26
+ const malloy_element_1 = require("../types/malloy-element");
27
+ class Calculate extends malloy_element_1.ListOf {
28
+ constructor(members) {
29
+ super('calculate', members);
30
+ }
31
+ }
32
+ exports.Calculate = Calculate;
33
+ //# sourceMappingURL=calculate.js.map
@@ -27,9 +27,6 @@ const declare_fields_1 = require("./declare-fields");
27
27
  class Dimensions extends declare_fields_1.DeclareFields {
28
28
  constructor(dimensions) {
29
29
  super(dimensions, 'dimension');
30
- for (const dim of dimensions) {
31
- dim.isMeasure = false;
32
- }
33
30
  }
34
31
  }
35
32
  exports.Dimensions = Dimensions;
@@ -68,14 +68,17 @@ class Filter extends malloy_element_1.ListOf {
68
68
  // here allows better reflection of errors back to user.
69
69
  if (this.havingClause !== undefined) {
70
70
  if (this.havingClause) {
71
+ // TODO I don't understand how this is working currently? This seems to imply
72
+ // that a calculation is NOT allowed, but it is...? It appears maybe this code
73
+ // just isn't being called.
71
74
  if ((0, malloy_types_1.expressionIsCalculation)(fExpr.expressionType)) {
72
- oneElement.log('Aggregate or Analytical expression expected in HAVING filter');
75
+ oneElement.log('Aggregate or analytic expression expected in HAVING filter');
73
76
  continue;
74
77
  }
75
78
  }
76
79
  else {
77
- if (fExpr.expressionType !== 'scalar') {
78
- oneElement.log('Aggregate or Analytical expressions not allowed in WHERE');
80
+ if ((0, malloy_types_1.expressionIsCalculation)(fExpr.expressionType)) {
81
+ oneElement.log('Aggregate or analytic expressions not allowed in WHERE');
79
82
  continue;
80
83
  }
81
84
  }
@@ -23,16 +23,10 @@
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.GroupBy = void 0;
26
- const field_declaration_1 = require("../query-items/field-declaration");
27
26
  const malloy_element_1 = require("../types/malloy-element");
28
27
  class GroupBy extends malloy_element_1.ListOf {
29
28
  constructor(members) {
30
29
  super('groupBy', members);
31
- for (const el of members) {
32
- if (el instanceof field_declaration_1.FieldDeclaration) {
33
- el.isMeasure = false;
34
- }
35
- }
36
30
  }
37
31
  }
38
32
  exports.GroupBy = GroupBy;
@@ -27,9 +27,6 @@ const declare_fields_1 = require("./declare-fields");
27
27
  class Measures extends declare_fields_1.DeclareFields {
28
28
  constructor(measures) {
29
29
  super(measures, 'measure');
30
- for (const dim of measures) {
31
- dim.isMeasure = true;
32
- }
33
30
  }
34
31
  }
35
32
  exports.Measures = Measures;
@@ -1,7 +1,9 @@
1
+ import { TypeDesc } from '../../../model';
1
2
  import { FieldReference } from '../query-items/field-references';
2
3
  import { FieldName } from '../types/field-space';
3
4
  export declare class NestReference extends FieldReference {
4
5
  readonly name: FieldName;
5
6
  elementType: string;
6
7
  constructor(name: FieldName);
8
+ typecheck(type: TypeDesc): void;
7
9
  }
@@ -23,6 +23,7 @@
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.NestReference = void 0;
26
+ const model_1 = require("../../../model");
26
27
  const field_references_1 = require("../query-items/field-references");
27
28
  class NestReference extends field_references_1.FieldReference {
28
29
  constructor(name) {
@@ -30,6 +31,28 @@ class NestReference extends field_references_1.FieldReference {
30
31
  this.name = name;
31
32
  this.elementType = 'nestReference';
32
33
  }
34
+ typecheck(type) {
35
+ if (type.dataType !== 'turtle') {
36
+ let useInstead;
37
+ let kind;
38
+ if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
39
+ useInstead = 'a calculate';
40
+ kind = 'an analytic';
41
+ }
42
+ else if ((0, model_1.expressionIsScalar)(type.expressionType)) {
43
+ useInstead = 'a group_by or project';
44
+ kind = 'a scalar';
45
+ }
46
+ else if ((0, model_1.expressionIsAggregate)(type.expressionType)) {
47
+ useInstead = 'an aggregate';
48
+ kind = 'an aggregate';
49
+ }
50
+ else {
51
+ throw new Error(`Unexpected expression type ${type} not handled here`);
52
+ }
53
+ this.log(`Cannot use ${kind} field in a nest operation, did you mean to use ${useInstead} operation instead?`);
54
+ }
55
+ }
33
56
  }
34
57
  exports.NestReference = NestReference;
35
58
  //# sourceMappingURL=nest-reference.js.map
@@ -7,7 +7,7 @@ export declare class OrderBy extends MalloyElement {
7
7
  elementType: string;
8
8
  constructor(field: number | FieldName, dir?: "asc" | "desc" | undefined);
9
9
  get modelField(): string | number;
10
- getOrderBy(_fs: FieldSpace): ModelOrderBy;
10
+ getOrderBy(fs: FieldSpace): ModelOrderBy;
11
11
  }
12
12
  export declare class Ordering extends ListOf<OrderBy> {
13
13
  constructor(list: OrderBy[]);
@@ -23,6 +23,7 @@
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Ordering = exports.OrderBy = void 0;
26
+ const malloy_types_1 = require("../../../model/malloy_types");
26
27
  const field_space_1 = require("../types/field-space");
27
28
  const malloy_element_1 = require("../types/malloy-element");
28
29
  class OrderBy extends malloy_element_1.MalloyElement {
@@ -38,14 +39,23 @@ class OrderBy extends malloy_element_1.MalloyElement {
38
39
  get modelField() {
39
40
  return typeof this.field === 'number' ? this.field : this.field.refString;
40
41
  }
41
- getOrderBy(_fs) {
42
- // TODO jump-to-definition `fs` cannot currently `lookup` fields in the output space
43
- // if (this.field instanceof FieldName) {
44
- // const entry = this.field.getField(_fs);
45
- // if (entry.error) {
46
- // this.field.log(entry.error);
47
- // }
48
- // }
42
+ getOrderBy(fs) {
43
+ var _a, _b;
44
+ // TODO jump-to-definition now that we can lookup fields in the output space,
45
+ // we need to actually add the reference when we do so.
46
+ if (this.field instanceof field_space_1.FieldName && fs.isQueryFieldSpace()) {
47
+ const output = fs.outputSpace();
48
+ const entry = this.field.getField(output);
49
+ if (entry.error) {
50
+ this.field.log(entry.error);
51
+ }
52
+ if (((_a = entry.found) === null || _a === void 0 ? void 0 : _a.typeDesc().evalSpace) === 'input') {
53
+ this.log(`Unknown field ${this.field.refString} in output space`);
54
+ }
55
+ if ((0, malloy_types_1.expressionIsAnalytic)((_b = entry.found) === null || _b === void 0 ? void 0 : _b.typeDesc().expressionType)) {
56
+ this.log(`Illegal order by of analytic field ${this.field.refString}`);
57
+ }
58
+ }
49
59
  const orderElement = { field: this.modelField };
50
60
  if (this.dir) {
51
61
  orderElement.dir = this.dir;
@@ -97,11 +97,11 @@ class QOPDesc extends malloy_element_1.ListOf {
97
97
  switch (this.computeType()) {
98
98
  case 'aggregate':
99
99
  case 'grouping':
100
- return new reduce_executor_1.ReduceExecutor(baseFS);
100
+ return new reduce_executor_1.ReduceExecutor(baseFS, this.refineThis);
101
101
  case 'project':
102
- return new project_executor_1.ProjectExecutor(baseFS);
102
+ return new project_executor_1.ProjectExecutor(baseFS, this.refineThis);
103
103
  case 'index':
104
- return new index_executor_1.IndexExecutor(baseFS);
104
+ return new index_executor_1.IndexExecutor(baseFS, this.refineThis);
105
105
  }
106
106
  }
107
107
  getOp(inputFS, forPipeline) {
@@ -116,7 +116,11 @@ class QOPDesc extends malloy_element_1.ListOf {
116
116
  const segment = qex.finalize(this.refineThis);
117
117
  return {
118
118
  segment,
119
- outputSpace: () => new static_space_1.StaticSpace((0, struct_utils_1.opOutputStruct)(this, inputFS.structDef(), segment)),
119
+ outputSpace: () =>
120
+ // TODO someday we'd like to get rid of the call to opOutputStruct here.
121
+ // If the `qex.resultFS` is correct, then we should be able to just use that
122
+ // in a more direct way.
123
+ new static_space_1.StaticSpace((0, struct_utils_1.opOutputStruct)(this, inputFS.structDef(), segment)),
120
124
  };
121
125
  }
122
126
  }
@@ -36,19 +36,33 @@ class Top extends malloy_element_1.MalloyElement {
36
36
  this.has({ by: by });
37
37
  }
38
38
  getBy(fs) {
39
+ var _a, _b;
39
40
  if (this.by) {
40
41
  if (this.by instanceof field_space_1.FieldName) {
41
- // TODO jump-to-definition `fs` cannot currently `lookup` fields in the output space
42
- // const entry = this.by.getField(fs);
43
- // if (entry.error) {
44
- // this.by.log(entry.error);
45
- // }
42
+ if (fs.isQueryFieldSpace()) {
43
+ // TODO jump-to-definition now that we can lookup fields in the output space,
44
+ // we need to actually add the reference when we do so.
45
+ const output = fs.outputSpace();
46
+ const entry = this.by.getField(output);
47
+ if (entry.error) {
48
+ this.by.log(entry.error);
49
+ }
50
+ if (((_a = entry.found) === null || _a === void 0 ? void 0 : _a.typeDesc().evalSpace) === 'input') {
51
+ this.by.log(`Unknown field ${this.by.refString} in output space`);
52
+ }
53
+ if ((0, malloy_types_1.expressionIsAnalytic)((_b = entry.found) === null || _b === void 0 ? void 0 : _b.typeDesc().expressionType)) {
54
+ this.by.log(`Illegal order by of analytic field ${this.by.refString}`);
55
+ }
56
+ }
46
57
  return { by: 'name', name: this.by.refString };
47
58
  }
48
59
  else {
49
60
  const byExpr = this.by.getExpression(fs);
50
61
  if ((0, malloy_types_1.expressionIsAggregate)(byExpr.expressionType)) {
51
- this.log('top by expression must be an aggregate');
62
+ this.by.log('top by expression must be an aggregate');
63
+ }
64
+ if (byExpr.evalSpace === 'output') {
65
+ this.by.log('top by expression must be an output expression');
52
66
  }
53
67
  return { by: 'expression', e: (0, utils_1.compressExpr)(byExpr.value) };
54
68
  }
@@ -77,6 +77,10 @@ class NamedSource extends source_1.Source {
77
77
  this.log(`Must use 'from()' for query source '${this.refName}`);
78
78
  return;
79
79
  }
80
+ else if (entry.type === 'function') {
81
+ this.log(`Cannot construct a source from a function '${this.refName}`);
82
+ return;
83
+ }
80
84
  else if ((0, malloy_types_1.isSQLBlockStruct)(entry) && entry.declaredSQLBlock) {
81
85
  this.log(`Must use 'from_sql()' for sql source '${this.refName}`);
82
86
  return;
@@ -40,7 +40,11 @@ class SQLSource extends named_source_1.NamedSource {
40
40
  this.log(`Undefined from_sql source '${this.refName}'`);
41
41
  return;
42
42
  }
43
- if (entry.type === 'query') {
43
+ if (entry.type === 'function') {
44
+ this.log(`Cannot construct a source from a function '${this.refName}'`);
45
+ return;
46
+ }
47
+ else if (entry.type === 'query') {
44
48
  this.log(`Cannot use 'from_sql()' with a query '${this.refName}'`);
45
49
  return;
46
50
  }
@@ -1,6 +1,5 @@
1
- import { AtomicFieldType, Expr, Fragment, TimeFieldType, TimestampUnit } from '../../model/malloy_types';
1
+ import { AtomicFieldType, Expr, Fragment, TimeFieldType, TimestampUnit, FieldValueType } from '../../model/malloy_types';
2
2
  import { TimeResult } from './types/time-result';
3
- import { FieldValueType } from './types/type-desc';
4
3
  export declare function timeOffset(timeType: TimeFieldType, from: Expr, op: '+' | '-', n: Expr, timeframe: TimestampUnit): Expr;
5
4
  export declare function castTo(castType: AtomicFieldType, from: Expr, fromType: FieldValueType, safe?: boolean): Expr;
6
5
  export declare function castTimestampToDate(from: Expr, safe?: boolean): Expr;
@@ -1,5 +1,4 @@
1
- import { Fragment } from '../../../model/malloy_types';
2
- import { TypeDesc } from './type-desc';
1
+ import { Fragment, TypeDesc } from '../../../model/malloy_types';
3
2
  declare type MorphicValues = Record<string, Fragment[]>;
4
3
  export interface ExprResult extends TypeDesc {
5
4
  value: Fragment[];
@@ -1,7 +1,6 @@
1
- import { TimestampUnit } from '../../../model/malloy_types';
1
+ import { TimestampUnit, FieldValueType } from '../../../model/malloy_types';
2
2
  import { ExprValue } from './expr-value';
3
3
  import { FieldSpace } from './field-space';
4
- import { FieldValueType } from './type-desc';
5
4
  import { MalloyElement } from './malloy-element';
6
5
  /**
7
6
  * Root node for any element in an expression. These essentially
@@ -19,7 +18,7 @@ export declare abstract class ExpressionDef extends MalloyElement {
19
18
  * @param space Namespace for looking up field references
20
19
  */
21
20
  abstract getExpression(fs: FieldSpace): ExprValue;
22
- legalChildTypes: import("./type-desc").TypeDesc[];
21
+ legalChildTypes: import("../../../model/malloy_types").TypeDesc[];
23
22
  /**
24
23
  * Some operators want to give the right hand value a chance to
25
24
  * rewrite itself. This requests a translation for a rewrite,
@@ -51,7 +50,7 @@ export declare class ExprDuration extends ExpressionDef {
51
50
  readonly n: ExpressionDef;
52
51
  readonly timeframe: TimestampUnit;
53
52
  elementType: string;
54
- legalChildTypes: import("./type-desc").TypeDesc[];
53
+ legalChildTypes: import("../../../model/malloy_types").TypeDesc[];
55
54
  constructor(n: ExpressionDef, timeframe: TimestampUnit);
56
55
  apply(fs: FieldSpace, op: string, left: ExpressionDef): ExprValue;
57
56
  getExpression(_fs: FieldSpace): ExprValue;
@@ -117,6 +117,7 @@ class ExprDuration extends ExpressionDef {
117
117
  return (0, time_utils_1.timeResult)({
118
118
  dataType: 'timestamp',
119
119
  expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, num.expressionType),
120
+ evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, num.evalSpace),
120
121
  value: result,
121
122
  }, resultGranularity);
122
123
  }
@@ -124,6 +125,7 @@ class ExprDuration extends ExpressionDef {
124
125
  return (0, time_utils_1.timeResult)({
125
126
  dataType: 'date',
126
127
  expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, num.expressionType),
128
+ evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, num.evalSpace),
127
129
  value: (0, time_utils_1.timeOffset)('date', lhs.value, op, num.value, this.timeframe),
128
130
  }, resultGranularity);
129
131
  }
@@ -139,6 +141,7 @@ class ExprDuration extends ExpressionDef {
139
141
  dataType: 'duration',
140
142
  expressionType: 'scalar',
141
143
  value: ['__ERROR_DURATION_IS_NOT_A_VALUE__'],
144
+ evalSpace: 'constant',
142
145
  };
143
146
  }
144
147
  }
@@ -193,7 +196,7 @@ function regexEqual(left, right) {
193
196
  type: 'dialect',
194
197
  function: 'regexpMatch',
195
198
  expr: left.value,
196
- regexp: right.value[0].replace(/^r'/, "'"),
199
+ regexp: right.value,
197
200
  },
198
201
  ];
199
202
  }
@@ -205,7 +208,7 @@ function regexEqual(left, right) {
205
208
  type: 'dialect',
206
209
  function: 'regexpMatch',
207
210
  expr: right.value,
208
- regexp: left.value[0].replace(/^r'/, "'"),
211
+ regexp: left.value,
209
212
  },
210
213
  ];
211
214
  }
@@ -275,6 +278,7 @@ function equality(fs, left, op, right) {
275
278
  return {
276
279
  dataType: 'boolean',
277
280
  expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, rhs.expressionType),
281
+ evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, rhs.evalSpace),
278
282
  value,
279
283
  };
280
284
  }
@@ -290,6 +294,7 @@ function compare(fs, left, op, right) {
290
294
  return {
291
295
  dataType: 'boolean',
292
296
  expressionType,
297
+ evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, rhs.evalSpace),
293
298
  value: value,
294
299
  };
295
300
  }
@@ -317,6 +322,7 @@ function numeric(fs, left, op, right) {
317
322
  dataType: 'number',
318
323
  expressionType,
319
324
  value: (0, utils_1.compose)(lhs.value, op, rhs.value),
325
+ evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, rhs.evalSpace),
320
326
  };
321
327
  }
322
328
  left.log(`Non numeric('${lhs.dataType},${rhs.dataType}') value with '${op}'`);
@@ -395,6 +401,7 @@ function applyBinary(fs, left, op, right) {
395
401
  return {
396
402
  dataType: 'number',
397
403
  expressionType: (0, malloy_types_1.maxExpressionType)(num.expressionType, denom.expressionType),
404
+ evalSpace: (0, malloy_types_1.mergeEvalSpaces)(num.evalSpace, denom.evalSpace),
398
405
  value: [div],
399
406
  };
400
407
  }
@@ -412,6 +419,7 @@ function unsupportError(l, lhs, r, rhs) {
412
419
  dataType: lhs.dataType,
413
420
  expressionType: (0, malloy_types_1.maxExpressionType)(lhs.expressionType, rhs.expressionType),
414
421
  value: ["'unsupported operation'"],
422
+ evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, rhs.evalSpace),
415
423
  };
416
424
  if (lhs.dataType === 'unsupported') {
417
425
  l.log('Unsupported type not allowed in expression');
@@ -2,6 +2,7 @@ import { Dialect } from '../../../dialect/dialect';
2
2
  import { StructDef } from '../../../model/malloy_types';
3
3
  import { LookupResult } from './lookup-result';
4
4
  import { MalloyElement } from './malloy-element';
5
+ import { SpaceEntry } from './space-entry';
5
6
  /**
6
7
  * A FieldSpace is a hierarchy of namespaces, where the leaf nodes
7
8
  * are fields. A FieldSpace can lookup fields, and generate a StructDef
@@ -11,8 +12,14 @@ export interface FieldSpace {
11
12
  structDef(): StructDef;
12
13
  emptyStructDef(): StructDef;
13
14
  lookup(symbol: FieldName[]): LookupResult;
15
+ entry(symbol: string): SpaceEntry | undefined;
16
+ entries(): [string, SpaceEntry][];
14
17
  dialectObj(): Dialect | undefined;
15
18
  whenComplete: (step: () => void) => void;
19
+ isQueryFieldSpace(): this is QueryFieldSpace;
20
+ }
21
+ export interface QueryFieldSpace extends FieldSpace {
22
+ outputSpace(): FieldSpace;
16
23
  }
17
24
  export declare class FieldName extends MalloyElement {
18
25
  readonly name: string;
@@ -0,0 +1,12 @@
1
+ import { ModelEntry } from './model-entry';
2
+ import { NameSpace } from './name-space';
3
+ /**
4
+ * We may want to remove this in the future...
5
+ *
6
+ * This is a global namespace which exists in the root of all Documents
7
+ * and includes SQL function definitions.
8
+ */
9
+ export declare class GlobalNameSpace implements NameSpace {
10
+ getEntry(name: string): ModelEntry | undefined;
11
+ setEntry(_name: string, _value: ModelEntry, _exported: boolean): void;
12
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.GlobalNameSpace = void 0;
26
+ const dialect_1 = require("../../../dialect");
27
+ /**
28
+ * We may want to remove this in the future...
29
+ *
30
+ * This is a global namespace which exists in the root of all Documents
31
+ * and includes SQL function definitions.
32
+ */
33
+ class GlobalNameSpace {
34
+ getEntry(name) {
35
+ // TODO cache this or precompute this so we're not comparing/merging dialect
36
+ // overloads on every usage
37
+ const func = (0, dialect_1.getDialectFunction)(name);
38
+ if (func === undefined) {
39
+ return undefined;
40
+ }
41
+ return {
42
+ entry: func,
43
+ exported: false,
44
+ };
45
+ }
46
+ setEntry(_name, _value, _exported) {
47
+ throw new Error('The global namespace is immutable!');
48
+ }
49
+ }
50
+ exports.GlobalNameSpace = GlobalNameSpace;
51
+ //# sourceMappingURL=global-name-space.js.map
@@ -90,6 +90,7 @@ export declare class RunList extends ListOf<DocStatement> {
90
90
  */
91
91
  export declare class Document extends MalloyElement implements NameSpace {
92
92
  elementType: string;
93
+ globalNameSpace: NameSpace;
93
94
  documentModel: Record<string, ModelEntry>;
94
95
  queryList: Query[];
95
96
  sqlBlocks: SQLBlockStructDef[];
@@ -28,6 +28,7 @@ exports.Document = exports.RunList = exports.ListOf = exports.isDocStatement = e
28
28
  */
29
29
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
30
30
  const malloy_types_1 = require("../../../model/malloy_types");
31
+ const global_name_space_1 = require("./global-name-space");
31
32
  class MalloyElement {
32
33
  /**
33
34
  * @param kids All children passed to the constructor are not optional
@@ -297,6 +298,10 @@ class RunList extends ListOf {
297
298
  executeList(doc) {
298
299
  while (this.execCursor < this.elements.length) {
299
300
  if (doc.errorsExist()) {
301
+ // TODO make a better way to stop cascading errors -- this way means that if there are
302
+ // actual different errors in multiple places, we only see the first one. A better way
303
+ // might be to make things that have error pass all kinds of typechecks, which prevents
304
+ // the real cascade.
300
305
  // This stops cascading errors
301
306
  return;
302
307
  }
@@ -330,6 +335,7 @@ class Document extends MalloyElement {
330
335
  constructor(statements) {
331
336
  super();
332
337
  this.elementType = 'document';
338
+ this.globalNameSpace = new global_name_space_1.GlobalNameSpace();
333
339
  this.documentModel = {};
334
340
  this.queryList = [];
335
341
  this.sqlBlocks = [];
@@ -347,7 +353,9 @@ class Document extends MalloyElement {
347
353
  if (extendingModelDef) {
348
354
  for (const [nm, orig] of Object.entries(extendingModelDef.contents)) {
349
355
  const entry = (0, cloneDeep_1.default)(orig);
350
- if (entry.type === 'struct' || entry.type === 'query') {
356
+ if (entry.type === 'struct' ||
357
+ entry.type === 'query' ||
358
+ entry.type === 'function') {
351
359
  const exported = extendingModelDef.exports.includes(nm);
352
360
  this.setEntry(nm, { entry, exported });
353
361
  }
@@ -395,9 +403,14 @@ class Document extends MalloyElement {
395
403
  return true;
396
404
  }
397
405
  getEntry(str) {
398
- return this.documentModel[str];
406
+ var _a;
407
+ return (_a = this.globalNameSpace.getEntry(str)) !== null && _a !== void 0 ? _a : this.documentModel[str];
399
408
  }
400
409
  setEntry(str, ent) {
410
+ // TODO this error message is going to be in the wrong place everywhere...
411
+ if (this.globalNameSpace.getEntry(str) !== undefined) {
412
+ this.log(`Cannot redefine '${str}', which is in global namespace`);
413
+ }
401
414
  this.documentModel[str] = ent;
402
415
  }
403
416
  }
@@ -13,6 +13,5 @@ import { Ordering } from '../query-properties/ordering';
13
13
  import { ProjectStatement } from '../query-properties/project-statement';
14
14
  import { SampleProperty } from '../query-properties/sampling';
15
15
  import { Top } from '../query-properties/top';
16
- import { TimezoneStatement } from '../source-properties/timezone-statement';
17
- export declare type QueryProperty = Ordering | Top | Limit | Filter | Index | SampleProperty | Joins | DeclareFields | ProjectStatement | NestReference | NestDefinition | NestReference | Nests | Aggregate | GroupBy | TimezoneStatement;
16
+ export declare type QueryProperty = Ordering | Top | Limit | Filter | Index | SampleProperty | Joins | DeclareFields | ProjectStatement | NestReference | NestDefinition | NestReference | Nests | Aggregate | GroupBy;
18
17
  export declare function isQueryProperty(q: MalloyElement): q is QueryProperty;
@@ -37,6 +37,7 @@ const project_statement_1 = require("../query-properties/project-statement");
37
37
  const sampling_1 = require("../query-properties/sampling");
38
38
  const top_1 = require("../query-properties/top");
39
39
  const timezone_statement_1 = require("../source-properties/timezone-statement");
40
+ const calculate_1 = require("../query-properties/calculate");
40
41
  function isQueryProperty(q) {
41
42
  return (q instanceof ordering_1.Ordering ||
42
43
  q instanceof top_1.Top ||
@@ -48,6 +49,7 @@ function isQueryProperty(q) {
48
49
  q instanceof declare_fields_1.DeclareFields ||
49
50
  q instanceof project_statement_1.ProjectStatement ||
50
51
  q instanceof aggregate_1.Aggregate ||
52
+ q instanceof calculate_1.Calculate ||
51
53
  q instanceof nests_1.Nests ||
52
54
  (0, nest_1.isNestedQuery)(q) ||
53
55
  q instanceof group_by_1.GroupBy ||
@@ -1,4 +1,4 @@
1
- import { TypeDesc } from './type-desc';
1
+ import { TypeDesc } from '../../../model';
2
2
  export declare abstract class SpaceEntry {
3
3
  abstract typeDesc(): TypeDesc;
4
4
  abstract refType: 'field' | 'parameter';
@@ -1,7 +1,6 @@
1
- import { FieldDef, QueryFieldDef } from '../../../model/malloy_types';
1
+ import { FieldDef, QueryFieldDef, TypeDesc } from '../../../model/malloy_types';
2
2
  import { SpaceEntry } from './space-entry';
3
3
  import { FieldSpace } from './field-space';
4
- import { TypeDesc } from './type-desc';
5
4
  export declare abstract class SpaceField extends SpaceEntry {
6
5
  readonly refType = "field";
7
6
  protected fieldTypeFromFieldDef(def: FieldDef): TypeDesc;
@@ -31,7 +31,11 @@ class SpaceField extends space_entry_1.SpaceEntry {
31
31
  this.refType = 'field';
32
32
  }
33
33
  fieldTypeFromFieldDef(def) {
34
- const ref = { dataType: def.type, expressionType: 'scalar' };
34
+ const ref = {
35
+ dataType: def.type,
36
+ expressionType: 'scalar',
37
+ evalSpace: 'input',
38
+ };
35
39
  if ((0, malloy_types_1.isFieldTypeDef)(def) && def.expressionType) {
36
40
  ref.expressionType = def.expressionType;
37
41
  }
@@ -1,7 +1,6 @@
1
- import { Parameter } from '../../../model/malloy_types';
1
+ import { Parameter, TypeDesc } from '../../../model/malloy_types';
2
2
  import { SpaceEntry } from './space-entry';
3
3
  import { HasParameter } from '../parameters/has-parameter';
4
- import { TypeDesc } from './type-desc';
5
4
  export declare abstract class SpaceParam extends SpaceEntry {
6
5
  abstract parameter(): Parameter;
7
6
  readonly refType = "parameter";