@malloydata/malloy 0.0.24-dev230224214106 → 0.0.24-dev230228224434

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 (310) hide show
  1. package/dist/connection_utils.js +10 -10
  2. package/dist/dialect/dialect.d.ts +2 -2
  3. package/dist/dialect/dialect.js +13 -13
  4. package/dist/dialect/dialect_map.d.ts +1 -1
  5. package/dist/dialect/duckdb.d.ts +3 -3
  6. package/dist/dialect/duckdb.js +44 -44
  7. package/dist/dialect/index.d.ts +6 -6
  8. package/dist/dialect/postgres.d.ts +3 -3
  9. package/dist/dialect/postgres.js +46 -46
  10. package/dist/dialect/standardsql.d.ts +4 -4
  11. package/dist/dialect/standardsql.js +51 -51
  12. package/dist/index.d.ts +10 -10
  13. package/dist/lang/ast/ast-utils.d.ts +1 -1
  14. package/dist/lang/ast/ast-utils.js +3 -3
  15. package/dist/lang/ast/elements/define-query.d.ts +3 -3
  16. package/dist/lang/ast/elements/define-query.js +6 -6
  17. package/dist/lang/ast/elements/define-source.d.ts +4 -4
  18. package/dist/lang/ast/elements/define-source.js +8 -8
  19. package/dist/lang/ast/elements/import-statement.d.ts +2 -2
  20. package/dist/lang/ast/elements/import-statement.js +7 -7
  21. package/dist/lang/ast/elements/pipeline-desc.d.ts +5 -5
  22. package/dist/lang/ast/elements/pipeline-desc.js +11 -11
  23. package/dist/lang/ast/elements/refined-source.d.ts +4 -4
  24. package/dist/lang/ast/elements/refined-source.js +6 -6
  25. package/dist/lang/ast/elements/source.d.ts +3 -3
  26. package/dist/lang/ast/elements/source.js +1 -1
  27. package/dist/lang/ast/error-factory.d.ts +1 -1
  28. package/dist/lang/ast/error-factory.js +15 -15
  29. package/dist/lang/ast/executors/index-executor.d.ts +7 -7
  30. package/dist/lang/ast/executors/index-executor.js +4 -4
  31. package/dist/lang/ast/executors/project-executor.d.ts +5 -5
  32. package/dist/lang/ast/executors/project-executor.js +2 -2
  33. package/dist/lang/ast/executors/reduce-executor.d.ts +8 -8
  34. package/dist/lang/ast/executors/reduce-executor.js +5 -5
  35. package/dist/lang/ast/expressions/apply.d.ts +2 -2
  36. package/dist/lang/ast/expressions/apply.js +1 -1
  37. package/dist/lang/ast/expressions/binary-boolean.d.ts +3 -3
  38. package/dist/lang/ast/expressions/binary-boolean.js +6 -6
  39. package/dist/lang/ast/expressions/binary-numeric.d.ts +3 -3
  40. package/dist/lang/ast/expressions/binary-numeric.js +2 -2
  41. package/dist/lang/ast/expressions/boolean.d.ts +4 -4
  42. package/dist/lang/ast/expressions/boolean.js +2 -2
  43. package/dist/lang/ast/expressions/constant-sub-expression.d.ts +4 -4
  44. package/dist/lang/ast/expressions/constant-sub-expression.js +12 -12
  45. package/dist/lang/ast/expressions/expr-add-sub.d.ts +2 -2
  46. package/dist/lang/ast/expressions/expr-add-sub.js +1 -1
  47. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +5 -5
  48. package/dist/lang/ast/expressions/expr-aggregate-function.js +15 -15
  49. package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +6 -6
  50. package/dist/lang/ast/expressions/expr-alternation-tree.js +6 -6
  51. package/dist/lang/ast/expressions/expr-asymmetric.d.ts +5 -5
  52. package/dist/lang/ast/expressions/expr-asymmetric.js +3 -3
  53. package/dist/lang/ast/expressions/expr-avg.d.ts +3 -3
  54. package/dist/lang/ast/expressions/expr-avg.js +2 -2
  55. package/dist/lang/ast/expressions/expr-cast.d.ts +4 -4
  56. package/dist/lang/ast/expressions/expr-cast.js +6 -6
  57. package/dist/lang/ast/expressions/expr-compare.d.ts +5 -5
  58. package/dist/lang/ast/expressions/expr-compare.js +9 -9
  59. package/dist/lang/ast/expressions/expr-count-distinct.d.ts +2 -2
  60. package/dist/lang/ast/expressions/expr-count-distinct.js +1 -1
  61. package/dist/lang/ast/expressions/expr-count.d.ts +4 -4
  62. package/dist/lang/ast/expressions/expr-count.js +10 -10
  63. package/dist/lang/ast/expressions/expr-filter.d.ts +4 -4
  64. package/dist/lang/ast/expressions/expr-filter.js +13 -13
  65. package/dist/lang/ast/expressions/expr-func.d.ts +3 -3
  66. package/dist/lang/ast/expressions/expr-func.js +8 -8
  67. package/dist/lang/ast/expressions/expr-granular-time.d.ts +4 -4
  68. package/dist/lang/ast/expressions/expr-granular-time.js +17 -17
  69. package/dist/lang/ast/expressions/expr-id-reference.d.ts +4 -4
  70. package/dist/lang/ast/expressions/expr-id-reference.js +11 -11
  71. package/dist/lang/ast/expressions/expr-logical-op.d.ts +2 -2
  72. package/dist/lang/ast/expressions/expr-logical-op.js +1 -1
  73. package/dist/lang/ast/expressions/expr-max.d.ts +4 -4
  74. package/dist/lang/ast/expressions/expr-max.js +1 -1
  75. package/dist/lang/ast/expressions/expr-min.d.ts +4 -4
  76. package/dist/lang/ast/expressions/expr-min.js +1 -1
  77. package/dist/lang/ast/expressions/expr-minus.d.ts +3 -3
  78. package/dist/lang/ast/expressions/expr-minus.js +5 -5
  79. package/dist/lang/ast/expressions/expr-mul-div.d.ts +2 -2
  80. package/dist/lang/ast/expressions/expr-mul-div.js +1 -1
  81. package/dist/lang/ast/expressions/expr-not.d.ts +4 -4
  82. package/dist/lang/ast/expressions/expr-not.js +3 -3
  83. package/dist/lang/ast/expressions/expr-now.d.ts +3 -3
  84. package/dist/lang/ast/expressions/expr-now.js +8 -8
  85. package/dist/lang/ast/expressions/expr-null.d.ts +2 -2
  86. package/dist/lang/ast/expressions/expr-null.js +4 -4
  87. package/dist/lang/ast/expressions/expr-number.d.ts +3 -3
  88. package/dist/lang/ast/expressions/expr-number.js +2 -2
  89. package/dist/lang/ast/expressions/expr-parens.d.ts +3 -3
  90. package/dist/lang/ast/expressions/expr-parens.js +3 -3
  91. package/dist/lang/ast/expressions/expr-regex.d.ts +2 -2
  92. package/dist/lang/ast/expressions/expr-regex.js +4 -4
  93. package/dist/lang/ast/expressions/expr-string.d.ts +3 -3
  94. package/dist/lang/ast/expressions/expr-string.js +8 -8
  95. package/dist/lang/ast/expressions/expr-sum.d.ts +3 -3
  96. package/dist/lang/ast/expressions/expr-sum.js +2 -2
  97. package/dist/lang/ast/expressions/expr-time-extract.d.ts +4 -4
  98. package/dist/lang/ast/expressions/expr-time-extract.js +30 -30
  99. package/dist/lang/ast/expressions/expr-time.d.ts +4 -4
  100. package/dist/lang/ast/expressions/expr-time.js +10 -10
  101. package/dist/lang/ast/expressions/expr-ungroup.d.ts +6 -6
  102. package/dist/lang/ast/expressions/expr-ungroup.js +13 -13
  103. package/dist/lang/ast/expressions/for-range.d.ts +4 -4
  104. package/dist/lang/ast/expressions/for-range.js +17 -17
  105. package/dist/lang/ast/expressions/granular-literal.d.ts +4 -4
  106. package/dist/lang/ast/expressions/granular-literal.js +34 -34
  107. package/dist/lang/ast/expressions/partial-compare.d.ts +4 -4
  108. package/dist/lang/ast/expressions/partial-compare.js +4 -4
  109. package/dist/lang/ast/expressions/pick-when.d.ts +4 -4
  110. package/dist/lang/ast/expressions/pick-when.js +32 -32
  111. package/dist/lang/ast/expressions/range.d.ts +3 -3
  112. package/dist/lang/ast/expressions/range.js +20 -20
  113. package/dist/lang/ast/expressions/time-frame.d.ts +2 -2
  114. package/dist/lang/ast/expressions/time-frame.js +3 -3
  115. package/dist/lang/ast/expressions/top-by.d.ts +4 -4
  116. package/dist/lang/ast/expressions/top-by.js +5 -5
  117. package/dist/lang/ast/expressions/unary.d.ts +1 -1
  118. package/dist/lang/ast/expressions/unary.js +1 -1
  119. package/dist/lang/ast/expressions/utils.d.ts +2 -2
  120. package/dist/lang/ast/expressions/utils.js +6 -6
  121. package/dist/lang/ast/field-space/column-space-field.d.ts +3 -3
  122. package/dist/lang/ast/field-space/dynamic-space.d.ts +7 -7
  123. package/dist/lang/ast/field-space/dynamic-space.js +2 -2
  124. package/dist/lang/ast/field-space/field-definition-value.d.ts +5 -5
  125. package/dist/lang/ast/field-space/index-field-space.d.ts +3 -3
  126. package/dist/lang/ast/field-space/index-field-space.js +4 -4
  127. package/dist/lang/ast/field-space/join-space-field.d.ts +3 -3
  128. package/dist/lang/ast/field-space/project-field-space.d.ts +2 -2
  129. package/dist/lang/ast/field-space/project-field-space.js +5 -5
  130. package/dist/lang/ast/field-space/query-field-struct.d.ts +3 -3
  131. package/dist/lang/ast/field-space/query-field-struct.js +1 -1
  132. package/dist/lang/ast/field-space/query-space-field.d.ts +4 -4
  133. package/dist/lang/ast/field-space/query-space-field.js +1 -1
  134. package/dist/lang/ast/field-space/query-spaces.d.ts +11 -11
  135. package/dist/lang/ast/field-space/query-spaces.js +8 -8
  136. package/dist/lang/ast/field-space/reference-field.d.ts +5 -5
  137. package/dist/lang/ast/field-space/reference-field.js +1 -1
  138. package/dist/lang/ast/field-space/refined-space.d.ts +4 -4
  139. package/dist/lang/ast/field-space/refined-space.js +2 -2
  140. package/dist/lang/ast/field-space/rename-space-field.d.ts +3 -3
  141. package/dist/lang/ast/field-space/rename-space-field.js +2 -2
  142. package/dist/lang/ast/field-space/static-space.d.ts +7 -7
  143. package/dist/lang/ast/field-space/static-space.js +12 -12
  144. package/dist/lang/ast/field-space/struct-space-field-base.d.ts +4 -4
  145. package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
  146. package/dist/lang/ast/field-space/wild-space-field.d.ts +4 -4
  147. package/dist/lang/ast/field-space/wild-space-field.js +1 -1
  148. package/dist/lang/ast/fragtype-utils.d.ts +1 -1
  149. package/dist/lang/ast/fragtype-utils.js +15 -15
  150. package/dist/lang/ast/index.d.ts +90 -90
  151. package/dist/lang/ast/parameters/constant-parameter.d.ts +3 -3
  152. package/dist/lang/ast/parameters/constant-parameter.js +10 -10
  153. package/dist/lang/ast/parameters/has-parameter.d.ts +3 -3
  154. package/dist/lang/ast/parameters/has-parameter.js +7 -7
  155. package/dist/lang/ast/query-elements/anonymous-query.d.ts +3 -3
  156. package/dist/lang/ast/query-elements/anonymous-query.js +2 -2
  157. package/dist/lang/ast/query-elements/existing-query.d.ts +4 -4
  158. package/dist/lang/ast/query-elements/existing-query.js +10 -10
  159. package/dist/lang/ast/query-elements/full-query.d.ts +4 -4
  160. package/dist/lang/ast/query-elements/full-query.js +10 -10
  161. package/dist/lang/ast/query-elements/query-head-struct.d.ts +2 -2
  162. package/dist/lang/ast/query-elements/query-head-struct.js +2 -2
  163. package/dist/lang/ast/query-items/field-declaration.d.ts +6 -6
  164. package/dist/lang/ast/query-items/field-declaration.js +14 -14
  165. package/dist/lang/ast/query-items/field-references.d.ts +6 -6
  166. package/dist/lang/ast/query-items/field-references.js +9 -9
  167. package/dist/lang/ast/query-properties/aggregate.d.ts +2 -2
  168. package/dist/lang/ast/query-properties/aggregate.js +1 -1
  169. package/dist/lang/ast/query-properties/declare-fields.d.ts +2 -2
  170. package/dist/lang/ast/query-properties/declare-fields.js +1 -1
  171. package/dist/lang/ast/query-properties/dimmensions.d.ts +2 -2
  172. package/dist/lang/ast/query-properties/dimmensions.js +1 -1
  173. package/dist/lang/ast/query-properties/filters.d.ts +4 -4
  174. package/dist/lang/ast/query-properties/filters.js +16 -16
  175. package/dist/lang/ast/query-properties/group-by.d.ts +2 -2
  176. package/dist/lang/ast/query-properties/group-by.js +1 -1
  177. package/dist/lang/ast/query-properties/indexing.d.ts +3 -3
  178. package/dist/lang/ast/query-properties/indexing.js +3 -3
  179. package/dist/lang/ast/query-properties/joins.d.ts +6 -6
  180. package/dist/lang/ast/query-properties/joins.js +27 -27
  181. package/dist/lang/ast/query-properties/limit.d.ts +1 -1
  182. package/dist/lang/ast/query-properties/limit.js +1 -1
  183. package/dist/lang/ast/query-properties/measures.d.ts +2 -2
  184. package/dist/lang/ast/query-properties/measures.js +1 -1
  185. package/dist/lang/ast/query-properties/nest-reference.d.ts +2 -2
  186. package/dist/lang/ast/query-properties/nest-reference.js +1 -1
  187. package/dist/lang/ast/query-properties/nest.d.ts +7 -7
  188. package/dist/lang/ast/query-properties/nest.js +7 -7
  189. package/dist/lang/ast/query-properties/nests.d.ts +2 -2
  190. package/dist/lang/ast/query-properties/nests.js +1 -1
  191. package/dist/lang/ast/query-properties/ordering.d.ts +3 -3
  192. package/dist/lang/ast/query-properties/ordering.js +6 -6
  193. package/dist/lang/ast/query-properties/project-statement.d.ts +2 -2
  194. package/dist/lang/ast/query-properties/project-statement.js +1 -1
  195. package/dist/lang/ast/query-properties/qop-desc.d.ts +7 -7
  196. package/dist/lang/ast/query-properties/qop-desc.js +20 -20
  197. package/dist/lang/ast/query-properties/sampling.d.ts +2 -2
  198. package/dist/lang/ast/query-properties/sampling.js +1 -1
  199. package/dist/lang/ast/query-properties/top.d.ts +4 -4
  200. package/dist/lang/ast/query-properties/top.js +5 -5
  201. package/dist/lang/ast/source-properties/field-list-edit.d.ts +4 -4
  202. package/dist/lang/ast/source-properties/field-list-edit.js +2 -2
  203. package/dist/lang/ast/source-properties/primary-key.d.ts +2 -2
  204. package/dist/lang/ast/source-properties/primary-key.js +2 -2
  205. package/dist/lang/ast/source-properties/renames.d.ts +2 -2
  206. package/dist/lang/ast/source-properties/renames.js +3 -3
  207. package/dist/lang/ast/source-properties/turtles.d.ts +2 -2
  208. package/dist/lang/ast/source-properties/turtles.js +1 -1
  209. package/dist/lang/ast/sources/named-source.d.ts +4 -4
  210. package/dist/lang/ast/sources/named-source.js +5 -5
  211. package/dist/lang/ast/sources/query-source.d.ts +3 -3
  212. package/dist/lang/ast/sources/query-source.js +3 -3
  213. package/dist/lang/ast/sources/sql-source.d.ts +2 -2
  214. package/dist/lang/ast/sources/sql-source.js +2 -2
  215. package/dist/lang/ast/sources/table-source.d.ts +2 -2
  216. package/dist/lang/ast/sources/table-source.js +7 -7
  217. package/dist/lang/ast/space-seed.d.ts +2 -2
  218. package/dist/lang/ast/space-seed.js +1 -1
  219. package/dist/lang/ast/sql-elements/sql-statement.d.ts +4 -4
  220. package/dist/lang/ast/sql-elements/sql-statement.js +9 -9
  221. package/dist/lang/ast/sql-elements/sql-string.d.ts +3 -3
  222. package/dist/lang/ast/sql-elements/sql-string.js +6 -6
  223. package/dist/lang/ast/struct-utils.d.ts +2 -2
  224. package/dist/lang/ast/struct-utils.js +3 -3
  225. package/dist/lang/ast/time-utils.d.ts +6 -6
  226. package/dist/lang/ast/time-utils.js +46 -46
  227. package/dist/lang/ast/types/document-compile-result.d.ts +2 -2
  228. package/dist/lang/ast/types/executor.d.ts +3 -3
  229. package/dist/lang/ast/types/explore-desc.d.ts +2 -2
  230. package/dist/lang/ast/types/explore-desc.js +1 -1
  231. package/dist/lang/ast/types/explore-field.d.ts +3 -3
  232. package/dist/lang/ast/types/expr-result.d.ts +2 -2
  233. package/dist/lang/ast/types/expr-value.d.ts +2 -2
  234. package/dist/lang/ast/types/expression-def.d.ts +4 -4
  235. package/dist/lang/ast/types/expression-def.js +86 -86
  236. package/dist/lang/ast/types/field-collection-member.d.ts +3 -3
  237. package/dist/lang/ast/types/field-decl.d.ts +5 -5
  238. package/dist/lang/ast/types/field-space.d.ts +5 -5
  239. package/dist/lang/ast/types/field-space.js +1 -1
  240. package/dist/lang/ast/types/granular-result.d.ts +3 -3
  241. package/dist/lang/ast/types/granular-result.js +1 -1
  242. package/dist/lang/ast/types/lookup-result.d.ts +1 -1
  243. package/dist/lang/ast/types/malloy-element.d.ts +6 -6
  244. package/dist/lang/ast/types/malloy-element.js +49 -49
  245. package/dist/lang/ast/types/model-entry.d.ts +1 -1
  246. package/dist/lang/ast/types/name-space.d.ts +1 -1
  247. package/dist/lang/ast/types/nested-query.d.ts +2 -2
  248. package/dist/lang/ast/types/op-desc.d.ts +2 -2
  249. package/dist/lang/ast/types/query-comp.d.ts +1 -1
  250. package/dist/lang/ast/types/query-element.d.ts +3 -3
  251. package/dist/lang/ast/types/query-item.d.ts +4 -4
  252. package/dist/lang/ast/types/query-property.d.ts +15 -15
  253. package/dist/lang/ast/types/source-property.d.ts +8 -8
  254. package/dist/lang/ast/types/space-entry.d.ts +2 -2
  255. package/dist/lang/ast/types/space-field.d.ts +4 -4
  256. package/dist/lang/ast/types/space-field.js +4 -4
  257. package/dist/lang/ast/types/space-param.d.ts +4 -4
  258. package/dist/lang/ast/types/space-param.js +4 -4
  259. package/dist/lang/ast/types/time-result.d.ts +2 -2
  260. package/dist/lang/ast/types/turtle-headed-pipe.d.ts +2 -2
  261. package/dist/lang/ast/types/turtle-headed-pipe.js +1 -1
  262. package/dist/lang/ast/types/type-desc.d.ts +3 -3
  263. package/dist/lang/field-utils.d.ts +1 -1
  264. package/dist/lang/field-utils.js +4 -4
  265. package/dist/lang/index.d.ts +10 -10
  266. package/dist/lang/malloy-to-ast.d.ts +8 -8
  267. package/dist/lang/malloy-to-ast.js +68 -68
  268. package/dist/lang/parse-error-handler.d.ts +3 -3
  269. package/dist/lang/parse-error-handler.js +4 -4
  270. package/dist/lang/parse-log.d.ts +2 -2
  271. package/dist/lang/parse-log.js +1 -1
  272. package/dist/lang/parse-malloy.d.ts +7 -7
  273. package/dist/lang/parse-malloy.js +81 -81
  274. package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +2 -2
  275. package/dist/lang/parse-tree-walkers/document-completion-walker.js +38 -38
  276. package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +1 -1
  277. package/dist/lang/parse-tree-walkers/document-help-context-walker.js +14 -14
  278. package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +3 -3
  279. package/dist/lang/parse-tree-walkers/document-highlight-walker.js +85 -85
  280. package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +4 -4
  281. package/dist/lang/parse-tree-walkers/document-symbol-walker.js +40 -40
  282. package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +3 -3
  283. package/dist/lang/parse-tree-walkers/explore-query-walker.js +3 -3
  284. package/dist/lang/parse-tree-walkers/find-external-references.d.ts +4 -4
  285. package/dist/lang/parse-tree-walkers/find-external-references.js +2 -2
  286. package/dist/lang/reference-list.d.ts +1 -1
  287. package/dist/lang/test/document-help-context-walker.spec.js +9 -9
  288. package/dist/lang/test/document-symbol-walker.spec.js +32 -32
  289. package/dist/lang/test/field-symbols.spec.js +87 -87
  290. package/dist/lang/test/parse.spec.d.ts +1 -1
  291. package/dist/lang/test/parse.spec.js +768 -768
  292. package/dist/lang/test/test-translator.d.ts +6 -6
  293. package/dist/lang/test/test-translator.js +159 -159
  294. package/dist/lang/translate-response.d.ts +7 -7
  295. package/dist/lang/translate-response.js +1 -1
  296. package/dist/lang/zone.d.ts +5 -5
  297. package/dist/lang/zone.js +8 -8
  298. package/dist/malloy.d.ts +7 -7
  299. package/dist/malloy.js +192 -192
  300. package/dist/model/index.d.ts +2 -2
  301. package/dist/model/malloy_query.d.ts +12 -12
  302. package/dist/model/malloy_query.js +497 -502
  303. package/dist/model/malloy_types.d.ts +68 -68
  304. package/dist/model/malloy_types.js +102 -102
  305. package/dist/model/sql_block.d.ts +1 -1
  306. package/dist/model/sql_block.js +4 -4
  307. package/dist/model/utils.d.ts +1 -1
  308. package/dist/model/utils.js +10 -10
  309. package/dist/runtime_types.d.ts +2 -2
  310. package/package.json +4 -1
@@ -50,8 +50,8 @@ class BetaModel extends Testable {
50
50
  compile() {
51
51
  const compileTo = this.translate();
52
52
  if (compileTo.translated && inspectCompile) {
53
- console.log("MODEL: ", (0, test_translator_1.pretty)(compileTo.translated.modelDef));
54
- console.log("QUERIES: ", (0, test_translator_1.pretty)(compileTo.translated.queryList));
53
+ console.log('MODEL: ', (0, test_translator_1.pretty)(compileTo.translated.modelDef));
54
+ console.log('QUERIES: ', (0, test_translator_1.pretty)(compileTo.translated.queryList));
55
55
  }
56
56
  // All the stuff to ask the ast for a translation is already in TestTranslator
57
57
  }
@@ -62,7 +62,7 @@ class BetaModel extends Testable {
62
62
  const t = this.translate().translated;
63
63
  if (t) {
64
64
  const s = t.modelDef.contents[srcName];
65
- if (s.type == "struct") {
65
+ if (s.type === 'struct') {
66
66
  return s;
67
67
  }
68
68
  }
@@ -71,10 +71,10 @@ class BetaModel extends Testable {
71
71
  getQuery(queryName) {
72
72
  const t = this.translate().translated;
73
73
  if (t) {
74
- const s = typeof queryName == "string"
74
+ const s = typeof queryName === 'string'
75
75
  ? t.modelDef.contents[queryName]
76
76
  : t.queryList[queryName];
77
- if ((s === null || s === void 0 ? void 0 : s.type) == "query") {
77
+ if ((s === null || s === void 0 ? void 0 : s.type) === 'query') {
78
78
  return s;
79
79
  }
80
80
  }
@@ -83,31 +83,31 @@ class BetaModel extends Testable {
83
83
  }
84
84
  function checkForErrors(trans) {
85
85
  if (trans.logger === undefined) {
86
- throw new Error("JESTERY BROKEN, CANT FIND ERORR LOG");
86
+ throw new Error('JESTERY BROKEN, CANT FIND ERORR LOG');
87
87
  }
88
88
  if (trans.logger.hasErrors()) {
89
89
  return {
90
- "message": () => `Translation Errors:\n${trans.prettyErrors()}`,
91
- "pass": false
90
+ message: () => `Translation Errors:\n${trans.prettyErrors()}`,
91
+ pass: false,
92
92
  };
93
93
  }
94
94
  return {
95
- "message": () => "Unexpected error free translation",
96
- "pass": true
95
+ message: () => 'Unexpected error free translation',
96
+ pass: true,
97
97
  };
98
98
  }
99
99
  function prettyNeeds(response) {
100
- let needString = "";
100
+ let needString = '';
101
101
  if (response.tables) {
102
- needString += "Tables:\n";
103
- response.tables.forEach((table) => (needString += ` - ${table}`));
102
+ needString += 'Tables:\n';
103
+ response.tables.forEach(table => (needString += ` - ${table}`));
104
104
  }
105
105
  if (response.compileSQL) {
106
106
  needString += `Compile SQL: ${response.compileSQL.name}`;
107
107
  }
108
108
  if (response.urls) {
109
- needString += "URLs:\n";
110
- response.urls.forEach((url) => (needString += ` - ${url}`));
109
+ needString += 'URLs:\n';
110
+ response.urls.forEach(url => (needString += ` - ${url}`));
111
111
  }
112
112
  return needString;
113
113
  }
@@ -115,42 +115,42 @@ function checkForNeededs(trans) {
115
115
  const response = trans.translateStep.step(trans);
116
116
  if (!response.final) {
117
117
  return {
118
- "message": () => `Translation is not complete, needs:\n${prettyNeeds(response)}`,
119
- "pass": false
118
+ message: () => `Translation is not complete, needs:\n${prettyNeeds(response)}`,
119
+ pass: false,
120
120
  };
121
121
  }
122
122
  return {
123
- "message": () => "Unexpected complete translation",
124
- "pass": true
123
+ message: () => 'Unexpected complete translation',
124
+ pass: true,
125
125
  };
126
126
  }
127
127
  function highlightError(dl, txt) {
128
- if (dl == undefined) {
129
- return "~Location Undefined~";
128
+ if (dl === undefined) {
129
+ return '~Location Undefined~';
130
130
  }
131
131
  const { start, end } = dl.range;
132
132
  const output = [
133
- `${start.line}:${start.character}-${end.line}:${end.character}`
133
+ `${start.line}:${start.character}-${end.line}:${end.character}`,
134
134
  ];
135
135
  let errStart = start.character;
136
- const doc = txt.split("\n");
136
+ const doc = txt.split('\n');
137
137
  for (let line = start.line; line <= end.line; line += 1) {
138
138
  const lineText = doc[line];
139
139
  const lineStr = ` ${line}`.slice(-5);
140
140
  output.push(`${lineStr}| ${lineText}`);
141
- const upToError = ` | ` + " ".repeat(errStart);
141
+ const upToError = ' | ' + ' '.repeat(errStart);
142
142
  let errLen = end.character - errStart;
143
143
  if (line < end.line) {
144
144
  errLen = lineText.length - errStart;
145
145
  errStart = 0;
146
146
  }
147
- output.push(upToError + "-".repeat(errLen));
147
+ output.push(upToError + '-'.repeat(errLen));
148
148
  }
149
- return output.join("\n");
149
+ return output.join('\n');
150
150
  }
151
151
  function unlocatedStructDef(sd) {
152
152
  const ret = { ...sd };
153
- ret.fields = sd.fields.map((f) => {
153
+ ret.fields = sd.fields.map(f => {
154
154
  const nf = { ...f };
155
155
  delete nf.location;
156
156
  return nf;
@@ -159,7 +159,7 @@ function unlocatedStructDef(sd) {
159
159
  return ret;
160
160
  }
161
161
  expect.extend({
162
- "toCompile": function (s) {
162
+ toCompile: function (s) {
163
163
  const x = new BetaModel(s);
164
164
  x.compile();
165
165
  const errorCheck = checkForErrors(x);
@@ -169,11 +169,11 @@ expect.extend({
169
169
  x.translate();
170
170
  return checkForNeededs(x);
171
171
  },
172
- "modelParsed": function (x) {
172
+ modelParsed: function (x) {
173
173
  x.compile();
174
174
  return checkForErrors(x);
175
175
  },
176
- "modelCompiled": function (x) {
176
+ modelCompiled: function (x) {
177
177
  x.compile();
178
178
  const errorCheck = checkForErrors(x);
179
179
  if (!errorCheck.pass) {
@@ -182,33 +182,33 @@ expect.extend({
182
182
  x.translate();
183
183
  return checkForNeededs(x);
184
184
  },
185
- "toBeErrorless": function (trans) {
185
+ toBeErrorless: function (trans) {
186
186
  return checkForErrors(trans);
187
187
  },
188
- "toReturnType": function (functionCall, returnType) {
188
+ toReturnType: function (functionCall, returnType) {
189
189
  const exprModel = new BetaModel(`explore: x is a { dimension: d is ${functionCall} }`);
190
190
  expect(exprModel).modelCompiled();
191
- const x = exprModel.getSourceDef("x");
191
+ const x = exprModel.getSourceDef('x');
192
192
  expect(x).toBeDefined();
193
193
  if (x) {
194
- const d = x.fields.find((f) => f.name === "d");
194
+ const d = x.fields.find(f => f.name === 'd');
195
195
  expect(d === null || d === void 0 ? void 0 : d.type).toBe(returnType);
196
196
  }
197
197
  return {
198
- "pass": true,
199
- "message": () => ""
198
+ pass: true,
199
+ message: () => '',
200
200
  };
201
201
  },
202
- "compileToFailWith": function (s, ...msgs) {
202
+ compileToFailWith: function (s, ...msgs) {
203
203
  var _a;
204
- let emsg = "Compile Error expectation not met\nExpected error";
204
+ let emsg = 'Compile Error expectation not met\nExpected error';
205
205
  let mSrc;
206
- const qmsgs = msgs.map((s) => `error '${s}'`);
207
- if (msgs.length == 1) {
206
+ const qmsgs = msgs.map(s => `error '${s}'`);
207
+ if (msgs.length === 1) {
208
208
  emsg += ` ${qmsgs[0]}`;
209
209
  }
210
210
  else {
211
- emsg += `s [\n${qmsgs.join("\n")}\n]`;
211
+ emsg += `s [\n${qmsgs.join('\n')}\n]`;
212
212
  }
213
213
  let m;
214
214
  let src;
@@ -217,7 +217,7 @@ expect.extend({
217
217
  src = m.testSrc;
218
218
  }
219
219
  else {
220
- if (typeof s == "string") {
220
+ if (typeof s === 'string') {
221
221
  src = s;
222
222
  }
223
223
  else {
@@ -229,15 +229,15 @@ expect.extend({
229
229
  emsg += `\nSource:\n${src}`;
230
230
  const t = m.translate();
231
231
  if (t.translated) {
232
- return { "pass": false, "message": () => emsg };
232
+ return { pass: false, message: () => emsg };
233
233
  }
234
- else if (t.errors == undefined) {
234
+ else if (t.errors === undefined) {
235
235
  return {
236
- "pass": false,
237
- "message": () => `TEST ERROR, not all objects resolved in source\n` +
236
+ pass: false,
237
+ message: () => 'TEST ERROR, not all objects resolved in source\n' +
238
238
  (0, test_translator_1.pretty)(t) +
239
- "\n" +
240
- emsg
239
+ '\n' +
240
+ emsg,
241
241
  };
242
242
  }
243
243
  else {
@@ -247,7 +247,7 @@ expect.extend({
247
247
  for (i = 0; i < msgs.length && errList[i]; i += 1) {
248
248
  const msg = msgs[i];
249
249
  const err = errList[i];
250
- if (msg != err.message) {
250
+ if (msg !== err.message) {
251
251
  explain.push(`Expected: ${msg}\nGot: ${err.message}`);
252
252
  }
253
253
  else {
@@ -261,53 +261,53 @@ expect.extend({
261
261
  }
262
262
  }
263
263
  }
264
- if (i != msgs.length) {
265
- explain.push(...msgs.slice(i).map((m) => `Missing: ${m}`));
264
+ if (i !== msgs.length) {
265
+ explain.push(...msgs.slice(i).map(m => `Missing: ${m}`));
266
266
  }
267
- if (i != errList.length) {
268
- explain.push(...errList.slice(i).map((m) => `Unexpected Error: ${m.message}`));
267
+ if (i !== errList.length) {
268
+ explain.push(...errList.slice(i).map(m => `Unexpected Error: ${m.message}`));
269
269
  }
270
- if (explain.length == 0) {
270
+ if (explain.length === 0) {
271
271
  return {
272
- "pass": true,
273
- "message": () => `All expected errors found: ${(0, test_translator_1.pretty)(msgs)}`
272
+ pass: true,
273
+ message: () => `All expected errors found: ${(0, test_translator_1.pretty)(msgs)}`,
274
274
  };
275
275
  }
276
276
  return {
277
- "pass": false,
278
- "message": () => `Compiler did not generated expected errors\n${explain.join("\n")}`
277
+ pass: false,
278
+ message: () => `Compiler did not generated expected errors\n${explain.join('\n')}`,
279
279
  };
280
280
  }
281
281
  },
282
- "isLocationIn": function (checkAt, at, text) {
282
+ isLocationIn: function (checkAt, at, text) {
283
283
  if (this.equals(at, checkAt)) {
284
284
  return {
285
- "pass": true,
286
- "message": () => `Locations match`
285
+ pass: true,
286
+ message: () => 'Locations match',
287
287
  };
288
288
  }
289
- const errMsg = `Locations do not match\n` +
289
+ const errMsg = 'Locations do not match\n' +
290
290
  `Expected: ${highlightError(at, text)}\n` +
291
291
  `Received: ${highlightError(checkAt, text)}\n`;
292
292
  return {
293
- "pass": false,
294
- "message": () => errMsg
293
+ pass: false,
294
+ message: () => errMsg,
295
295
  };
296
- }
296
+ },
297
297
  });
298
298
  class BetaExpression extends Testable {
299
299
  constructor(src) {
300
- super(src, "justExpr");
300
+ super(src, 'justExpr');
301
301
  }
302
302
  compile() {
303
303
  const exprAst = this.ast();
304
304
  if (exprAst instanceof expression_def_1.ExpressionDef) {
305
305
  const aStruct = this.internalModel.contents.ab;
306
- if (aStruct.type === "struct") {
306
+ if (aStruct.type === 'struct') {
307
307
  const tstFS = new static_space_1.StaticSpace(aStruct);
308
308
  const exprDef = exprAst.getExpression(tstFS);
309
309
  if (inspectCompile) {
310
- console.log("EXPRESSION: ", (0, test_translator_1.pretty)(exprDef));
310
+ console.log('EXPRESSION: ', (0, test_translator_1.pretty)(exprDef));
311
311
  }
312
312
  }
313
313
  else {
@@ -318,7 +318,7 @@ class BetaExpression extends Testable {
318
318
  return;
319
319
  }
320
320
  else {
321
- const whatIsIt = (exprAst === null || exprAst === void 0 ? void 0 : exprAst.toString()) || "NO AST GENERATED";
321
+ const whatIsIt = (exprAst === null || exprAst === void 0 ? void 0 : exprAst.toString()) || 'NO AST GENERATED';
322
322
  throw new Error(`Not an expression: ${whatIsIt}`);
323
323
  }
324
324
  }
@@ -338,7 +338,7 @@ function modelOK(s) {
338
338
  }
339
339
  function badModel(s, msg) {
340
340
  return () => {
341
- const src = typeof s == "string" ? s : s.code;
341
+ const src = typeof s === 'string' ? s : s.code;
342
342
  const emsg = `Error expectation not met\nExpected error: '${msg}'\nSource:\n${src}`;
343
343
  const m = new BetaModel(src);
344
344
  const t = m.translate();
@@ -348,10 +348,10 @@ function badModel(s, msg) {
348
348
  else {
349
349
  const errList = m.errors().errors;
350
350
  const firstError = errList[0];
351
- if (firstError.message != msg) {
351
+ if (firstError.message !== msg) {
352
352
  fail(`Received errror: ${firstError.message}\n${emsg}`);
353
353
  }
354
- if (typeof s != "string") {
354
+ if (typeof s !== 'string') {
355
355
  if (!(0, isEqual_1.default)(errList[0].at, s.locations[0])) {
356
356
  fail(`Expected location: ${s.locations[0]}\n` +
357
357
  `Received location: ${errList[0].at}\n${emsg}`);
@@ -361,49 +361,49 @@ function badModel(s, msg) {
361
361
  return undefined;
362
362
  };
363
363
  }
364
- describe("model statements", () => {
365
- describe("explore:", () => {
366
- test("explore table", modelOK(`explore: testA is table('aTable')`));
367
- test("explore shorcut fitlered table", () => {
368
- expect(`explore: testA is table('aTable') {? astr ~ 'a%' } `).toCompile();
364
+ describe('model statements', () => {
365
+ describe('explore:', () => {
366
+ test('explore table', modelOK("explore: testA is table('aTable')"));
367
+ test('explore shorcut fitlered table', () => {
368
+ expect("explore: testA is table('aTable') {? astr ~ 'a%' } ").toCompile();
369
369
  });
370
- test("explore fitlered table", modelOK(`
370
+ test('explore fitlered table', modelOK(`
371
371
  explore: testA is table('aTable') { where: astr ~ 'a%' }
372
372
  `));
373
- test("explore explore", modelOK(`explore: testA is a`));
374
- test("explore query", modelOK(`explore: testA is from(a->{group_by: astr})`));
375
- test("refine explore", modelOK(`explore: aa is a { dimension: a is astr }`));
376
- test("source refinement preserves original", () => {
377
- const x = new BetaModel("source: na is a + { dimension: one is 1 }");
373
+ test('explore explore', modelOK('explore: testA is a'));
374
+ test('explore query', modelOK('explore: testA is from(a->{group_by: astr})'));
375
+ test('refine explore', modelOK('explore: aa is a { dimension: a is astr }'));
376
+ test('source refinement preserves original', () => {
377
+ const x = new BetaModel('source: na is a + { dimension: one is 1 }');
378
378
  expect(x).modelCompiled();
379
- const a = x.getSourceDef("a");
379
+ const a = x.getSourceDef('a');
380
380
  if (a) {
381
- const aFields = a.fields.map((f) => f.as || f.name);
382
- expect(aFields).toContain("astr");
383
- expect(aFields).not.toContain("one");
381
+ const aFields = a.fields.map(f => f.as || f.name);
382
+ expect(aFields).toContain('astr');
383
+ expect(aFields).not.toContain('one');
384
384
  }
385
385
  });
386
386
  });
387
- describe("query:", () => {
388
- test("anonymous query", modelOK("query: table('aTable') -> { group_by: astr }"));
389
- test("query", modelOK("query: name is table('aTable') -> { group_by: astr }"));
390
- test("query from query", modelOK(`
387
+ describe('query:', () => {
388
+ test('anonymous query', modelOK("query: table('aTable') -> { group_by: astr }"));
389
+ test('query', modelOK("query: name is table('aTable') -> { group_by: astr }"));
390
+ test('query from query', modelOK(`
391
391
  query: q1 is ab->{ group_by: astr limit: 10 }
392
392
  query: q2 is ->q1
393
393
  `));
394
- test("query with refinements from query", modelOK(`
394
+ test('query with refinements from query', modelOK(`
395
395
  query: q1 is ab->{ group_by: astr limit: 10 }
396
396
  query: q2 is ->q1 { aggregate: acount }
397
397
  `));
398
- test("chained query operations", modelOK(`
398
+ test('chained query operations', modelOK(`
399
399
  query: ab
400
400
  -> { group_by: astr; aggregate: acount }
401
401
  -> { top: 5; where: astr ~ 'a%' group_by: astr }
402
402
  `));
403
- test("query from explore from query", modelOK(`query: from(ab -> {group_by: astr}) { dimension: bigstr is UPPER(astr) } -> { group_by: bigstr }`));
404
- test("query with shortcut filtered turtle", modelOK("query: allA is ab->aturtle {? astr ~ 'a%' }"));
405
- test("query with filtered turtle", modelOK("query: allA is ab->aturtle { where: astr ~ 'a%' }"));
406
- test("nest: in group_by:", modelOK(`
403
+ test('query from explore from query', modelOK('query: from(ab -> {group_by: astr}) { dimension: bigstr is UPPER(astr) } -> { group_by: bigstr }'));
404
+ test('query with shortcut filtered turtle', modelOK("query: allA is ab->aturtle {? astr ~ 'a%' }"));
405
+ test('query with filtered turtle', modelOK("query: allA is ab->aturtle { where: astr ~ 'a%' }"));
406
+ test('nest: in group_by:', modelOK(`
407
407
  query: ab -> {
408
408
  group_by: astr;
409
409
  nest: nested_count is {
@@ -411,39 +411,39 @@ describe("model statements", () => {
411
411
  }
412
412
  }
413
413
  `));
414
- test("reduce pipe project", modelOK(`
414
+ test('reduce pipe project', modelOK(`
415
415
  query: a -> { aggregate: f is count() } -> { project: f2 is f + 1 }
416
416
  `));
417
- test("refine and extend query", modelOK(`
417
+ test('refine and extend query', modelOK(`
418
418
  query: a_by_str is a -> { group_by: astr }
419
419
  query: -> a_by_str { aggregate: str_count is count() }
420
420
  `));
421
- test("query refinement preserves original", () => {
421
+ test('query refinement preserves original', () => {
422
422
  const x = new BetaModel(`
423
423
  query: q is a -> { aggregate: acount is count() }
424
424
  query: nq is -> q + { group_by: astr }
425
425
  `);
426
426
  expect(x).modelCompiled();
427
- const q = x.getQuery("q");
427
+ const q = x.getQuery('q');
428
428
  expect(q).toBeDefined();
429
429
  if (q) {
430
430
  const qFields = q.pipeline[0].fields;
431
431
  expect(qFields.length).toBe(1);
432
432
  }
433
433
  });
434
- test("query composition preserves original", () => {
434
+ test('query composition preserves original', () => {
435
435
  const x = new BetaModel(`
436
436
  query: q is ab -> { aggregate: acount }
437
437
  query: nq is -> q -> { project: * }
438
438
  `);
439
439
  expect(x).modelCompiled();
440
- const q = x.getQuery("q");
440
+ const q = x.getQuery('q');
441
441
  expect(q).toBeDefined();
442
442
  if (q) {
443
443
  expect(q.pipeline.length).toBe(1);
444
444
  }
445
445
  });
446
- test("all ungroup with args", modelOK(`
446
+ test('all ungroup with args', modelOK(`
447
447
  query: a -> {
448
448
  group_by: astr
449
449
  nest: by_int is {
@@ -452,7 +452,7 @@ describe("model statements", () => {
452
452
  }
453
453
  }
454
454
  `));
455
- test("all ungroup checks args", () => {
455
+ test('all ungroup checks args', () => {
456
456
  expect(`
457
457
  query: a -> {
458
458
  group_by: astr
@@ -461,9 +461,9 @@ describe("model statements", () => {
461
461
  aggregate: bi_count is all(count(), afloat)
462
462
  }
463
463
  }
464
- `).compileToFailWith(`all() 'afloat' is missing from query output`);
464
+ `).compileToFailWith("all() 'afloat' is missing from query output");
465
465
  });
466
- test("exclude ungroup with args", modelOK(`
466
+ test('exclude ungroup with args', modelOK(`
467
467
  query: a -> {
468
468
  group_by: aa is 'a'
469
469
  nest: by_b is {
@@ -475,7 +475,7 @@ describe("model statements", () => {
475
475
  }
476
476
  }
477
477
  `));
478
- test("exclude ungroup checks args", () => {
478
+ test('exclude ungroup checks args', () => {
479
479
  expect(`
480
480
  query: a -> {
481
481
  group_by: aa is 'a'
@@ -489,7 +489,7 @@ describe("model statements", () => {
489
489
  }
490
490
  `).compileToFailWith("exclude() 'aaa' is missing from query output");
491
491
  });
492
- test("exclude problem revealed by production models", modelOK(`
492
+ test('exclude problem revealed by production models', modelOK(`
493
493
  source: carriers is table('malloytest.carriers') {
494
494
  primary_key: code
495
495
  }
@@ -508,128 +508,128 @@ describe("model statements", () => {
508
508
  }
509
509
  `));
510
510
  });
511
- describe("import:", () => {
512
- test("simple import", () => {
513
- const docParse = new BetaModel(`import "child"`);
511
+ describe('import:', () => {
512
+ test('simple import', () => {
513
+ const docParse = new BetaModel('import "child"');
514
514
  const xr = docParse.unresolved();
515
515
  expect(docParse).toBeErrorless();
516
- expect(xr).toEqual({ "urls": ["internal://test/langtests/child"] });
516
+ expect(xr).toEqual({ urls: ['internal://test/langtests/child'] });
517
517
  docParse.update({
518
- "urls": { "internal://test/langtests/child": "explore: aa is a" }
518
+ urls: { 'internal://test/langtests/child': 'explore: aa is a' },
519
519
  });
520
520
  const yr = docParse.unresolved();
521
521
  expect(yr).toBeNull();
522
522
  });
523
- test("missing import", () => {
524
- const docParse = new BetaModel(`import "child"`);
523
+ test('missing import', () => {
524
+ const docParse = new BetaModel('import "child"');
525
525
  const xr = docParse.unresolved();
526
526
  expect(docParse).toBeErrorless();
527
- expect(xr).toEqual({ "urls": ["internal://test/langtests/child"] });
528
- const reportedError = "ENOWAY: No way to find your child";
527
+ expect(xr).toEqual({ urls: ['internal://test/langtests/child'] });
528
+ const reportedError = 'ENOWAY: No way to find your child';
529
529
  docParse.update({
530
- "errors": {
531
- "urls": { "internal://test/langtests/child": reportedError }
532
- }
530
+ errors: {
531
+ urls: { 'internal://test/langtests/child': reportedError },
532
+ },
533
533
  });
534
534
  docParse.translate();
535
535
  expect(docParse).not.toBeErrorless();
536
536
  expect(docParse.prettyErrors()).toContain(reportedError);
537
537
  });
538
- test("chained imports", () => {
539
- const docParse = new BetaModel(`import "child"`);
538
+ test('chained imports', () => {
539
+ const docParse = new BetaModel('import "child"');
540
540
  docParse.update({
541
- "urls": { "internal://test/langtests/child": `import "grandChild"` }
541
+ urls: { 'internal://test/langtests/child': 'import "grandChild"' },
542
542
  });
543
543
  const xr = docParse.unresolved();
544
544
  expect(docParse).toBeErrorless();
545
- expect(xr).toEqual({ "urls": ["internal://test/langtests/grandChild"] });
545
+ expect(xr).toEqual({ urls: ['internal://test/langtests/grandChild'] });
546
546
  });
547
- test("relative imports", () => {
548
- const docParse = new BetaModel(`import "../parent.malloy"`);
547
+ test('relative imports', () => {
548
+ const docParse = new BetaModel('import "../parent.malloy"');
549
549
  expect(docParse).modelParsed();
550
550
  const xr = docParse.unresolved();
551
- expect(xr).toEqual({ "urls": ["internal://test/parent.malloy"] });
551
+ expect(xr).toEqual({ urls: ['internal://test/parent.malloy'] });
552
552
  docParse.update({
553
- "urls": {
554
- "internal://test/parent.malloy": `source: aa is table('aTable')`
555
- }
553
+ urls: {
554
+ 'internal://test/parent.malloy': "source: aa is table('aTable')",
555
+ },
556
556
  });
557
557
  expect(docParse).modelCompiled();
558
558
  });
559
- test("relative imports with errors", () => {
560
- const docParse = new BetaModel(`import "../parent.malloy"`);
559
+ test('relative imports with errors', () => {
560
+ const docParse = new BetaModel('import "../parent.malloy"');
561
561
  expect(docParse).modelParsed();
562
562
  const xr = docParse.unresolved();
563
- expect(xr).toEqual({ "urls": ["internal://test/parent.malloy"] });
563
+ expect(xr).toEqual({ urls: ['internal://test/parent.malloy'] });
564
564
  docParse.update({
565
- "urls": {
566
- "internal://test/parent.malloy": `
565
+ urls: {
566
+ 'internal://test/parent.malloy': `
567
567
  source: aa is table('aTable') {
568
568
  dimension: astr is 'not legal beause astr exists'
569
- }`
570
- }
569
+ }`,
570
+ },
571
571
  });
572
572
  expect(docParse).compileToFailWith("Cannot redefine 'astr'");
573
573
  });
574
- test("source references expanded when not exported", () => {
574
+ test('source references expanded when not exported', () => {
575
575
  const srcFiles = {
576
- "internal://test/langtests/middle": `
576
+ 'internal://test/langtests/middle': `
577
577
  import "bottom"
578
578
  source: midSrc is from(bottomSrc -> { group_by: astr })
579
579
  `,
580
- "internal://test/langtests/bottom": `source: bottomSrc is table('aTable')`
580
+ 'internal://test/langtests/bottom': "source: bottomSrc is table('aTable')",
581
581
  };
582
582
  const fullModel = new BetaModel(`
583
583
  import "middle"
584
584
  `);
585
- fullModel.update({ "urls": srcFiles });
585
+ fullModel.update({ urls: srcFiles });
586
586
  expect(fullModel).modelCompiled();
587
- const ms = fullModel.getSourceDef("midSrc");
587
+ const ms = fullModel.getSourceDef('midSrc');
588
588
  expect(ms).toBeDefined();
589
589
  if (ms) {
590
- expect(ms.structSource.type).toBe("query");
591
- if (ms.structSource.type == "query") {
590
+ expect(ms.structSource.type).toBe('query');
591
+ if (ms.structSource.type === 'query') {
592
592
  const qs = ms.structSource.query.structRef;
593
- expect(typeof qs).not.toBe("string");
593
+ expect(typeof qs).not.toBe('string');
594
594
  }
595
595
  }
596
596
  });
597
597
  });
598
598
  });
599
- describe("explore properties", () => {
600
- test("single dimension", modelOK("explore: aa is a { dimension: x is 1 }"));
601
- test("multiple dimensions", modelOK(`
599
+ describe('explore properties', () => {
600
+ test('single dimension', modelOK('explore: aa is a { dimension: x is 1 }'));
601
+ test('multiple dimensions', modelOK(`
602
602
  explore: aa is a {
603
603
  dimension:
604
604
  x is 1
605
605
  y is 2
606
606
  }
607
607
  `));
608
- test("single declare", modelOK("explore: aa is a { declare: x is 1 }"));
609
- test("multiple declare", modelOK(`
608
+ test('single declare', modelOK('explore: aa is a { declare: x is 1 }'));
609
+ test('multiple declare', modelOK(`
610
610
  explore: aa is a {
611
611
  declare:
612
612
  x is 1
613
613
  y is 2
614
614
  }
615
615
  `));
616
- test("single measure", modelOK("explore: aa is a { measure: x is count() }"));
617
- test("multiple measures", modelOK(`
616
+ test('single measure', modelOK('explore: aa is a { measure: x is count() }'));
617
+ test('multiple measures', modelOK(`
618
618
  explore: aa is a {
619
619
  dimension:
620
620
  x is count()
621
621
  y is x * x
622
622
  }
623
623
  `));
624
- test("single where", modelOK("explore: aa is a { where: ai > 10 }"));
625
- test("multiple where", modelOK(`
624
+ test('single where', modelOK('explore: aa is a { where: ai > 10 }'));
625
+ test('multiple where', modelOK(`
626
626
  explore: aa is a {
627
627
  where:
628
628
  ai > 10,
629
629
  af < 1000
630
630
  }
631
631
  `));
632
- test("where clause can use the join namespace in source refined query", modelOK(`
632
+ test('where clause can use the join namespace in source refined query', modelOK(`
633
633
  source: flights is table('malloytest.flights') + {
634
634
  query: boo is {
635
635
  join_one: carriers is table('malloytest.carriers') on carrier = carriers.code
@@ -638,60 +638,60 @@ describe("explore properties", () => {
638
638
  aggregate: flight_count is count()
639
639
  }
640
640
  }`));
641
- describe("joins", () => {
642
- test("with", modelOK("explore: x is a { join_one: b with astr }"));
643
- test("with", modelOK("explore: x is a { join_one: y is b with astr }"));
644
- test("with dotted ref", modelOK("explore: x is ab { join_one: xz is a with b.astr }"));
645
- test("one on", modelOK("explore: x is a { join_one: b on astr = b.astr }"));
646
- test("one is on", modelOK("explore: x is a { join_one: y is b on astr = y.astr }"));
647
- test("many on", modelOK("explore: nab is a { join_many: b on astr = b.astr }"));
648
- test("many is on", modelOK("explore: y is a { join_many: x is b on astr = x.astr }"));
649
- test("cross", modelOK("explore: nab is a { join_cross: b }"));
650
- test("cross is", modelOK("explore: nab is a { join_cross: xb is b }"));
651
- test("cross on", modelOK("explore: nab is a { join_cross: b on true}"));
652
- test("multiple joins", modelOK(`
641
+ describe('joins', () => {
642
+ test('with', modelOK('explore: x is a { join_one: b with astr }'));
643
+ test('with', modelOK('explore: x is a { join_one: y is b with astr }'));
644
+ test('with dotted ref', modelOK('explore: x is ab { join_one: xz is a with b.astr }'));
645
+ test('one on', modelOK('explore: x is a { join_one: b on astr = b.astr }'));
646
+ test('one is on', modelOK('explore: x is a { join_one: y is b on astr = y.astr }'));
647
+ test('many on', modelOK('explore: nab is a { join_many: b on astr = b.astr }'));
648
+ test('many is on', modelOK('explore: y is a { join_many: x is b on astr = x.astr }'));
649
+ test('cross', modelOK('explore: nab is a { join_cross: b }'));
650
+ test('cross is', modelOK('explore: nab is a { join_cross: xb is b }'));
651
+ test('cross on', modelOK('explore: nab is a { join_cross: b on true}'));
652
+ test('multiple joins', modelOK(`
653
653
  explore: nab is a {
654
654
  join_one:
655
655
  b with astr,
656
656
  br is b with astr
657
657
  }
658
658
  `));
659
- test("with requires primary key", () => {
659
+ test('with requires primary key', () => {
660
660
  expect((0, test_translator_1.markSource) `
661
661
  source: nb is b {
662
662
  join_one: ${"bb is table('aTable') with astr"}
663
663
  }
664
- `).compileToFailWith("join_one: Cannot use with unless source has a primary key");
664
+ `).compileToFailWith('join_one: Cannot use with unless source has a primary key');
665
665
  });
666
666
  });
667
- test("primary_key", modelOK("explore: c is a { primary_key: ai }"));
668
- test("rename", modelOK("explore: c is a { rename: nn is ai }"));
669
- test("accept single", () => {
670
- const onlyAstr = new BetaModel("explore: c is a { accept: astr }");
667
+ test('primary_key', modelOK('explore: c is a { primary_key: ai }'));
668
+ test('rename', modelOK('explore: c is a { rename: nn is ai }'));
669
+ test('accept single', () => {
670
+ const onlyAstr = new BetaModel('explore: c is a { accept: astr }');
671
671
  expect(onlyAstr).modelCompiled();
672
- const c = onlyAstr.getSourceDef("c");
672
+ const c = onlyAstr.getSourceDef('c');
673
673
  if (c) {
674
674
  expect(c.fields.length).toBe(1);
675
675
  }
676
676
  });
677
- test("accept multi", modelOK("explore: c is a { accept: astr, af }"));
678
- test("except single", () => {
679
- const noAstr = new BetaModel("explore: c is a { except: astr }");
677
+ test('accept multi', modelOK('explore: c is a { accept: astr, af }'));
678
+ test('except single', () => {
679
+ const noAstr = new BetaModel('explore: c is a { except: astr }');
680
680
  expect(noAstr).modelCompiled();
681
- const c = noAstr.getSourceDef("c");
681
+ const c = noAstr.getSourceDef('c');
682
682
  if (c) {
683
- const foundAstr = c.fields.find((f) => f.name == "astr");
683
+ const foundAstr = c.fields.find(f => f.name === 'astr');
684
684
  expect(foundAstr).toBeUndefined();
685
685
  }
686
686
  });
687
- test("except multi", modelOK("explore: c is a { except: astr, af }"));
688
- test("explore-query", modelOK("explore: c is a {query: q is { group_by: astr } }"));
689
- test("refined explore-query", modelOK(`
687
+ test('except multi', modelOK('explore: c is a { except: astr, af }'));
688
+ test('explore-query', modelOK('explore: c is a {query: q is { group_by: astr } }'));
689
+ test('refined explore-query', modelOK(`
690
690
  explore: abNew is ab {
691
691
  query: for1 is aturtle {? ai = 1 }
692
692
  }
693
693
  `));
694
- test("chained explore-query", modelOK(`
694
+ test('chained explore-query', modelOK(`
695
695
  explore: c is a {
696
696
  query: chain is {
697
697
  group_by: astr
@@ -701,7 +701,7 @@ describe("explore properties", () => {
701
701
  }
702
702
  }
703
703
  `));
704
- test("multiple explore-query", modelOK(`
704
+ test('multiple explore-query', modelOK(`
705
705
  explore: abNew is ab {
706
706
  query:
707
707
  q1 is { group_by: astr },
@@ -709,90 +709,90 @@ describe("explore properties", () => {
709
709
  }
710
710
  `));
711
711
  });
712
- describe("qops", () => {
713
- test("group by single", modelOK("query: a->{ group_by: astr }"));
714
- test("group_by x is x'", modelOK("query: a->{ group_by: ai is ai/2 }"));
715
- test("group by multiple", modelOK("query: a->{ group_by: astr,ai }"));
716
- test("aggregate single", modelOK("query: a->{ aggregate: num is count() }"));
717
- test("aggregate multiple", modelOK(`
712
+ describe('qops', () => {
713
+ test('group by single', modelOK('query: a->{ group_by: astr }'));
714
+ test("group_by x is x'", modelOK('query: a->{ group_by: ai is ai/2 }'));
715
+ test('group by multiple', modelOK('query: a->{ group_by: astr,ai }'));
716
+ test('aggregate single', modelOK('query: a->{ aggregate: num is count() }'));
717
+ test('aggregate multiple', modelOK(`
718
718
  query: a->{
719
719
  aggregate: num is count(), total is sum(ai)
720
720
  }
721
721
  `));
722
- test("project ref", modelOK("query:ab->{ project: b.astr }"));
723
- test("project *", modelOK("query:ab->{ project: * }"));
724
- test("project def", modelOK("query:ab->{ project: one is 1 }"));
725
- test("project multiple", modelOK(`
722
+ test('project ref', modelOK('query:ab->{ project: b.astr }'));
723
+ test('project *', modelOK('query:ab->{ project: * }'));
724
+ test('project def', modelOK('query:ab->{ project: one is 1 }'));
725
+ test('project multiple', modelOK(`
726
726
  query: a->{
727
727
  project: one is 1, astr
728
728
  }
729
729
  `));
730
- test("index single", modelOK("query:a->{index: astr}"));
731
- test("index path", modelOK("query:ab->{index: ab.astr}"));
732
- test("index unique on path", modelOK("query:ab->{index: b.astr, ab.astr}"));
733
- test("index join.*", modelOK("query:ab->{index: ab.*}"));
734
- test("index multiple", () => {
735
- const model = new BetaModel("query:a->{index: af, astr}");
730
+ test('index single', modelOK('query:a->{index: astr}'));
731
+ test('index path', modelOK('query:ab->{index: ab.astr}'));
732
+ test('index unique on path', modelOK('query:ab->{index: b.astr, ab.astr}'));
733
+ test('index join.*', modelOK('query:ab->{index: ab.*}'));
734
+ test('index multiple', () => {
735
+ const model = new BetaModel('query:a->{index: af, astr}');
736
736
  expect(model).modelCompiled();
737
737
  const q = model.getQuery(0);
738
738
  expect(q).toBeDefined();
739
739
  if (q) {
740
740
  const index = q.pipeline[0];
741
- expect(index.type).toBe("index");
742
- expect(index.fields).toEqual(["af", "astr"]);
741
+ expect(index.type).toBe('index');
742
+ expect(index.fields).toEqual(['af', 'astr']);
743
743
  }
744
744
  });
745
- test("index star", () => {
746
- const model = new BetaModel("query:a->{index: *, astr}");
745
+ test('index star', () => {
746
+ const model = new BetaModel('query:a->{index: *, astr}');
747
747
  expect(model).modelCompiled();
748
748
  const q = model.getQuery(0);
749
749
  expect(q).toBeDefined();
750
750
  if (q) {
751
751
  const index = q.pipeline[0];
752
- expect(index.type).toBe("index");
753
- expect(index.fields).toEqual(["*", "astr"]);
752
+ expect(index.type).toBe('index');
753
+ expect(index.fields).toEqual(['*', 'astr']);
754
754
  }
755
755
  });
756
- test("index by", modelOK("query:a->{index: * by ai}"));
757
- test("index sampled", modelOK("query:a->{index: *; sample: true}"));
758
- test("index unsampled", modelOK("query:a->{index: *; sample: false}"));
759
- test("index sample-percent", () => {
760
- const model = new BetaModel("query:a->{index: *; sample: 42%}");
756
+ test('index by', modelOK('query:a->{index: * by ai}'));
757
+ test('index sampled', modelOK('query:a->{index: *; sample: true}'));
758
+ test('index unsampled', modelOK('query:a->{index: *; sample: false}'));
759
+ test('index sample-percent', () => {
760
+ const model = new BetaModel('query:a->{index: *; sample: 42%}');
761
761
  expect(model).modelCompiled();
762
762
  const q = model.getQuery(0);
763
763
  expect(q).toBeDefined();
764
764
  if (q) {
765
765
  const index = q.pipeline[0];
766
- expect(index.type).toBe("index");
767
- if (index.type == "index") {
768
- expect(index.sample).toEqual({ "percent": 42 });
766
+ expect(index.type).toBe('index');
767
+ if (index.type === 'index') {
768
+ expect(index.sample).toEqual({ percent: 42 });
769
769
  }
770
770
  }
771
771
  });
772
- test("index sample-rows", modelOK("query:a->{index: *; sample: 100000}"));
773
- test("top N", modelOK("query: a->{ top: 5; group_by: astr }"));
774
- test("top N by field", modelOK("query: a->{top: 5 by af; group_by: astr}"));
775
- test("top N by expression", modelOK("query: ab->{top: 5 by acount; group_by: astr}"));
776
- test("limit N", modelOK("query: a->{ limit: 5; group_by: astr }"));
777
- test("order by", modelOK("query: a->{ order_by: af; group_by: astr }"));
778
- test("order by asc", modelOK("query: a->{ order_by: af asc; group_by: astr }"));
779
- test("order by desc", modelOK("query: a->{ order_by: af desc; group_by: astr }"));
780
- test("order by N", modelOK("query: a->{ order_by: 1 asc; group_by: astr }"));
781
- test("order by multiple", modelOK(`
772
+ test('index sample-rows', modelOK('query:a->{index: *; sample: 100000}'));
773
+ test('top N', modelOK('query: a->{ top: 5; group_by: astr }'));
774
+ test('top N by field', modelOK('query: a->{top: 5 by af; group_by: astr}'));
775
+ test('top N by expression', modelOK('query: ab->{top: 5 by acount; group_by: astr}'));
776
+ test('limit N', modelOK('query: a->{ limit: 5; group_by: astr }'));
777
+ test('order by', modelOK('query: a->{ order_by: af; group_by: astr }'));
778
+ test('order by asc', modelOK('query: a->{ order_by: af asc; group_by: astr }'));
779
+ test('order by desc', modelOK('query: a->{ order_by: af desc; group_by: astr }'));
780
+ test('order by N', modelOK('query: a->{ order_by: 1 asc; group_by: astr }'));
781
+ test('order by multiple', modelOK(`
782
782
  query: a->{
783
783
  order_by: 1 asc, af desc
784
784
  group_by: astr, af
785
785
  }
786
786
  `));
787
- test("where single", modelOK("query:a->{ group_by: astr; where: af > 10 }"));
788
- test("having single", modelOK("query:ab->{ aggregate: acount; group_by: astr; having: acount > 10 }"));
789
- test("compound having still works", modelOK("query:ab->{ aggregate: acount; having: acount > 10 and acount < 100 }"));
790
- test("compound aggregate still works", modelOK("query:ab->{ aggregate: thing is acount > 10 and acount < 100 }"));
791
- test("where multiple", modelOK("query:a->{ group_by: astr; where: af > 10,astr~'a%' }"));
792
- test(`filters preserve source formatting in code:`, () => {
793
- const model = new BetaModel(`source: notb is a + { where: astr != 'b' }`);
787
+ test('where single', modelOK('query:a->{ group_by: astr; where: af > 10 }'));
788
+ test('having single', modelOK('query:ab->{ aggregate: acount; group_by: astr; having: acount > 10 }'));
789
+ test('compound having still works', modelOK('query:ab->{ aggregate: acount; having: acount > 10 and acount < 100 }'));
790
+ test('compound aggregate still works', modelOK('query:ab->{ aggregate: thing is acount > 10 and acount < 100 }'));
791
+ test('where multiple', modelOK("query:a->{ group_by: astr; where: af > 10,astr~'a%' }"));
792
+ test('filters preserve source formatting in code:', () => {
793
+ const model = new BetaModel("source: notb is a + { where: astr != 'b' }");
794
794
  expect(model).modelCompiled();
795
- const notb = model.getSourceDef("notb");
795
+ const notb = model.getSourceDef('notb');
796
796
  expect(notb).toBeDefined();
797
797
  if (notb) {
798
798
  const f = notb.filterList;
@@ -802,27 +802,27 @@ describe("qops", () => {
802
802
  }
803
803
  }
804
804
  });
805
- test(`field expressions preserve source formatting in code:`, () => {
806
- const model = new BetaModel(`source: notb is a + { dimension: d is 1 + 2 }`);
805
+ test('field expressions preserve source formatting in code:', () => {
806
+ const model = new BetaModel('source: notb is a + { dimension: d is 1 + 2 }');
807
807
  expect(model).modelCompiled();
808
- const notb = model.getSourceDef("notb");
808
+ const notb = model.getSourceDef('notb');
809
809
  expect(notb).toBeDefined();
810
810
  if (notb) {
811
- const d = notb.fields.find((f) => f.as || f.name === "d");
811
+ const d = notb.fields.find(f => f.as || f.name === 'd');
812
812
  expect(d).toBeDefined();
813
- expect(d === null || d === void 0 ? void 0 : d.type).toBe("number");
814
- if ((d === null || d === void 0 ? void 0 : d.type) === "number") {
815
- expect(d.code).toBe("1 + 2");
813
+ expect(d === null || d === void 0 ? void 0 : d.type).toBe('number');
814
+ if ((d === null || d === void 0 ? void 0 : d.type) === 'number') {
815
+ expect(d.code).toBe('1 + 2');
816
816
  }
817
817
  }
818
818
  });
819
- test("nest single", modelOK(`
819
+ test('nest single', modelOK(`
820
820
  query: a->{
821
821
  group_by: ai
822
822
  nest: nestbystr is { group_by: astr; aggregate: N is count() }
823
823
  }
824
824
  `));
825
- test("nest multiple", modelOK(`
825
+ test('nest multiple', modelOK(`
826
826
  query: a->{
827
827
  group_by: ai
828
828
  nest:
@@ -830,8 +830,8 @@ describe("qops", () => {
830
830
  renest is { group_by: astr; aggregate: N is count() }
831
831
  }
832
832
  `));
833
- test("nest ref", modelOK("query: ab->{group_by: ai; nest: aturtle}"));
834
- test("refine query with extended source", () => {
833
+ test('nest ref', modelOK('query: ab->{group_by: ai; nest: aturtle}'));
834
+ test('refine query with extended source', () => {
835
835
  const m = new BetaModel(`
836
836
  source: nab is ab {
837
837
  query: xturtle is aturtle + {
@@ -844,20 +844,20 @@ describe("qops", () => {
844
844
  const t = m.translate();
845
845
  if (t.translated) {
846
846
  const q = t.translated.queryList[0].pipeline[0];
847
- if (q.type == "reduce" && q.extendSource) {
847
+ if (q.type === 'reduce' && q.extendSource) {
848
848
  expect(q.extendSource.length).toBe(1);
849
849
  const f = q.extendSource[0];
850
- expect(f.type).toBe("number");
851
- if (f.type == "number") {
850
+ expect(f.type).toBe('number');
851
+ if (f.type === 'number') {
852
852
  expect((0, model_1.expressionIsCalculation)(f.expressionType)).toBeTruthy();
853
853
  }
854
854
  }
855
855
  else {
856
- fail("Did not generate extendSource");
856
+ fail('Did not generate extendSource');
857
857
  }
858
858
  }
859
859
  });
860
- test("refine query source with field", () => {
860
+ test('refine query source with field', () => {
861
861
  const m = new BetaModel(`
862
862
  query: ab -> aturtle + {
863
863
  declare: aratio is ai / acount
@@ -868,20 +868,20 @@ describe("qops", () => {
868
868
  const t = m.translate();
869
869
  if (t.translated) {
870
870
  const q = t.translated.queryList[0].pipeline[0];
871
- if (q.type == "reduce" && q.extendSource) {
871
+ if (q.type === 'reduce' && q.extendSource) {
872
872
  expect(q.extendSource.length).toBe(1);
873
873
  const f = q.extendSource[0];
874
- expect(f.type).toBe("number");
875
- if (f.type == "number") {
874
+ expect(f.type).toBe('number');
875
+ if (f.type === 'number') {
876
876
  expect((0, model_1.expressionIsCalculation)(f.expressionType)).toBeTruthy();
877
877
  }
878
878
  }
879
879
  else {
880
- fail("Did not generate extendSource");
880
+ fail('Did not generate extendSource');
881
881
  }
882
882
  }
883
883
  });
884
- test("refine query source with join", () => {
884
+ test('refine query source with join', () => {
885
885
  const m = new BetaModel(`
886
886
  query: ab -> aturtle + {
887
887
  join_one: bb is b on bb.astr = astr
@@ -892,89 +892,89 @@ describe("qops", () => {
892
892
  const t = m.translate();
893
893
  if (t.translated) {
894
894
  const q = t.translated.queryList[0].pipeline[0];
895
- if (q.type == "reduce" && q.extendSource) {
895
+ if (q.type === 'reduce' && q.extendSource) {
896
896
  expect(q.extendSource.length).toBe(1);
897
- expect(q.extendSource[0].type).toBe("struct");
897
+ expect(q.extendSource[0].type).toBe('struct');
898
898
  }
899
899
  else {
900
- fail("Did not generate extendSource");
900
+ fail('Did not generate extendSource');
901
901
  }
902
902
  }
903
903
  });
904
904
  });
905
- describe("expressions", () => {
906
- describe("literals", () => {
907
- test("integer", exprOK("42"));
908
- test("string", exprOK(`'fortywo-two'`));
909
- test("string with quoted quote", exprOK(`'Isn` + `\\` + `'t this nice'`));
910
- test("string with quoted backslash", exprOK(`'Is ` + `\\` + `\\` + ` nice'`));
911
- test("year", exprOK("@1960"));
912
- test("quarter", exprOK("@1960-Q1"));
913
- test("week", exprOK("@WK1960-06-26"));
914
- test("month", exprOK("@1960-06"));
915
- test("day", exprOK("@1960-06-30"));
916
- test("minute", exprOK("@1960-06-30 10:30"));
917
- test("second", exprOK("@1960-06-30 10:30:31"));
918
- test("null", exprOK("null"));
919
- test("now", exprOK("now"));
920
- test("true", exprOK("true"));
921
- test("false", exprOK("false"));
922
- test("regex", exprOK("r'RegularExpression'"));
923
- });
924
- describe("timeframes", () => {
905
+ describe('expressions', () => {
906
+ describe('literals', () => {
907
+ test('integer', exprOK('42'));
908
+ test('string', exprOK("'fortywo-two'"));
909
+ test('string with quoted quote', exprOK("'Isn" + '\\' + "'t this nice'"));
910
+ test('string with quoted backslash', exprOK("'Is " + '\\' + '\\' + " nice'"));
911
+ test('year', exprOK('@1960'));
912
+ test('quarter', exprOK('@1960-Q1'));
913
+ test('week', exprOK('@WK1960-06-26'));
914
+ test('month', exprOK('@1960-06'));
915
+ test('day', exprOK('@1960-06-30'));
916
+ test('minute', exprOK('@1960-06-30 10:30'));
917
+ test('second', exprOK('@1960-06-30 10:30:31'));
918
+ test('null', exprOK('null'));
919
+ test('now', exprOK('now'));
920
+ test('true', exprOK('true'));
921
+ test('false', exprOK('false'));
922
+ test('regex', exprOK("r'RegularExpression'"));
923
+ });
924
+ describe('timeframes', () => {
925
925
  const timeframes = [
926
- "second",
927
- "minute",
928
- "hour",
929
- "day",
930
- "week",
931
- "month",
932
- "quarter",
933
- "year"
926
+ 'second',
927
+ 'minute',
928
+ 'hour',
929
+ 'day',
930
+ 'week',
931
+ 'month',
932
+ 'quarter',
933
+ 'year',
934
934
  ];
935
- describe("timestamp truncation", () => {
935
+ describe('timestamp truncation', () => {
936
936
  for (const unit of timeframes) {
937
937
  test(`timestamp truncate ${unit}`, exprOK(`ats.${unit}`));
938
938
  }
939
939
  });
940
- describe("timestamp difference", () => {
940
+ describe('timestamp difference', () => {
941
941
  for (const unit of timeframes) {
942
942
  // TODO expect these to error ...
943
943
  test(`timestamp extract ${unit}`, exprOK(`${unit}(@2021 to ats)`));
944
944
  }
945
945
  });
946
946
  });
947
- test("field name", exprOK("astr"));
948
- test("function call", exprOK("CURRENT_TIMESTAMP()"));
949
- describe("operators", () => {
950
- test("addition", exprOK("42 + 7"));
951
- test("subtraction", exprOK("42 - 7"));
952
- test("multiplication", exprOK("42 * 7"));
953
- test("mod", exprOK("42 % 7"));
954
- test("division", exprOK("42 / 7"));
955
- test("unary negation", exprOK("- ai"));
956
- test("equal", exprOK("42 = 7"));
957
- test("not equal", exprOK("42 != 7"));
958
- test("greater than", exprOK("42 > 7"));
959
- test("greater than or equal", exprOK("42 >= 7"));
960
- test("less than or equal", exprOK("42 <= 7"));
961
- test("less than", exprOK("42 < 7"));
962
- test("match", exprOK("'forty-two' ~ 'fifty-four'"));
963
- test("not match", exprOK("'forty-two' !~ 'fifty-four'"));
964
- test("apply", exprOK("'forty-two' ? 'fifty-four'"));
965
- test("not", exprOK("not true"));
966
- test("and", exprOK("true and false"));
967
- test("or", exprOK("true or false"));
968
- });
969
- test("filtered measure", exprOK("acount {? astr = 'why?' }"));
970
- describe("aggregate forms", () => {
971
- test("count", exprOK("count()"));
972
- test("count distinct", exprOK("count(distinct astr)"));
973
- test("join.count()", exprOK("b.count()"));
974
- for (const f of ["sum", "min", "max", "avg"]) {
947
+ test('field name', exprOK('astr'));
948
+ test('function call', exprOK('CURRENT_TIMESTAMP()'));
949
+ describe('operators', () => {
950
+ test('addition', exprOK('42 + 7'));
951
+ test('subtraction', exprOK('42 - 7'));
952
+ test('multiplication', exprOK('42 * 7'));
953
+ test('mod', exprOK('42 % 7'));
954
+ test('division', exprOK('42 / 7'));
955
+ test('unary negation', exprOK('- ai'));
956
+ test('equal', exprOK('42 = 7'));
957
+ test('not equal', exprOK('42 != 7'));
958
+ test('greater than', exprOK('42 > 7'));
959
+ test('greater than or equal', exprOK('42 >= 7'));
960
+ test('less than or equal', exprOK('42 <= 7'));
961
+ test('less than', exprOK('42 < 7'));
962
+ test('match', exprOK("'forty-two' ~ 'fifty-four'"));
963
+ test('not match', exprOK("'forty-two' !~ 'fifty-four'"));
964
+ test('apply', exprOK("'forty-two' ? 'fifty-four'"));
965
+ test('not', exprOK('not true'));
966
+ test('and', exprOK('true and false'));
967
+ test('or', exprOK('true or false'));
968
+ });
969
+ test('filtered measure', exprOK("acount {? astr = 'why?' }"));
970
+ describe('aggregate forms', () => {
971
+ test('count', exprOK('count()'));
972
+ test('count distinct', exprOK('count(distinct astr)'));
973
+ test('join.count()', exprOK('b.count()'));
974
+ for (const f of ['sum', 'min', 'max', 'avg']) {
975
975
  const fOfT = `${f}(af)`;
976
976
  test(fOfT, exprOK(fOfT));
977
- if (f !== "min" && f !== "max") {
977
+ if (f !== 'min' && f !== 'max') {
978
978
  const joinDot = `b.af.${f}()`;
979
979
  test(joinDot, exprOK(joinDot));
980
980
  const joinAgg = `b.${f}(af)`;
@@ -982,47 +982,47 @@ describe("expressions", () => {
982
982
  }
983
983
  }
984
984
  });
985
- describe("pick statements", () => {
986
- test("full", exprOK(`
985
+ describe('pick statements', () => {
986
+ test('full', exprOK(`
987
987
  pick 'the answer' when ai = 42
988
988
  pick 'the questionable answer' when ai = 54
989
989
  else 'random'
990
990
  `));
991
- test("applied", exprOK(`
991
+ test('applied', exprOK(`
992
992
  astr ?
993
993
  pick 'the answer' when = '42'
994
994
  pick 'the questionable answer' when = '54'
995
995
  else 'random'
996
996
  `));
997
- test("filtering", exprOK(`
997
+ test('filtering', exprOK(`
998
998
  astr ? pick 'missing value' when NULL
999
999
  `));
1000
- test("tiering", exprOK(`
1000
+ test('tiering', exprOK(`
1001
1001
  ai ?
1002
1002
  pick 1 when < 10
1003
1003
  pick 10 when < 100
1004
1004
  pick 100 when < 1000
1005
1005
  else 10000
1006
1006
  `));
1007
- test("transforming", exprOK(`
1007
+ test('transforming', exprOK(`
1008
1008
  ai ?
1009
1009
  pick 'small' when < 10
1010
1010
  pick 'medium' when < 100
1011
1011
  else 'large'
1012
1012
  `));
1013
- test("when single values", exprOK(`
1013
+ test('when single values', exprOK(`
1014
1014
  ai ?
1015
1015
  pick 'one' when 1
1016
1016
  else 'a lot'
1017
1017
  `));
1018
- test("n-ary without else", () => {
1018
+ test('n-ary without else', () => {
1019
1019
  expect((0, test_translator_1.markSource) `
1020
1020
  explore: na is a + { dimension: d is
1021
1021
  pick 7 when true and true
1022
1022
  }
1023
1023
  `).compileToFailWith("pick incomplete, missing 'else'", "Cannot define 'd', value has unknown type");
1024
1024
  });
1025
- test("n-ary with mismatch when clauses", () => {
1025
+ test('n-ary with mismatch when clauses', () => {
1026
1026
  expect((0, test_translator_1.markSource) `
1027
1027
  explore: na is a + { dimension: d is
1028
1028
  pick 7 when true and true
@@ -1031,7 +1031,7 @@ describe("expressions", () => {
1031
1031
  }
1032
1032
  `).compileToFailWith("pick type 'string', expected 'number'", "Cannot define 'd', value has unknown type");
1033
1033
  });
1034
- test("n-ary with mismatched else clause", () => {
1034
+ test('n-ary with mismatched else clause', () => {
1035
1035
  expect((0, test_translator_1.markSource) `
1036
1036
  explore: na is a + { dimension: d is
1037
1037
  pick 7 when true and true
@@ -1039,21 +1039,21 @@ describe("expressions", () => {
1039
1039
  }
1040
1040
  `).compileToFailWith("else type 'string', expected 'number'", "Cannot define 'd', value has unknown type");
1041
1041
  });
1042
- test("applied else mismatch", () => {
1042
+ test('applied else mismatch', () => {
1043
1043
  expect((0, test_translator_1.markSource) `
1044
1044
  explore: na is a + { dimension: d is
1045
1045
  7 ? pick 7 when 7 else 'not seven'
1046
1046
  }
1047
1047
  `).compileToFailWith("else type 'string', expected 'number'", "Cannot define 'd', value has unknown type");
1048
1048
  });
1049
- test("applied default mismatch", () => {
1049
+ test('applied default mismatch', () => {
1050
1050
  expect((0, test_translator_1.markSource) `
1051
1051
  explore: na is a + { dimension: d is
1052
1052
  7 ? pick 'seven' when 7
1053
1053
  }
1054
1054
  `).compileToFailWith("pick default type 'number', expected 'string'", "Cannot define 'd', value has unknown type");
1055
1055
  });
1056
- test("applied when mismatch", () => {
1056
+ test('applied when mismatch', () => {
1057
1057
  expect((0, test_translator_1.markSource) `
1058
1058
  explore: na is a + { dimension: d is
1059
1059
  7 ? pick 'seven' when 7 pick 6 when 6
@@ -1061,89 +1061,89 @@ describe("expressions", () => {
1061
1061
  `).compileToFailWith("pick type 'number', expected 'string'", "Cannot define 'd', value has unknown type");
1062
1062
  });
1063
1063
  });
1064
- test("paren and applied div", () => {
1064
+ test('paren and applied div', () => {
1065
1065
  var _a, _b;
1066
- const modelSrc = `query: z is a -> { group_by: x is 1+(3/4) }`;
1066
+ const modelSrc = 'query: z is a -> { group_by: x is 1+(3/4) }';
1067
1067
  const m = new BetaModel(modelSrc);
1068
1068
  expect(m).modelCompiled();
1069
1069
  const queryDef = (_b = (_a = m.translate()) === null || _a === void 0 ? void 0 : _a.translated) === null || _b === void 0 ? void 0 : _b.modelDef.contents.z;
1070
1070
  expect(queryDef).toBeDefined();
1071
- expect(queryDef === null || queryDef === void 0 ? void 0 : queryDef.type).toBe("query");
1072
- if (queryDef && queryDef.type == "query") {
1071
+ expect(queryDef === null || queryDef === void 0 ? void 0 : queryDef.type).toBe('query');
1072
+ if (queryDef && queryDef.type === 'query') {
1073
1073
  const x = queryDef.pipeline[0].fields[0];
1074
- if (typeof x != "string" &&
1074
+ if (typeof x !== 'string' &&
1075
1075
  !(0, model_1.isFilteredAliasedName)(x) &&
1076
1076
  (0, model_1.isFieldTypeDef)(x) &&
1077
- x.type == "number" &&
1077
+ x.type === 'number' &&
1078
1078
  x.e) {
1079
1079
  const firstFrag = x.e[0];
1080
- if (typeof firstFrag == "string") {
1081
- expect(firstFrag).toContain("(");
1080
+ if (typeof firstFrag === 'string') {
1081
+ expect(firstFrag).toContain('(');
1082
1082
  }
1083
1083
  else {
1084
- fail("expression with parens compiled oddly");
1084
+ fail('expression with parens compiled oddly');
1085
1085
  }
1086
1086
  }
1087
1087
  else {
1088
- fail("expression with parens compiled oddly");
1088
+ fail('expression with parens compiled oddly');
1089
1089
  }
1090
1090
  }
1091
1091
  });
1092
1092
  });
1093
- describe("unspported fields in schema", () => {
1094
- test("unsupported reference in result allowed", () => {
1095
- const uModel = new BetaModel(`query: a->{ group_by: aun }`);
1093
+ describe('unspported fields in schema', () => {
1094
+ test('unsupported reference in result allowed', () => {
1095
+ const uModel = new BetaModel('query: a->{ group_by: aun }');
1096
1096
  expect(uModel).modelCompiled();
1097
1097
  });
1098
- test("unsupported reference can be compared to NULL", () => {
1099
- const uModel = new BetaModel(`query: a->{ where: aun != NULL; project: * }`);
1098
+ test('unsupported reference can be compared to NULL', () => {
1099
+ const uModel = new BetaModel('query: a->{ where: aun != NULL; project: * }');
1100
1100
  expect(uModel).modelCompiled();
1101
1101
  });
1102
- test("flag unsupported equality", () => {
1102
+ test('flag unsupported equality', () => {
1103
1103
  // because we don't know if the two unsupported types are comparable
1104
- const uModel = new BetaModel(`query: ab->{ where: aun = b.aun project: * }`);
1105
- expect(uModel).compileToFailWith("Unsupported type not allowed in expression");
1104
+ const uModel = new BetaModel('query: ab->{ where: aun = b.aun project: * }');
1105
+ expect(uModel).compileToFailWith('Unsupported type not allowed in expression');
1106
1106
  });
1107
- test("flag unsupported compare", () => {
1107
+ test('flag unsupported compare', () => {
1108
1108
  // because we don't know if the two unsupported types are comparable
1109
- const uModel = new BetaModel(`query: ab->{ where: aun > b.aun project: * }`);
1110
- expect(uModel).compileToFailWith("Unsupported type not allowed in expression");
1109
+ const uModel = new BetaModel('query: ab->{ where: aun > b.aun project: * }');
1110
+ expect(uModel).compileToFailWith('Unsupported type not allowed in expression');
1111
1111
  });
1112
- test("allow unsupported equality when raw types match", () => {
1113
- const uModel = new BetaModel(`query: ab->{ where: aweird = b.aweird project: * }`);
1112
+ test('allow unsupported equality when raw types match', () => {
1113
+ const uModel = new BetaModel('query: ab->{ where: aweird = b.aweird project: * }');
1114
1114
  expect(uModel).modelCompiled();
1115
1115
  });
1116
- test("flag not applied to unsupported", () => {
1117
- const uModel = new BetaModel(`source: x is a { dimension: notUn is not aun }`);
1116
+ test('flag not applied to unsupported', () => {
1117
+ const uModel = new BetaModel('source: x is a { dimension: notUn is not aun }');
1118
1118
  expect(uModel).compileToFailWith("'not' Can't use type unsupported");
1119
1119
  });
1120
- test("allow unsupported to be cast", () => {
1121
- const uModel = new BetaModel(`source: x is a { dimension: notUn is aun::string }`);
1120
+ test('allow unsupported to be cast', () => {
1121
+ const uModel = new BetaModel('source: x is a { dimension: notUn is aun::string }');
1122
1122
  expect(uModel).modelCompiled();
1123
1123
  });
1124
1124
  });
1125
- describe("sql:", () => {
1125
+ describe('sql:', () => {
1126
1126
  function makeSchemaResponse(sql) {
1127
- const cname = sql.connection || "bigquery";
1127
+ const cname = sql.connection || 'bigquery';
1128
1128
  return {
1129
- "type": "struct",
1130
- "name": sql.name,
1131
- "dialect": "standardsql'",
1132
- "structSource": {
1133
- "type": "sql",
1134
- "method": "subquery",
1135
- "sqlBlock": {
1136
- "type": "sqlBlock",
1129
+ type: 'struct',
1130
+ name: sql.name,
1131
+ dialect: "standardsql'",
1132
+ structSource: {
1133
+ type: 'sql',
1134
+ method: 'subquery',
1135
+ sqlBlock: {
1136
+ type: 'sqlBlock',
1137
1137
  ...sql,
1138
- "selectStr": sql.select.filter((s) => typeof s == "string").join("")
1139
- }
1138
+ selectStr: sql.select.filter(s => typeof s === 'string').join(''),
1139
+ },
1140
1140
  },
1141
- "structRelationship": { "type": "basetable", "connectionName": cname },
1142
- "fields": test_translator_1.aTableDef.fields
1141
+ structRelationship: { type: 'basetable', connectionName: cname },
1142
+ fields: test_translator_1.aTableDef.fields,
1143
1143
  };
1144
1144
  }
1145
- test("definition", () => {
1146
- const selStmt = "SELECT * FROM aTable";
1145
+ test('definition', () => {
1146
+ const selStmt = 'SELECT * FROM aTable';
1147
1147
  const model = new BetaModel(`
1148
1148
  sql: users IS {
1149
1149
  select: """${selStmt}"""
@@ -1155,20 +1155,20 @@ describe("sql:", () => {
1155
1155
  const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
1156
1156
  expect(needs).toBeDefined();
1157
1157
  if (needs) {
1158
- const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }], "aConnection");
1158
+ const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }], 'aConnection');
1159
1159
  expect(needs).toMatchObject(sql);
1160
1160
  const refKey = needs.name;
1161
1161
  expect(refKey).toBeDefined();
1162
1162
  if (refKey) {
1163
1163
  const sr = makeSchemaResponse(sql);
1164
- model.update({ "compileSQL": { [refKey]: sr } });
1164
+ model.update({ compileSQL: { [refKey]: sr } });
1165
1165
  expect(model).modelCompiled();
1166
- expect(unlocatedStructDef(model.sqlBlocks[0])).toEqual(unlocatedStructDef({ ...sr, "as": "users" }));
1166
+ expect(unlocatedStructDef(model.sqlBlocks[0])).toEqual(unlocatedStructDef({ ...sr, as: 'users' }));
1167
1167
  }
1168
1168
  }
1169
1169
  });
1170
- test("source from sql", () => {
1171
- const selStmt = "SELECT * FROM aTable";
1170
+ test('source from sql', () => {
1171
+ const selStmt = 'SELECT * FROM aTable';
1172
1172
  const model = new BetaModel(`
1173
1173
  sql: users IS { select: """${selStmt}""" }
1174
1174
  source: malloyUsers is from_sql(users) { primary_key: ai }
@@ -1178,16 +1178,16 @@ describe("sql:", () => {
1178
1178
  const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
1179
1179
  expect(needs).toBeDefined();
1180
1180
  if (needs) {
1181
- const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }], "aConnection");
1181
+ const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }], 'aConnection');
1182
1182
  const refKey = needs.name;
1183
- model.update({ "compileSQL": { [refKey]: makeSchemaResponse(sql) } });
1183
+ model.update({ compileSQL: { [refKey]: makeSchemaResponse(sql) } });
1184
1184
  expect(model).modelCompiled();
1185
- const users = model.getSourceDef("malloyUsers");
1185
+ const users = model.getSourceDef('malloyUsers');
1186
1186
  expect(users).toBeDefined();
1187
1187
  }
1188
1188
  });
1189
- test("explore from imported sql-based-source", () => {
1190
- const selStmt = "SELECT * FROM aTable";
1189
+ test('explore from imported sql-based-source', () => {
1190
+ const selStmt = 'SELECT * FROM aTable';
1191
1191
  const createModel = `
1192
1192
  sql: users IS { select: """${selStmt}""" }
1193
1193
  source: malloyUsers is from_sql(users) { primary_key: ai }
@@ -1196,16 +1196,16 @@ describe("sql:", () => {
1196
1196
  import "createModel.malloy"
1197
1197
  source: importUsers is malloyUsers
1198
1198
  `);
1199
- model.importZone.define("internal://test/langtests/createModel.malloy", createModel);
1199
+ model.importZone.define('internal://test/langtests/createModel.malloy', createModel);
1200
1200
  expect(model).modelParsed();
1201
1201
  const needReq = model.translate();
1202
1202
  const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
1203
1203
  expect(needs).toBeDefined();
1204
- const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }]);
1205
- model.update({ "compileSQL": { [sql.name]: makeSchemaResponse(sql) } });
1204
+ const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }]);
1205
+ model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
1206
1206
  expect(model).modelCompiled();
1207
1207
  });
1208
- it("turducken", () => {
1208
+ it('turducken', () => {
1209
1209
  const m = new BetaModel(`
1210
1210
  sql: someSql is {
1211
1211
  select: """SELECT * FROM %{ a -> { group_by: astr } }% WHERE 1=1"""
@@ -1218,13 +1218,13 @@ describe("sql:", () => {
1218
1218
  const select = compileSql.select[0];
1219
1219
  const star = compileSql.select[1];
1220
1220
  const where = compileSql.select[2];
1221
- expect(select).toEqual({ "sql": "SELECT * FROM " });
1221
+ expect(select).toEqual({ sql: 'SELECT * FROM ' });
1222
1222
  expect((0, model_1.isSQLFragment)(star)).toBeFalsy();
1223
- expect(where).toEqual({ "sql": " WHERE 1=1" });
1223
+ expect(where).toEqual({ sql: ' WHERE 1=1' });
1224
1224
  }
1225
1225
  });
1226
- it("model preserved", () => {
1227
- const selStmt = "SELECT * FROM aTable";
1226
+ it('model preserved', () => {
1227
+ const selStmt = 'SELECT * FROM aTable';
1228
1228
  const shouldBeOK = `
1229
1229
  source: newa is a
1230
1230
  sql: someSql is { select: """${selStmt}""" }
@@ -1235,20 +1235,20 @@ describe("sql:", () => {
1235
1235
  const needReq = model.translate();
1236
1236
  const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
1237
1237
  expect(needs).toBeDefined();
1238
- const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }]);
1239
- model.update({ "compileSQL": { [sql.name]: makeSchemaResponse(sql) } });
1238
+ const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }]);
1239
+ model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
1240
1240
  expect(model).modelCompiled();
1241
1241
  });
1242
1242
  });
1243
- describe("error handling", () => {
1244
- test("field and query with same name does not overflow", () => {
1243
+ describe('error handling', () => {
1244
+ test('field and query with same name does not overflow', () => {
1245
1245
  expect(`
1246
1246
  source: flights is table('malloytest.flights') {
1247
1247
  query: carrier is { group_by: carrier }
1248
1248
  }
1249
1249
  `).compileToFailWith("Cannot redefine 'carrier'");
1250
1250
  });
1251
- test("redefine source", () => {
1251
+ test('redefine source', () => {
1252
1252
  expect((0, test_translator_1.markSource) `
1253
1253
  source: airports is table('malloytest.airports') + {
1254
1254
  primary_key: code
@@ -1258,27 +1258,27 @@ describe("error handling", () => {
1258
1258
  }
1259
1259
  `).compileToFailWith("Cannot redefine 'airports'");
1260
1260
  });
1261
- test("query from undefined source", () => {
1262
- expect((0, test_translator_1.markSource) `query: ${"x"}->{ project: y }`).compileToFailWith("Undefined source 'x'");
1261
+ test('query from undefined source', () => {
1262
+ expect((0, test_translator_1.markSource) `query: ${'x'}->{ project: y }`).compileToFailWith("Undefined source 'x'");
1263
1263
  });
1264
- test("query with expression from undefined source", () => {
1264
+ test('query with expression from undefined source', () => {
1265
1265
  // Regression check: Once upon a time this died with an exception even
1266
1266
  // when "query: x->{ group_by: y}" (above) generated the correct error.
1267
- expect((0, test_translator_1.markSource) `query: ${"x"}->{ project: y is z / 2 }`).compileToFailWith("Undefined source 'x'");
1267
+ expect((0, test_translator_1.markSource) `query: ${'x'}->{ project: y is z / 2 }`).compileToFailWith("Undefined source 'x'");
1268
1268
  });
1269
- test("join reference before definition", () => {
1269
+ test('join reference before definition', () => {
1270
1270
  expect((0, test_translator_1.markSource) `
1271
- explore: newAB is a { join_one: newB is ${"bb"} on astring }
1271
+ explore: newAB is a { join_one: newB is ${'bb'} on astring }
1272
1272
  explore: newB is b
1273
1273
  `).compileToFailWith("Undefined source 'bb'");
1274
1274
  });
1275
- test("non-rename rename", badModel("explore: na is a { rename: astr is astr }", "Can't rename field to itself"));
1276
- test("reference to field in its definition", badModel(`explore: na is a { dimension: ustr is UPPER(ustr) } `, "Circular reference to 'ustr' in definition"));
1277
- test("empty model", modelOK(""));
1278
- test("one line model ", modelOK("\n"));
1279
- test("query without fields", badModel(`query: a -> { top: 5 }`, "Can't determine query type (group_by/aggregate/nest,project,index)"));
1280
- test("refine can't change query type", badModel(`query: ab -> aturtle { project: astr }`, "project: not legal in grouping query"));
1281
- test("undefined field ref in query", badModel(`query: ab -> { aggregate: xyzzy }`, "'xyzzy' is not defined"));
1275
+ test('non-rename rename', badModel('explore: na is a { rename: astr is astr }', "Can't rename field to itself"));
1276
+ test('reference to field in its definition', badModel('explore: na is a { dimension: ustr is UPPER(ustr) } ', "Circular reference to 'ustr' in definition"));
1277
+ test('empty model', modelOK(''));
1278
+ test('one line model ', modelOK('\n'));
1279
+ test('query without fields', badModel('query: a -> { top: 5 }', "Can't determine query type (group_by/aggregate/nest,project,index)"));
1280
+ test("refine can't change query type", badModel('query: ab -> aturtle { project: astr }', 'project: not legal in grouping query'));
1281
+ test('undefined field ref in query', badModel('query: ab -> { aggregate: xyzzy }', "'xyzzy' is not defined"));
1282
1282
  // test("queries with anonymous expressions", () => {
1283
1283
  // const m = new BetaModel("query: a->{\n group_by: a+1\n}");
1284
1284
  // expect(m).not.modelParsed();
@@ -1286,32 +1286,32 @@ describe("error handling", () => {
1286
1286
  // const firstError = errList[0];
1287
1287
  // expect(firstError.message).toBe("Expressions in queries must have names");
1288
1288
  // });
1289
- test("query on source with errors", () => {
1289
+ test('query on source with errors', () => {
1290
1290
  expect((0, test_translator_1.markSource) `
1291
- explore: na is a { join_one: ${"n"} on astr }
1291
+ explore: na is a { join_one: ${'n'} on astr }
1292
1292
  `).compileToFailWith("Undefined source 'n'");
1293
1293
  });
1294
- test("detect duplicate output field names", () => {
1295
- expect((0, test_translator_1.markSource) `query: ab -> { group_by: astr, ${"astr"} }`).compileToFailWith("Output already has a field named 'astr'");
1294
+ test('detect duplicate output field names', () => {
1295
+ expect((0, test_translator_1.markSource) `query: ab -> { group_by: astr, ${'astr'} }`).compileToFailWith("Output already has a field named 'astr'");
1296
1296
  });
1297
- test("detect join tail overlap existing ref", () => {
1298
- expect((0, test_translator_1.markSource) `query: ab -> { group_by: astr, ${"b.astr"} }`).compileToFailWith("Output already has a field named 'astr'");
1297
+ test('detect join tail overlap existing ref', () => {
1298
+ expect((0, test_translator_1.markSource) `query: ab -> { group_by: astr, ${'b.astr'} }`).compileToFailWith("Output already has a field named 'astr'");
1299
1299
  });
1300
- test("undefined in expression with regex compare", () => {
1300
+ test('undefined in expression with regex compare', () => {
1301
1301
  expect(`
1302
1302
  source: c is a {
1303
1303
  dimension: d is meaning_of_life ~ r'(forty two|fifty four)'
1304
1304
  }
1305
1305
  `).compileToFailWith("'meaning_of_life' is not defined");
1306
1306
  });
1307
- test("detect output collision on join references", () => {
1307
+ test('detect output collision on join references', () => {
1308
1308
  expect(`
1309
1309
  query: ab -> {
1310
1310
  group_by: astr, b.astr
1311
1311
  }
1312
1312
  `).compileToFailWith("Output already has a field named 'astr'");
1313
1313
  });
1314
- test("rejoin a query is renamed", modelOK(`
1314
+ test('rejoin a query is renamed', modelOK(`
1315
1315
  source: querySrc is from(
1316
1316
  table('malloytest.flights')->{
1317
1317
  group_by: origin
@@ -1326,123 +1326,123 @@ describe("error handling", () => {
1326
1326
  }
1327
1327
  }
1328
1328
  `));
1329
- test("popping out of embedding when not embedded", () => {
1330
- expect("}%").compileToFailWith("extraneous input '}%' expecting {<EOF>, EXPLORE, QUERY, SOURCE, SQL, IMPORT, ';'}");
1329
+ test('popping out of embedding when not embedded', () => {
1330
+ expect('}%').compileToFailWith("extraneous input '}%' expecting {<EOF>, EXPLORE, QUERY, SOURCE, SQL, IMPORT, ';'}");
1331
1331
  });
1332
- test("bad sql in sql block", () => {
1333
- const badModel = new BetaModel(`sql: { select: """)""" }`);
1332
+ test('bad sql in sql block', () => {
1333
+ const badModel = new BetaModel('sql: { select: """)""" }');
1334
1334
  expect(badModel).modelParsed();
1335
1335
  const needSchema = badModel.translate();
1336
1336
  expect(needSchema.compileSQL).toBeDefined();
1337
1337
  if (needSchema.compileSQL) {
1338
1338
  badModel.update({
1339
- "errors": {
1340
- "compileSQL": {
1341
- [needSchema.compileSQL.name]: "ZZZZ"
1342
- }
1343
- }
1339
+ errors: {
1340
+ compileSQL: {
1341
+ [needSchema.compileSQL.name]: 'ZZZZ',
1342
+ },
1343
+ },
1344
1344
  });
1345
1345
  }
1346
- expect(badModel).compileToFailWith("Invalid SQL, ZZZZ");
1346
+ expect(badModel).compileToFailWith('Invalid SQL, ZZZZ');
1347
1347
  });
1348
1348
  });
1349
1349
  function getSelectOneStruct(sqlBlock) {
1350
1350
  const selectThis = sqlBlock.select[0];
1351
1351
  if (!(0, model_1.isSQLFragment)(selectThis)) {
1352
- throw new Error("weird test support error sorry");
1352
+ throw new Error('weird test support error sorry');
1353
1353
  }
1354
1354
  return {
1355
- "type": "struct",
1356
- "name": sqlBlock.name,
1357
- "dialect": "bigquery",
1358
- "structSource": {
1359
- "type": "sql",
1360
- "method": "subquery",
1361
- "sqlBlock": {
1362
- "type": "sqlBlock",
1363
- "name": sqlBlock.name,
1364
- "selectStr": selectThis.sql
1365
- }
1355
+ type: 'struct',
1356
+ name: sqlBlock.name,
1357
+ dialect: 'bigquery',
1358
+ structSource: {
1359
+ type: 'sql',
1360
+ method: 'subquery',
1361
+ sqlBlock: {
1362
+ type: 'sqlBlock',
1363
+ name: sqlBlock.name,
1364
+ selectStr: selectThis.sql,
1365
+ },
1366
1366
  },
1367
- "structRelationship": { "type": "basetable", "connectionName": "bigquery" },
1368
- "fields": [{ "type": "number", "name": "one" }]
1367
+ structRelationship: { type: 'basetable', connectionName: 'bigquery' },
1368
+ fields: [{ type: 'number', name: 'one' }],
1369
1369
  };
1370
1370
  }
1371
- describe("source locations", () => {
1372
- test("renamed explore location", () => {
1373
- const source = (0, test_translator_1.markSource) `explore: ${"na is a"}`;
1371
+ describe('source locations', () => {
1372
+ test('renamed explore location', () => {
1373
+ const source = (0, test_translator_1.markSource) `explore: ${'na is a'}`;
1374
1374
  const m = new BetaModel(source.code);
1375
1375
  expect(m).modelParsed();
1376
- expect((0, test_translator_1.getExplore)(m.modelDef, "na").location).toMatchObject(source.locations[0]);
1376
+ expect((0, test_translator_1.getExplore)(m.modelDef, 'na').location).toMatchObject(source.locations[0]);
1377
1377
  });
1378
- test("refined explore location", () => {
1379
- const source = (0, test_translator_1.markSource) `explore: ${"na is a {}"}`;
1378
+ test('refined explore location', () => {
1379
+ const source = (0, test_translator_1.markSource) `explore: ${'na is a {}'}`;
1380
1380
  const m = new BetaModel(source.code);
1381
1381
  expect(m).modelParsed();
1382
- expect((0, test_translator_1.getExplore)(m.modelDef, "na").location).toMatchObject(source.locations[0]);
1382
+ expect((0, test_translator_1.getExplore)(m.modelDef, 'na').location).toMatchObject(source.locations[0]);
1383
1383
  });
1384
- test("location of defined dimension", () => {
1385
- const source = (0, test_translator_1.markSource) `explore: na is a { dimension: ${"x is 1"} }`;
1384
+ test('location of defined dimension', () => {
1385
+ const source = (0, test_translator_1.markSource) `explore: na is a { dimension: ${'x is 1'} }`;
1386
1386
  const m = new BetaModel(source.code);
1387
1387
  expect(m).modelCompiled();
1388
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1389
- const x = (0, test_translator_1.getField)(na, "x");
1388
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1389
+ const x = (0, test_translator_1.getField)(na, 'x');
1390
1390
  expect(x.location).toMatchObject(source.locations[0]);
1391
1391
  });
1392
- test("location of defined measure", () => {
1393
- const source = (0, test_translator_1.markSource) `explore: na is a { measure: ${"x is count()"} }`;
1392
+ test('location of defined measure', () => {
1393
+ const source = (0, test_translator_1.markSource) `explore: na is a { measure: ${'x is count()'} }`;
1394
1394
  const m = new BetaModel(source.code);
1395
1395
  expect(m).modelCompiled();
1396
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1397
- const x = (0, test_translator_1.getField)(na, "x");
1396
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1397
+ const x = (0, test_translator_1.getField)(na, 'x');
1398
1398
  expect(x.location).toMatchObject(source.locations[0]);
1399
1399
  });
1400
- test("location of defined query", () => {
1401
- const source = (0, test_translator_1.markSource) `explore: na is a { query: ${"x is { group_by: y is 1 }"} }`;
1400
+ test('location of defined query', () => {
1401
+ const source = (0, test_translator_1.markSource) `explore: na is a { query: ${'x is { group_by: y is 1 }'} }`;
1402
1402
  const m = new BetaModel(source.code);
1403
1403
  expect(m).modelCompiled();
1404
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1405
- const x = (0, test_translator_1.getField)(na, "x");
1404
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1405
+ const x = (0, test_translator_1.getField)(na, 'x');
1406
1406
  expect(x.location).toMatchObject(source.locations[0]);
1407
1407
  });
1408
- test("location of defined field inside a query", () => {
1408
+ test('location of defined field inside a query', () => {
1409
1409
  const source = (0, test_translator_1.markSource) `
1410
1410
  explore: na is a {
1411
1411
  query: x is {
1412
- group_by: ${"y is 1"}
1412
+ group_by: ${'y is 1'}
1413
1413
  }
1414
1414
  }`;
1415
1415
  const m = new BetaModel(source.code);
1416
1416
  expect(m).modelCompiled();
1417
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1418
- const x = (0, test_translator_1.getQueryField)(na, "x");
1419
- const y = (0, test_translator_1.getField)(x.pipeline[0], "y");
1417
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1418
+ const x = (0, test_translator_1.getQueryField)(na, 'x');
1419
+ const y = (0, test_translator_1.getField)(x.pipeline[0], 'y');
1420
1420
  expect(y.location).toMatchObject(source.locations[0]);
1421
1421
  });
1422
- test("location of filtered field inside a query", () => {
1422
+ test('location of filtered field inside a query', () => {
1423
1423
  const source = (0, test_translator_1.markSource) `
1424
1424
  explore: na is a {
1425
1425
  measure: y is count()
1426
1426
  query: x is {
1427
- group_by: ${"z is y { where: true }"}
1427
+ group_by: ${'z is y { where: true }'}
1428
1428
  }
1429
1429
  }`;
1430
1430
  const m = new BetaModel(source.code);
1431
1431
  expect(m).modelCompiled();
1432
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1433
- const x = (0, test_translator_1.getQueryField)(na, "x");
1434
- const z = (0, test_translator_1.getField)(x.pipeline[0], "z");
1432
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1433
+ const x = (0, test_translator_1.getQueryField)(na, 'x');
1434
+ const z = (0, test_translator_1.getField)(x.pipeline[0], 'z');
1435
1435
  expect(z.location).toMatchObject(source.locations[0]);
1436
1436
  });
1437
- test("location of field inherited from table", () => {
1437
+ test('location of field inherited from table', () => {
1438
1438
  const source = (0, test_translator_1.markSource) `explore: na is ${"table('aTable')"}`;
1439
1439
  const m = new BetaModel(source.code);
1440
1440
  expect(m).modelCompiled();
1441
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1442
- const abool = (0, test_translator_1.getField)(na, "abool");
1441
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1442
+ const abool = (0, test_translator_1.getField)(na, 'abool');
1443
1443
  expect(abool.location).toMatchObject(source.locations[0]);
1444
1444
  });
1445
- test("location of field inherited from sql block", () => {
1445
+ test('location of field inherited from sql block', () => {
1446
1446
  const source = (0, test_translator_1.markSource) `--- comment
1447
1447
  sql: s is { select: ${'"""SELECT 1 as one """'} }
1448
1448
  explore: na is from_sql(s)
@@ -1453,112 +1453,112 @@ describe("source locations", () => {
1453
1453
  expect(compileSql).toBeDefined();
1454
1454
  if (compileSql) {
1455
1455
  m.update({
1456
- "compileSQL": { [compileSql.name]: getSelectOneStruct(compileSql) }
1456
+ compileSQL: { [compileSql.name]: getSelectOneStruct(compileSql) },
1457
1457
  });
1458
1458
  expect(m).modelCompiled();
1459
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1460
- const one = (0, test_translator_1.getField)(na, "one");
1459
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1460
+ const one = (0, test_translator_1.getField)(na, 'one');
1461
1461
  expect(one.location).isLocationIn(source.locations[0], source.code);
1462
1462
  }
1463
1463
  });
1464
- test("location of fields inherited from a query", () => {
1464
+ test('location of fields inherited from a query', () => {
1465
1465
  const source = (0, test_translator_1.markSource) `
1466
1466
  explore: na is from(
1467
1467
  ${"table('aTable')"} -> {
1468
1468
  group_by:
1469
1469
  abool
1470
- ${"y is 1"}
1470
+ ${'y is 1'}
1471
1471
  }
1472
1472
  )
1473
1473
  `;
1474
1474
  const m = new BetaModel(source.code);
1475
1475
  expect(m).modelCompiled();
1476
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1477
- const abool = (0, test_translator_1.getField)(na, "abool");
1476
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1477
+ const abool = (0, test_translator_1.getField)(na, 'abool');
1478
1478
  expect(abool.location).toMatchObject(source.locations[0]);
1479
- const y = (0, test_translator_1.getField)(na, "y");
1479
+ const y = (0, test_translator_1.getField)(na, 'y');
1480
1480
  expect(y.location).toMatchObject(source.locations[1]);
1481
1481
  });
1482
- test("location of named query", () => {
1483
- const source = (0, test_translator_1.markSource) `query: ${"q is a -> { project: * }"}`;
1482
+ test('location of named query', () => {
1483
+ const source = (0, test_translator_1.markSource) `query: ${'q is a -> { project: * }'}`;
1484
1484
  const m = new BetaModel(source.code);
1485
1485
  expect(m).modelCompiled();
1486
- const q = (0, test_translator_1.getExplore)(m.modelDef, "q");
1486
+ const q = (0, test_translator_1.getExplore)(m.modelDef, 'q');
1487
1487
  expect(q.location).toMatchObject(source.locations[0]);
1488
1488
  });
1489
- test("location of field in named query", () => {
1490
- const source = (0, test_translator_1.markSource) `query: q is a -> { group_by: ${"b is 1"} }`;
1489
+ test('location of field in named query', () => {
1490
+ const source = (0, test_translator_1.markSource) `query: q is a -> { group_by: ${'b is 1'} }`;
1491
1491
  const m = new BetaModel(source.code);
1492
1492
  expect(m).modelCompiled();
1493
- const q = (0, test_translator_1.getModelQuery)(m.modelDef, "q");
1494
- const a = (0, test_translator_1.getField)(q.pipeline[0], "b");
1493
+ const q = (0, test_translator_1.getModelQuery)(m.modelDef, 'q');
1494
+ const a = (0, test_translator_1.getField)(q.pipeline[0], 'b');
1495
1495
  expect(a.location).toMatchObject(source.locations[0]);
1496
1496
  });
1497
- test("location of named SQL block", () => {
1498
- const source = (0, test_translator_1.markSource) `${`sql: s is { select: """SELECT 1 as one""" }`}`;
1497
+ test('location of named SQL block', () => {
1498
+ const source = (0, test_translator_1.markSource) `${'sql: s is { select: """SELECT 1 as one""" }'}`;
1499
1499
  const m = new BetaModel(source.code);
1500
1500
  expect(m).modelParsed();
1501
1501
  const compileSql = m.translate().compileSQL;
1502
1502
  expect(compileSql).toBeDefined();
1503
1503
  if (compileSql) {
1504
1504
  m.update({
1505
- "compileSQL": { [compileSql.name]: getSelectOneStruct(compileSql) }
1505
+ compileSQL: { [compileSql.name]: getSelectOneStruct(compileSql) },
1506
1506
  });
1507
1507
  expect(m).modelCompiled();
1508
1508
  const s = m.sqlBlocks[0];
1509
1509
  expect(s.location).isLocationIn(source.locations[0], source.code);
1510
1510
  }
1511
1511
  });
1512
- test("location of renamed field", () => {
1512
+ test('location of renamed field', () => {
1513
1513
  const source = (0, test_translator_1.markSource) `
1514
1514
  explore: na is a {
1515
- rename: ${"bbool is abool"}
1515
+ rename: ${'bbool is abool'}
1516
1516
  }
1517
1517
  `;
1518
1518
  const m = new BetaModel(source.code);
1519
1519
  expect(m).modelCompiled();
1520
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1521
- const bbool = (0, test_translator_1.getField)(na, "bbool");
1520
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1521
+ const bbool = (0, test_translator_1.getField)(na, 'bbool');
1522
1522
  expect(bbool.location).toMatchObject(source.locations[0]);
1523
1523
  });
1524
- test("location of join on", () => {
1524
+ test('location of join on', () => {
1525
1525
  const source = (0, test_translator_1.markSource) `
1526
1526
  explore: na is a {
1527
- join_one: ${"x is a { primary_key: abool } on abool"}
1527
+ join_one: ${'x is a { primary_key: abool } on abool'}
1528
1528
  }
1529
1529
  `;
1530
1530
  const m = new BetaModel(source.code);
1531
1531
  expect(m).modelCompiled();
1532
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1533
- const x = (0, test_translator_1.getField)(na, "x");
1532
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1533
+ const x = (0, test_translator_1.getField)(na, 'x');
1534
1534
  expect(x.location).toMatchObject(source.locations[0]);
1535
1535
  });
1536
- test("location of join with", () => {
1536
+ test('location of join with', () => {
1537
1537
  const source = (0, test_translator_1.markSource) `
1538
1538
  explore: na is a {
1539
- join_one: ${"x is a { primary_key: astr } with astr"}
1539
+ join_one: ${'x is a { primary_key: astr } with astr'}
1540
1540
  }
1541
1541
  `;
1542
1542
  const m = new BetaModel(source.code);
1543
1543
  expect(m).modelCompiled();
1544
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1545
- const x = (0, test_translator_1.getField)(na, "x");
1544
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1545
+ const x = (0, test_translator_1.getField)(na, 'x');
1546
1546
  expect(x.location).toMatchObject(source.locations[0]);
1547
1547
  });
1548
- test("location of field in join", () => {
1548
+ test('location of field in join', () => {
1549
1549
  const source = (0, test_translator_1.markSource) `
1550
1550
  explore: na is a {
1551
1551
  join_one: x is a {
1552
1552
  primary_key: abool
1553
- dimension: ${"y is 1"}
1553
+ dimension: ${'y is 1'}
1554
1554
  } on abool
1555
1555
  }
1556
1556
  `;
1557
1557
  const m = new BetaModel(source.code);
1558
1558
  expect(m).modelCompiled();
1559
- const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
1560
- const x = (0, test_translator_1.getJoinField)(na, "x");
1561
- const y = (0, test_translator_1.getField)(x, "y");
1559
+ const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
1560
+ const x = (0, test_translator_1.getJoinField)(na, 'x');
1561
+ const y = (0, test_translator_1.getField)(x, 'y');
1562
1562
  expect(y.location).toMatchObject(source.locations[0]);
1563
1563
  });
1564
1564
  // Since """ strings are not single tokens, I don't know how to do this.
@@ -1569,67 +1569,67 @@ describe("source locations", () => {
1569
1569
  // const errList = m.errors().errors;
1570
1570
  // expect(errList[0].at?.range.end).toEqual({ line: 2, character: 11 });
1571
1571
  // });
1572
- test("undefined query location", badModel((0, test_translator_1.markSource) `query: ${"-> xyz"}`, "Reference to undefined query 'xyz'"));
1573
- test("undefined field reference", badModel((0, test_translator_1.markSource) `query: a -> { group_by: ${"xyz"} }`, "'xyz' is not defined"));
1574
- test("bad query", badModel((0, test_translator_1.markSource) `query: a -> { group_by: astr; ${"project: *"} }`, "project: not legal in grouping query"));
1575
- test.skip("undefined field reference in top", badModel((0, test_translator_1.markSource) `query: a -> { group_by: one is 1; top: 1 by ${"xyz"} }`, "'xyz' is not defined"));
1576
- test.skip("undefined field reference in order_by", badModel((0, test_translator_1.markSource) `query: a -> { group_by: one is 1; order_by: ${"xyz"} }`, "'xyz' is not defined"));
1572
+ test('undefined query location', badModel((0, test_translator_1.markSource) `query: ${'-> xyz'}`, "Reference to undefined query 'xyz'"));
1573
+ test('undefined field reference', badModel((0, test_translator_1.markSource) `query: a -> { group_by: ${'xyz'} }`, "'xyz' is not defined"));
1574
+ test('bad query', badModel((0, test_translator_1.markSource) `query: a -> { group_by: astr; ${'project: *'} }`, 'project: not legal in grouping query'));
1575
+ test.skip('undefined field reference in top', badModel((0, test_translator_1.markSource) `query: a -> { group_by: one is 1; top: 1 by ${'xyz'} }`, "'xyz' is not defined"));
1576
+ test.skip('undefined field reference in order_by', badModel((0, test_translator_1.markSource) `query: a -> { group_by: one is 1; order_by: ${'xyz'} }`, "'xyz' is not defined"));
1577
1577
  });
1578
- describe("source references", () => {
1579
- test("reference to explore", () => {
1578
+ describe('source references', () => {
1579
+ test('reference to explore', () => {
1580
1580
  const source = (0, test_translator_1.markSource) `
1581
- explore: ${"na is a"}
1582
- query: ${"na"} -> { project: * }
1581
+ explore: ${'na is a'}
1582
+ query: ${'na'} -> { project: * }
1583
1583
  `;
1584
1584
  const m = new BetaModel(source.code);
1585
1585
  expect(m).modelCompiled();
1586
1586
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1587
- "location": source.locations[1],
1588
- "type": "exploreReference",
1589
- "text": "na",
1590
- "definition": {
1591
- "location": source.locations[0]
1592
- }
1587
+ location: source.locations[1],
1588
+ type: 'exploreReference',
1589
+ text: 'na',
1590
+ definition: {
1591
+ location: source.locations[0],
1592
+ },
1593
1593
  });
1594
1594
  });
1595
- test("reference to query in query", () => {
1595
+ test('reference to query in query', () => {
1596
1596
  const source = (0, test_translator_1.markSource) `
1597
1597
  explore: t is a {
1598
- query: ${"q is { project: * }"}
1598
+ query: ${'q is { project: * }'}
1599
1599
  }
1600
- query: t -> ${"q"}
1600
+ query: t -> ${'q'}
1601
1601
  `;
1602
1602
  const m = new BetaModel(source.code);
1603
1603
  expect(m).modelCompiled();
1604
1604
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1605
- "location": source.locations[1],
1606
- "type": "fieldReference",
1607
- "text": "q",
1608
- "definition": {
1609
- "location": source.locations[0]
1610
- }
1605
+ location: source.locations[1],
1606
+ type: 'fieldReference',
1607
+ text: 'q',
1608
+ definition: {
1609
+ location: source.locations[0],
1610
+ },
1611
1611
  });
1612
1612
  });
1613
- test("reference to query in query (version 2)", () => {
1613
+ test('reference to query in query (version 2)', () => {
1614
1614
  const source = (0, test_translator_1.markSource) `
1615
- explore: na is a { query: ${"x is { group_by: y is 1 }"} }
1616
- query: na -> ${"x"}
1615
+ explore: na is a { query: ${'x is { group_by: y is 1 }'} }
1616
+ query: na -> ${'x'}
1617
1617
  `;
1618
1618
  const m = new BetaModel(source.code);
1619
1619
  expect(m).modelCompiled();
1620
1620
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1621
- "location": source.locations[1],
1622
- "type": "fieldReference",
1623
- "text": "x",
1624
- "definition": {
1625
- "location": source.locations[0]
1626
- }
1621
+ location: source.locations[1],
1622
+ type: 'fieldReference',
1623
+ text: 'x',
1624
+ definition: {
1625
+ location: source.locations[0],
1626
+ },
1627
1627
  });
1628
1628
  });
1629
- test("reference to sql block", () => {
1629
+ test('reference to sql block', () => {
1630
1630
  const source = (0, test_translator_1.markSource) `
1631
- ${`sql: s is {select:"""SELECT 1 as one"""}`}
1632
- explore: na is from_sql(${"s"})
1631
+ ${'sql: s is {select:"""SELECT 1 as one"""}'}
1632
+ explore: na is from_sql(${'s'})
1633
1633
  `;
1634
1634
  const m = new BetaModel(source.code);
1635
1635
  expect(m).modelParsed();
@@ -1637,436 +1637,436 @@ describe("source references", () => {
1637
1637
  expect(compileSql).toBeDefined();
1638
1638
  if (compileSql) {
1639
1639
  m.update({
1640
- "compileSQL": { [compileSql.name]: getSelectOneStruct(compileSql) }
1640
+ compileSQL: { [compileSql.name]: getSelectOneStruct(compileSql) },
1641
1641
  });
1642
1642
  expect(m).modelCompiled();
1643
1643
  const ref = m.referenceAt(pos(source.locations[1]));
1644
1644
  expect(ref).toMatchObject({
1645
- "location": source.locations[1],
1646
- "type": "sqlBlockReference",
1647
- "text": "s",
1648
- "definition": {
1645
+ location: source.locations[1],
1646
+ type: 'sqlBlockReference',
1647
+ text: 's',
1648
+ definition: {
1649
1649
  ...getSelectOneStruct(compileSql),
1650
- "location": source.locations[0]
1651
- }
1650
+ location: source.locations[0],
1651
+ },
1652
1652
  });
1653
1653
  }
1654
1654
  });
1655
- test("reference to query in from", () => {
1655
+ test('reference to query in from', () => {
1656
1656
  const source = (0, test_translator_1.markSource) `
1657
- query: ${"q is a -> { project: * }"}
1658
- explore: na is from(-> ${"q"})
1657
+ query: ${'q is a -> { project: * }'}
1658
+ explore: na is from(-> ${'q'})
1659
1659
  `;
1660
1660
  const m = new BetaModel(source.code);
1661
1661
  expect(m).modelCompiled();
1662
1662
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1663
- "location": source.locations[1],
1664
- "type": "queryReference",
1665
- "text": "q",
1666
- "definition": {
1667
- "location": source.locations[0]
1668
- }
1663
+ location: source.locations[1],
1664
+ type: 'queryReference',
1665
+ text: 'q',
1666
+ definition: {
1667
+ location: source.locations[0],
1668
+ },
1669
1669
  });
1670
1670
  });
1671
- test("reference to query in query head", () => {
1671
+ test('reference to query in query head', () => {
1672
1672
  const source = (0, test_translator_1.markSource) `
1673
- query: ${"q is a -> { project: * }"}
1674
- query: q2 is -> ${"q"} -> { project: * }
1673
+ query: ${'q is a -> { project: * }'}
1674
+ query: q2 is -> ${'q'} -> { project: * }
1675
1675
  `;
1676
1676
  const m = new BetaModel(source.code);
1677
1677
  expect(m).modelCompiled();
1678
1678
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1679
- "location": source.locations[1],
1680
- "type": "queryReference",
1681
- "text": "q",
1682
- "definition": {
1683
- "location": source.locations[0]
1684
- }
1679
+ location: source.locations[1],
1680
+ type: 'queryReference',
1681
+ text: 'q',
1682
+ definition: {
1683
+ location: source.locations[0],
1684
+ },
1685
1685
  });
1686
1686
  });
1687
- test("reference to query in refined query", () => {
1687
+ test('reference to query in refined query', () => {
1688
1688
  const source = (0, test_translator_1.markSource) `
1689
- query: ${"q is a -> { project: * }"}
1690
- query: q2 is -> ${"q"} { limit: 10 }
1689
+ query: ${'q is a -> { project: * }'}
1690
+ query: q2 is -> ${'q'} { limit: 10 }
1691
1691
  `;
1692
1692
  const m = new BetaModel(source.code);
1693
1693
  expect(m).modelCompiled();
1694
1694
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1695
- "location": source.locations[1],
1696
- "type": "queryReference",
1697
- "text": "q",
1698
- "definition": {
1699
- "location": source.locations[0]
1700
- }
1695
+ location: source.locations[1],
1696
+ type: 'queryReference',
1697
+ text: 'q',
1698
+ definition: {
1699
+ location: source.locations[0],
1700
+ },
1701
1701
  });
1702
1702
  });
1703
- test("reference to field in expression", () => {
1703
+ test('reference to field in expression', () => {
1704
1704
  const source = (0, test_translator_1.markSource) `
1705
1705
  explore: na is ${"table('aTable')"}
1706
- query: na -> { project: bbool is not ${"abool"} }
1706
+ query: na -> { project: bbool is not ${'abool'} }
1707
1707
  `;
1708
1708
  const m = new BetaModel(source.code);
1709
1709
  expect(m).modelCompiled();
1710
1710
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1711
- "location": source.locations[1],
1712
- "type": "fieldReference",
1713
- "text": "abool",
1714
- "definition": {
1715
- "location": source.locations[0]
1716
- }
1711
+ location: source.locations[1],
1712
+ type: 'fieldReference',
1713
+ text: 'abool',
1714
+ definition: {
1715
+ location: source.locations[0],
1716
+ },
1717
1717
  });
1718
1718
  });
1719
- test("reference to quoted field in expression", () => {
1719
+ test('reference to quoted field in expression', () => {
1720
1720
  const source = (0, test_translator_1.markSource) `
1721
1721
  explore: na is a {
1722
1722
  dimension: ${"`name` is 'name'"}
1723
1723
  }
1724
- query: na -> { project: ${"`name`"} }
1724
+ query: na -> { project: ${'`name`'} }
1725
1725
  `;
1726
1726
  const m = new BetaModel(source.code);
1727
1727
  expect(m).modelCompiled();
1728
1728
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1729
- "location": source.locations[1],
1730
- "type": "fieldReference",
1731
- "text": "name",
1732
- "definition": {
1733
- "location": source.locations[0]
1734
- }
1729
+ location: source.locations[1],
1730
+ type: 'fieldReference',
1731
+ text: 'name',
1732
+ definition: {
1733
+ location: source.locations[0],
1734
+ },
1735
1735
  });
1736
1736
  });
1737
- test("reference to joined field in expression", () => {
1737
+ test('reference to joined field in expression', () => {
1738
1738
  const source = (0, test_translator_1.markSource) `
1739
1739
  explore: na is a {
1740
1740
  join_one: self is ${"table('aTable')"}
1741
1741
  on astr = self.astr
1742
1742
  }
1743
- query: na -> { project: bstr is self.${"astr"} }
1743
+ query: na -> { project: bstr is self.${'astr'} }
1744
1744
  `;
1745
1745
  const m = new BetaModel(source.code);
1746
1746
  expect(m).modelCompiled();
1747
1747
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1748
- "location": source.locations[1],
1749
- "type": "fieldReference",
1750
- "text": "astr",
1751
- "definition": {
1752
- "location": source.locations[0]
1753
- }
1748
+ location: source.locations[1],
1749
+ type: 'fieldReference',
1750
+ text: 'astr',
1751
+ definition: {
1752
+ location: source.locations[0],
1753
+ },
1754
1754
  });
1755
1755
  });
1756
- test("reference to joined join in expression", () => {
1756
+ test('reference to joined join in expression', () => {
1757
1757
  const source = (0, test_translator_1.markSource) `
1758
1758
  explore: na is a {
1759
- join_one: ${"self is a on astr = self.astr"}
1759
+ join_one: ${'self is a on astr = self.astr'}
1760
1760
  }
1761
- query: na -> { project: bstr is ${"self"}.astr }
1761
+ query: na -> { project: bstr is ${'self'}.astr }
1762
1762
  `;
1763
1763
  const m = new BetaModel(source.code);
1764
1764
  expect(m).modelCompiled();
1765
1765
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1766
- "location": source.locations[1],
1767
- "type": "joinReference",
1768
- "text": "self",
1769
- "definition": {
1770
- "location": source.locations[0]
1771
- }
1766
+ location: source.locations[1],
1767
+ type: 'joinReference',
1768
+ text: 'self',
1769
+ definition: {
1770
+ location: source.locations[0],
1771
+ },
1772
1772
  });
1773
1773
  });
1774
- test("reference to field not in expression (group by)", () => {
1774
+ test('reference to field not in expression (group by)', () => {
1775
1775
  const source = (0, test_translator_1.markSource) `
1776
- query: ${"table('aTable')"} -> { group_by: ${"abool"} }
1776
+ query: ${"table('aTable')"} -> { group_by: ${'abool'} }
1777
1777
  `;
1778
1778
  const m = new BetaModel(source.code);
1779
1779
  expect(m).modelCompiled();
1780
1780
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1781
- "location": source.locations[1],
1782
- "type": "fieldReference",
1783
- "text": "abool",
1784
- "definition": {
1785
- "location": source.locations[0]
1786
- }
1781
+ location: source.locations[1],
1782
+ type: 'fieldReference',
1783
+ text: 'abool',
1784
+ definition: {
1785
+ location: source.locations[0],
1786
+ },
1787
1787
  });
1788
1788
  });
1789
- test("reference to field not in expression (project)", () => {
1789
+ test('reference to field not in expression (project)', () => {
1790
1790
  const source = (0, test_translator_1.markSource) `
1791
1791
  explore: na is ${"table('aTable')"}
1792
- query: na -> { project: ${"abool"} }
1792
+ query: na -> { project: ${'abool'} }
1793
1793
  `;
1794
1794
  const m = new BetaModel(source.code);
1795
1795
  expect(m).modelCompiled();
1796
1796
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1797
- "location": source.locations[1],
1798
- "type": "fieldReference",
1799
- "text": "abool",
1800
- "definition": {
1801
- "location": source.locations[0]
1802
- }
1797
+ location: source.locations[1],
1798
+ type: 'fieldReference',
1799
+ text: 'abool',
1800
+ definition: {
1801
+ location: source.locations[0],
1802
+ },
1803
1803
  });
1804
1804
  });
1805
- test.skip("reference to field in order by", () => {
1805
+ test.skip('reference to field in order by', () => {
1806
1806
  const source = (0, test_translator_1.markSource) `
1807
1807
  query: ${"table('aTable')"} -> {
1808
1808
  group_by: abool
1809
- order_by: ${"abool"}
1809
+ order_by: ${'abool'}
1810
1810
  }
1811
1811
  `;
1812
1812
  const m = new BetaModel(source.code);
1813
1813
  expect(m).modelCompiled();
1814
1814
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1815
- "location": source.locations[1],
1816
- "type": "fieldReference",
1817
- "text": "abool",
1818
- "definition": {
1819
- "location": source.locations[0]
1820
- }
1815
+ location: source.locations[1],
1816
+ type: 'fieldReference',
1817
+ text: 'abool',
1818
+ definition: {
1819
+ location: source.locations[0],
1820
+ },
1821
1821
  });
1822
1822
  });
1823
- test.skip("reference to field in order by (output space)", () => {
1823
+ test.skip('reference to field in order by (output space)', () => {
1824
1824
  const source = (0, test_translator_1.markSource) `
1825
1825
  query: a -> {
1826
- group_by: ${"one is 1"}
1827
- order_by: ${"one"}
1826
+ group_by: ${'one is 1'}
1827
+ order_by: ${'one'}
1828
1828
  }
1829
1829
  `;
1830
1830
  const m = new BetaModel(source.code);
1831
1831
  expect(m).modelCompiled();
1832
1832
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1833
- "location": source.locations[1],
1834
- "type": "fieldReference",
1835
- "text": "abool",
1836
- "definition": {
1837
- "location": source.locations[0]
1838
- }
1833
+ location: source.locations[1],
1834
+ type: 'fieldReference',
1835
+ text: 'abool',
1836
+ definition: {
1837
+ location: source.locations[0],
1838
+ },
1839
1839
  });
1840
1840
  });
1841
- test("reference to field in aggregate", () => {
1841
+ test('reference to field in aggregate', () => {
1842
1842
  const source = (0, test_translator_1.markSource) `
1843
- query: a { measure: ${"c is count()"} } -> {
1843
+ query: a { measure: ${'c is count()'} } -> {
1844
1844
  group_by: abool
1845
- aggregate: ${"c"}
1845
+ aggregate: ${'c'}
1846
1846
  }
1847
1847
  `;
1848
1848
  const m = new BetaModel(source.code);
1849
1849
  expect(m).modelCompiled();
1850
1850
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1851
- "location": source.locations[1],
1852
- "type": "fieldReference",
1853
- "text": "c",
1854
- "definition": {
1855
- "location": source.locations[0]
1856
- }
1851
+ location: source.locations[1],
1852
+ type: 'fieldReference',
1853
+ text: 'c',
1854
+ definition: {
1855
+ location: source.locations[0],
1856
+ },
1857
1857
  });
1858
1858
  });
1859
- test("reference to field in measure", () => {
1859
+ test('reference to field in measure', () => {
1860
1860
  const source = (0, test_translator_1.markSource) `
1861
1861
  explore: e is a {
1862
- measure: ${"c is count()"}
1863
- measure: c2 is ${"c"}
1862
+ measure: ${'c is count()'}
1863
+ measure: c2 is ${'c'}
1864
1864
  }
1865
1865
  `;
1866
1866
  const m = new BetaModel(source.code);
1867
1867
  expect(m).modelCompiled();
1868
1868
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1869
- "location": source.locations[1],
1870
- "type": "fieldReference",
1871
- "text": "c",
1872
- "definition": {
1873
- "location": source.locations[0]
1874
- }
1869
+ location: source.locations[1],
1870
+ type: 'fieldReference',
1871
+ text: 'c',
1872
+ definition: {
1873
+ location: source.locations[0],
1874
+ },
1875
1875
  });
1876
1876
  });
1877
- test.skip("reference to field in top", () => {
1877
+ test.skip('reference to field in top', () => {
1878
1878
  const source = (0, test_translator_1.markSource) `
1879
1879
  query: ${"table('aTable')"} -> {
1880
1880
  group_by: abool
1881
- top: 10 by ${"abool"}
1881
+ top: 10 by ${'abool'}
1882
1882
  }
1883
1883
  `;
1884
1884
  const m = new BetaModel(source.code);
1885
1885
  expect(m).modelCompiled();
1886
1886
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1887
- "location": source.locations[1],
1888
- "type": "fieldReference",
1889
- "text": "abool",
1890
- "definition": {
1891
- "location": source.locations[0]
1892
- }
1887
+ location: source.locations[1],
1888
+ type: 'fieldReference',
1889
+ text: 'abool',
1890
+ definition: {
1891
+ location: source.locations[0],
1892
+ },
1893
1893
  });
1894
1894
  });
1895
- test.skip("reference to field in top (output space)", () => {
1895
+ test.skip('reference to field in top (output space)', () => {
1896
1896
  const source = (0, test_translator_1.markSource) `
1897
1897
  query: a -> {
1898
- group_by: ${"one is 1"}
1899
- top: 10 by ${"one"}
1898
+ group_by: ${'one is 1'}
1899
+ top: 10 by ${'one'}
1900
1900
  }
1901
1901
  `;
1902
1902
  const m = new BetaModel(source.code);
1903
1903
  expect(m).modelCompiled();
1904
1904
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1905
- "location": source.locations[1],
1906
- "type": "fieldReference",
1907
- "text": "abool",
1908
- "definition": {
1909
- "location": source.locations[0]
1910
- }
1905
+ location: source.locations[1],
1906
+ type: 'fieldReference',
1907
+ text: 'abool',
1908
+ definition: {
1909
+ location: source.locations[0],
1910
+ },
1911
1911
  });
1912
1912
  });
1913
- test("reference to field in filter", () => {
1913
+ test('reference to field in filter', () => {
1914
1914
  const source = (0, test_translator_1.markSource) `
1915
1915
  query: ${"table('aTable')"} -> {
1916
1916
  group_by: abool
1917
- where: ${"abool"}
1917
+ where: ${'abool'}
1918
1918
  }
1919
1919
  `;
1920
1920
  const m = new BetaModel(source.code);
1921
1921
  expect(m).modelCompiled();
1922
1922
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1923
- "location": source.locations[1],
1924
- "type": "fieldReference",
1925
- "text": "abool",
1926
- "definition": {
1927
- "location": source.locations[0]
1928
- }
1923
+ location: source.locations[1],
1924
+ type: 'fieldReference',
1925
+ text: 'abool',
1926
+ definition: {
1927
+ location: source.locations[0],
1928
+ },
1929
1929
  });
1930
1930
  });
1931
- test("reference to field in aggregate source", () => {
1931
+ test('reference to field in aggregate source', () => {
1932
1932
  const source = (0, test_translator_1.markSource) `
1933
1933
  explore: na is ${"table('aTable')"}
1934
- query: na -> { aggregate: ai_sum is ${"ai"}.sum() }
1934
+ query: na -> { aggregate: ai_sum is ${'ai'}.sum() }
1935
1935
  `;
1936
1936
  const m = new BetaModel(source.code);
1937
1937
  expect(m).modelCompiled();
1938
1938
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1939
- "location": source.locations[1],
1940
- "type": "fieldReference",
1941
- "text": "ai",
1942
- "definition": {
1943
- "location": source.locations[0]
1944
- }
1939
+ location: source.locations[1],
1940
+ type: 'fieldReference',
1941
+ text: 'ai',
1942
+ definition: {
1943
+ location: source.locations[0],
1944
+ },
1945
1945
  });
1946
1946
  });
1947
1947
  function pos(location) {
1948
1948
  return location.range.start;
1949
1949
  }
1950
- test("reference to join in aggregate source", () => {
1950
+ test('reference to join in aggregate source', () => {
1951
1951
  const source = (0, test_translator_1.markSource) `
1952
1952
  explore: na is a {
1953
- join_one: ${"self is a on astr = self.astr"}
1953
+ join_one: ${'self is a on astr = self.astr'}
1954
1954
  }
1955
- query: na -> { aggregate: ai_sum is ${"self"}.sum(self.ai) }
1955
+ query: na -> { aggregate: ai_sum is ${'self'}.sum(self.ai) }
1956
1956
  `;
1957
1957
  const m = new BetaModel(source.code);
1958
1958
  expect(m).modelCompiled();
1959
1959
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1960
- "location": source.locations[1],
1961
- "type": "joinReference",
1962
- "text": "self",
1963
- "definition": {
1964
- "location": source.locations[0]
1965
- }
1960
+ location: source.locations[1],
1961
+ type: 'joinReference',
1962
+ text: 'self',
1963
+ definition: {
1964
+ location: source.locations[0],
1965
+ },
1966
1966
  });
1967
1967
  });
1968
- test("reference to join in aggregate in expr", () => {
1968
+ test('reference to join in aggregate in expr', () => {
1969
1969
  const source = (0, test_translator_1.markSource) `
1970
1970
  explore: na is a {
1971
- join_one: ${"self is a on astr = self.astr"}
1971
+ join_one: ${'self is a on astr = self.astr'}
1972
1972
  }
1973
- query: na -> { aggregate: ai_sum is self.sum(${"self"}.ai) }
1973
+ query: na -> { aggregate: ai_sum is self.sum(${'self'}.ai) }
1974
1974
  `;
1975
1975
  const m = new BetaModel(source.code);
1976
1976
  expect(m).modelCompiled();
1977
1977
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1978
- "location": source.locations[1],
1979
- "type": "joinReference",
1980
- "text": "self",
1981
- "definition": {
1982
- "location": source.locations[0]
1983
- }
1978
+ location: source.locations[1],
1979
+ type: 'joinReference',
1980
+ text: 'self',
1981
+ definition: {
1982
+ location: source.locations[0],
1983
+ },
1984
1984
  });
1985
1985
  });
1986
- test("reference to explore in join", () => {
1986
+ test('reference to explore in join', () => {
1987
1987
  const source = (0, test_translator_1.markSource) `
1988
- explore: ${"exp1 is a"}
1988
+ explore: ${'exp1 is a'}
1989
1989
  explore: exp2 is a {
1990
- join_one: ${"exp1"} on astr = exp1.astr
1990
+ join_one: ${'exp1'} on astr = exp1.astr
1991
1991
  }
1992
1992
  `;
1993
1993
  const m = new BetaModel(source.code);
1994
1994
  expect(m).modelCompiled();
1995
1995
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
1996
- "location": source.locations[1],
1997
- "type": "exploreReference",
1998
- "text": "exp1",
1999
- "definition": {
2000
- "location": source.locations[0]
2001
- }
1996
+ location: source.locations[1],
1997
+ type: 'exploreReference',
1998
+ text: 'exp1',
1999
+ definition: {
2000
+ location: source.locations[0],
2001
+ },
2002
2002
  });
2003
2003
  });
2004
- test("reference to field in aggregate (in expr)", () => {
2004
+ test('reference to field in aggregate (in expr)', () => {
2005
2005
  const source = (0, test_translator_1.markSource) `
2006
2006
  explore: na is ${"table('aTable')"}
2007
- query: na -> { aggregate: ai_sum is sum(${"ai"}) }
2007
+ query: na -> { aggregate: ai_sum is sum(${'ai'}) }
2008
2008
  `;
2009
2009
  const m = new BetaModel(source.code);
2010
2010
  expect(m).modelCompiled();
2011
2011
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
2012
- "location": source.locations[1],
2013
- "type": "fieldReference",
2014
- "text": "ai",
2015
- "definition": {
2016
- "location": source.locations[0]
2017
- }
2012
+ location: source.locations[1],
2013
+ type: 'fieldReference',
2014
+ text: 'ai',
2015
+ definition: {
2016
+ location: source.locations[0],
2017
+ },
2018
2018
  });
2019
2019
  });
2020
- test("reference to field in rename", () => {
2020
+ test('reference to field in rename', () => {
2021
2021
  const source = (0, test_translator_1.markSource) `
2022
2022
  explore: na is ${"table('aTable')"} {
2023
- rename: bbool is ${"abool"}
2023
+ rename: bbool is ${'abool'}
2024
2024
  }
2025
2025
  `;
2026
2026
  const m = new BetaModel(source.code);
2027
2027
  expect(m).modelCompiled();
2028
2028
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
2029
- "location": source.locations[1],
2030
- "type": "fieldReference",
2031
- "text": "abool",
2032
- "definition": {
2033
- "location": source.locations[0]
2034
- }
2029
+ location: source.locations[1],
2030
+ type: 'fieldReference',
2031
+ text: 'abool',
2032
+ definition: {
2033
+ location: source.locations[0],
2034
+ },
2035
2035
  });
2036
2036
  });
2037
- test("reference to field in join with", () => {
2037
+ test('reference to field in join with', () => {
2038
2038
  const source = (0, test_translator_1.markSource) `
2039
2039
  explore: exp1 is a { primary_key: astr }
2040
2040
  explore: exp2 is ${"table('aTable')"} {
2041
- join_one: exp1 with ${"astr"}
2041
+ join_one: exp1 with ${'astr'}
2042
2042
  }
2043
2043
  `;
2044
2044
  const m = new BetaModel(source.code);
2045
2045
  expect(m).modelCompiled();
2046
2046
  expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
2047
- "location": source.locations[1],
2048
- "type": "fieldReference",
2049
- "text": "astr",
2050
- "definition": {
2051
- "location": source.locations[0]
2052
- }
2047
+ location: source.locations[1],
2048
+ type: 'fieldReference',
2049
+ text: 'astr',
2050
+ definition: {
2051
+ location: source.locations[0],
2052
+ },
2053
2053
  });
2054
2054
  });
2055
2055
  });
2056
- describe("translation need error locations", () => {
2057
- test("import error location", () => {
2056
+ describe('translation need error locations', () => {
2057
+ test('import error location', () => {
2058
2058
  const source = (0, test_translator_1.markSource) `import ${'"badfile"'}`;
2059
2059
  const m = new BetaModel(source.code);
2060
2060
  const result = m.translate();
2061
2061
  m.update({
2062
- "errors": { "urls": { [(result.urls || [])[0]]: "Bad file!" } }
2062
+ errors: { urls: { [(result.urls || [])[0]]: 'Bad file!' } },
2063
2063
  });
2064
2064
  expect(m).not.modelParsed();
2065
2065
  const errList = m.errors().errors;
2066
2066
  expect(errList[0].at).isLocationIn(source.locations[0], source.code);
2067
2067
  return undefined;
2068
2068
  });
2069
- test("sql struct error location", () => {
2069
+ test('sql struct error location', () => {
2070
2070
  const source = (0, test_translator_1.markSource) `
2071
2071
  sql: bad_sql is {select: ${'"""BAD_SQL"""'}}
2072
2072
  query: from_sql(bad_sql) -> { project: * }
@@ -2076,22 +2076,22 @@ describe("translation need error locations", () => {
2076
2076
  const req = m.translate().compileSQL;
2077
2077
  expect(req).toBeDefined();
2078
2078
  if (req) {
2079
- m.update({ "errors": { "compileSQL": { [req.name]: "Bad SQL!" } } });
2079
+ m.update({ errors: { compileSQL: { [req.name]: 'Bad SQL!' } } });
2080
2080
  }
2081
2081
  expect(m).not.modelCompiled();
2082
2082
  const errList = m.errors().errors;
2083
2083
  expect(errList[0].at).isLocationIn(source.locations[0], source.code);
2084
2084
  });
2085
- test("table struct error location", () => {
2085
+ test('table struct error location', () => {
2086
2086
  const source = (0, test_translator_1.markSource) `
2087
2087
  explore: bad_explore is ${"table('malloy-data.bad.table')"}
2088
2088
  `;
2089
2089
  const m = new BetaModel(source.code);
2090
2090
  const result = m.translate();
2091
2091
  m.update({
2092
- "errors": {
2093
- "tables": { [(result.tables || [])[0]]: "Bad table!" }
2094
- }
2092
+ errors: {
2093
+ tables: { [(result.tables || [])[0]]: 'Bad table!' },
2094
+ },
2095
2095
  });
2096
2096
  expect(m).not.modelParsed();
2097
2097
  const errList = m.errors().errors;
@@ -2099,8 +2099,8 @@ describe("translation need error locations", () => {
2099
2099
  return undefined;
2100
2100
  });
2101
2101
  });
2102
- describe("pipeline comprehension", () => {
2103
- test("second query gets namespace from first", modelOK(`
2102
+ describe('pipeline comprehension', () => {
2103
+ test('second query gets namespace from first', modelOK(`
2104
2104
  explore: aq is a {
2105
2105
  query: t1 is {
2106
2106
  group_by: t1int is ai, t1str is astr
@@ -2114,11 +2114,11 @@ describe("pipeline comprehension", () => {
2114
2114
  query: t1 is {
2115
2115
  group_by: t1int is ai, t1str is astr
2116
2116
  } -> {
2117
- project: ${"ai"}
2117
+ project: ${'ai'}
2118
2118
  }
2119
2119
  }
2120
2120
  `, "'ai' is not defined"));
2121
- test("new query can append ops to existing query", modelOK(`
2121
+ test('new query can append ops to existing query', modelOK(`
2122
2122
  explore: aq is a {
2123
2123
  query: t0 is {
2124
2124
  group_by: t1int is ai, t1str is astr
@@ -2128,7 +2128,7 @@ describe("pipeline comprehension", () => {
2128
2128
  }
2129
2129
  }
2130
2130
  `));
2131
- test("new query can refine and append to exisiting query", modelOK(`
2131
+ test('new query can refine and append to exisiting query', modelOK(`
2132
2132
  explore: aq is table('aTable') {
2133
2133
  query: by_region is { group_by: astr }
2134
2134
  query: by_region2 is by_region {
@@ -2138,20 +2138,20 @@ describe("pipeline comprehension", () => {
2138
2138
  }
2139
2139
  }
2140
2140
  `));
2141
- test("reference to a query can include a refinement", modelOK(`
2141
+ test('reference to a query can include a refinement', modelOK(`
2142
2142
  query: ab -> {
2143
2143
  group_by: ai
2144
2144
  nest: aturtle { limit: 1 }
2145
2145
  }
2146
2146
  `));
2147
- test("Querying an explore based on a query", modelOK(`
2147
+ test('Querying an explore based on a query', modelOK(`
2148
2148
  query: q is a -> { group_by: astr; aggregate: strsum is ai.sum() }
2149
2149
  explore: aq is a {
2150
2150
  join_one: aq is from(->q) on astr = aq.astr
2151
2151
  }
2152
2152
  query: aqf is aq -> { project: * }
2153
2153
  `));
2154
- test("new query appends to existing query", () => {
2154
+ test('new query appends to existing query', () => {
2155
2155
  const src = `
2156
2156
  query: s1 is table('malloytest.flights') -> {
2157
2157
  group_by: origin, destination
@@ -2162,13 +2162,13 @@ describe("pipeline comprehension", () => {
2162
2162
  `;
2163
2163
  const m = new BetaModel(src);
2164
2164
  expect(m).modelCompiled();
2165
- const s2 = m.getQuery("s2");
2165
+ const s2 = m.getQuery('s2');
2166
2166
  expect(s2 === null || s2 === void 0 ? void 0 : s2.pipeline.length).toBe(2);
2167
2167
  });
2168
2168
  });
2169
- describe("standard sql function return types", () => {
2170
- test("timestamp_seconds", () => {
2171
- expect("timestamp_seconds(0)").toReturnType("timestamp");
2169
+ describe('standard sql function return types', () => {
2170
+ test('timestamp_seconds', () => {
2171
+ expect('timestamp_seconds(0)').toReturnType('timestamp');
2172
2172
  });
2173
2173
  });
2174
2174
  //# sourceMappingURL=parse.spec.js.map