@malloydata/malloy 0.0.22-dev230126015148 → 0.0.22-dev230202171033

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 (307) hide show
  1. package/dist/lang/ast/ast-main.d.ts +18 -815
  2. package/dist/lang/ast/ast-main.js +106 -3241
  3. package/dist/lang/ast/ast-utils.d.ts +10 -0
  4. package/dist/lang/ast/ast-utils.js +42 -0
  5. package/dist/lang/ast/elements/define-explore.d.ts +17 -0
  6. package/dist/lang/ast/elements/define-explore.js +79 -0
  7. package/dist/lang/ast/elements/define-query.d.ts +14 -0
  8. package/dist/lang/ast/elements/define-query.js +56 -0
  9. package/dist/lang/ast/elements/mallobj.d.ts +12 -0
  10. package/dist/lang/ast/elements/mallobj.js +53 -0
  11. package/dist/lang/ast/elements/pipeline-desc.d.ts +28 -0
  12. package/dist/lang/ast/elements/pipeline-desc.js +102 -0
  13. package/dist/lang/ast/elements/refined-explore.d.ts +15 -0
  14. package/dist/lang/ast/elements/refined-explore.js +121 -0
  15. package/dist/lang/ast/error-factory.d.ts +9 -0
  16. package/dist/lang/ast/error-factory.js +61 -0
  17. package/dist/lang/ast/executors/index-executor.d.ts +18 -0
  18. package/dist/lang/ast/executors/index-executor.js +96 -0
  19. package/dist/lang/ast/executors/project-executor.d.ts +10 -0
  20. package/dist/lang/ast/executors/project-executor.js +68 -0
  21. package/dist/lang/ast/executors/reduce-executor.d.ts +20 -0
  22. package/dist/lang/ast/executors/reduce-executor.js +149 -0
  23. package/dist/lang/ast/explore-properties/field-list-edit.d.ts +8 -0
  24. package/dist/lang/ast/explore-properties/field-list-edit.js +36 -0
  25. package/dist/lang/ast/explore-properties/primary-key.d.ts +7 -0
  26. package/dist/lang/ast/{apply-expr.js → explore-properties/primary-key.js} +9 -8
  27. package/dist/lang/ast/explore-properties/renames.d.ts +11 -0
  28. package/dist/lang/ast/explore-properties/renames.js +43 -0
  29. package/dist/lang/ast/explore-properties/turtles.d.ts +5 -0
  30. package/dist/lang/ast/explore-properties/turtles.js +33 -0
  31. package/dist/lang/ast/expressions/apply.d.ts +8 -0
  32. package/dist/lang/ast/expressions/apply.js +37 -0
  33. package/dist/lang/ast/expressions/binary-boolean.d.ts +12 -0
  34. package/dist/lang/ast/expressions/binary-boolean.js +54 -0
  35. package/dist/lang/ast/expressions/binary-numeric.d.ts +11 -0
  36. package/dist/lang/ast/expressions/binary-numeric.js +42 -0
  37. package/dist/lang/ast/expressions/boolean.d.ts +8 -0
  38. package/dist/lang/ast/expressions/boolean.js +39 -0
  39. package/dist/lang/ast/expressions/constant-sub-expression.d.ts +16 -0
  40. package/dist/lang/ast/expressions/constant-sub-expression.js +98 -0
  41. package/dist/lang/ast/expressions/expr-add-sub.d.ts +4 -0
  42. package/dist/lang/ast/expressions/expr-add-sub.js +34 -0
  43. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +15 -0
  44. package/dist/lang/ast/expressions/expr-aggregate-function.js +99 -0
  45. package/dist/lang/ast/expressions/expr-alternation-tree.d.ts +11 -0
  46. package/dist/lang/ast/expressions/expr-alternation-tree.js +54 -0
  47. package/dist/lang/ast/expressions/expr-asymmetric.d.ts +10 -0
  48. package/dist/lang/ast/expressions/expr-asymmetric.js +27 -0
  49. package/dist/lang/ast/expressions/expr-avg.d.ts +6 -0
  50. package/dist/lang/ast/expressions/expr-avg.js +34 -0
  51. package/dist/lang/ast/expressions/expr-case.d.ts +11 -0
  52. package/dist/lang/ast/expressions/expr-case.js +84 -0
  53. package/dist/lang/ast/expressions/expr-cast.d.ts +13 -0
  54. package/dist/lang/ast/expressions/expr-cast.js +29 -0
  55. package/dist/lang/ast/expressions/expr-compare.d.ts +10 -0
  56. package/dist/lang/ast/expressions/expr-compare.js +48 -0
  57. package/dist/lang/ast/expressions/expr-count-distinct.d.ts +6 -0
  58. package/dist/lang/ast/expressions/expr-count-distinct.js +35 -0
  59. package/dist/lang/ast/expressions/expr-count.d.ts +11 -0
  60. package/dist/lang/ast/expressions/expr-count.js +57 -0
  61. package/dist/lang/ast/expressions/expr-filter.d.ts +12 -0
  62. package/dist/lang/ast/expressions/expr-filter.js +69 -0
  63. package/dist/lang/ast/expressions/expr-func.d.ts +10 -0
  64. package/dist/lang/ast/expressions/expr-func.js +63 -0
  65. package/dist/lang/ast/expressions/expr-granular-time.d.ts +24 -0
  66. package/dist/lang/ast/expressions/expr-granular-time.js +117 -0
  67. package/dist/lang/ast/expressions/expr-id-reference.d.ts +12 -0
  68. package/dist/lang/ast/expressions/expr-id-reference.js +76 -0
  69. package/dist/lang/ast/expressions/expr-logical-op.d.ts +9 -0
  70. package/dist/lang/ast/expressions/expr-logical-op.js +36 -0
  71. package/dist/lang/ast/expressions/expr-max.d.ts +9 -0
  72. package/dist/lang/ast/expressions/expr-max.js +16 -0
  73. package/dist/lang/ast/expressions/expr-min.d.ts +9 -0
  74. package/dist/lang/ast/expressions/expr-min.js +16 -0
  75. package/dist/lang/ast/expressions/expr-minus.d.ts +9 -0
  76. package/dist/lang/ast/expressions/expr-minus.js +48 -0
  77. package/dist/lang/ast/expressions/expr-mul-div.d.ts +4 -0
  78. package/dist/lang/ast/expressions/expr-mul-div.js +34 -0
  79. package/dist/lang/ast/expressions/expr-not.d.ts +10 -0
  80. package/dist/lang/ast/expressions/expr-not.js +49 -0
  81. package/dist/lang/ast/expressions/expr-now.d.ts +7 -0
  82. package/dist/lang/ast/expressions/expr-now.js +46 -0
  83. package/dist/lang/ast/expressions/expr-null.d.ts +6 -0
  84. package/dist/lang/ast/expressions/expr-null.js +41 -0
  85. package/dist/lang/ast/expressions/expr-number.d.ts +10 -0
  86. package/dist/lang/ast/expressions/expr-number.js +42 -0
  87. package/dist/lang/ast/expressions/expr-parens.d.ts +10 -0
  88. package/dist/lang/ast/expressions/expr-parens.js +42 -0
  89. package/dist/lang/ast/expressions/expr-regex.d.ts +8 -0
  90. package/dist/lang/ast/expressions/expr-regex.js +42 -0
  91. package/dist/lang/ast/expressions/expr-string.d.ts +9 -0
  92. package/dist/lang/ast/expressions/expr-string.js +50 -0
  93. package/dist/lang/ast/expressions/expr-sum.d.ts +6 -0
  94. package/dist/lang/ast/expressions/expr-sum.js +12 -0
  95. package/dist/lang/ast/expressions/expr-time-extract.d.ts +13 -0
  96. package/dist/lang/ast/expressions/expr-time-extract.js +117 -0
  97. package/dist/lang/ast/expressions/expr-time.d.ts +11 -0
  98. package/dist/lang/ast/expressions/expr-time.js +62 -0
  99. package/dist/lang/ast/expressions/expr-ungroup.d.ts +14 -0
  100. package/dist/lang/ast/expressions/expr-ungroup.js +83 -0
  101. package/dist/lang/ast/expressions/for-range.d.ts +19 -0
  102. package/dist/lang/ast/expressions/for-range.js +101 -0
  103. package/dist/lang/ast/expressions/granular-literal.d.ts +20 -0
  104. package/dist/lang/ast/expressions/granular-literal.js +148 -0
  105. package/dist/lang/ast/expressions/partial-compare.d.ts +14 -0
  106. package/dist/lang/ast/expressions/partial-compare.js +50 -0
  107. package/dist/lang/ast/expressions/pick-when.d.ts +19 -0
  108. package/dist/lang/ast/expressions/pick-when.js +156 -0
  109. package/dist/lang/ast/expressions/range.d.ts +12 -0
  110. package/dist/lang/ast/expressions/range.js +80 -0
  111. package/dist/lang/ast/expressions/time-frame.d.ts +7 -0
  112. package/dist/lang/ast/expressions/time-frame.js +40 -0
  113. package/dist/lang/ast/expressions/top-by.d.ts +10 -0
  114. package/dist/lang/ast/expressions/top-by.js +51 -0
  115. package/dist/lang/ast/expressions/unary.d.ts +5 -0
  116. package/dist/lang/ast/expressions/unary.js +34 -0
  117. package/dist/lang/ast/expressions/utils.d.ts +15 -0
  118. package/dist/lang/ast/expressions/utils.js +106 -0
  119. package/dist/lang/ast/expressions/when-clause.d.ts +10 -0
  120. package/dist/lang/ast/expressions/when-clause.js +17 -0
  121. package/dist/lang/ast/fragtype-utils.d.ts +39 -0
  122. package/dist/lang/ast/fragtype-utils.js +100 -0
  123. package/dist/lang/ast/import-elements/import-statement.d.ts +9 -0
  124. package/dist/lang/ast/import-elements/import-statement.js +78 -0
  125. package/dist/lang/ast/index.d.ts +94 -3
  126. package/dist/lang/ast/index.js +94 -3
  127. package/dist/lang/ast/json-elements/json-element.d.ts +6 -0
  128. package/dist/lang/ast/json-elements/json-element.js +41 -0
  129. package/dist/lang/ast/json-elements/json-struct-def.d.ts +10 -0
  130. package/dist/lang/ast/json-elements/json-struct-def.js +48 -0
  131. package/dist/lang/ast/nesting/nest-reference.d.ts +7 -0
  132. package/dist/lang/ast/nesting/nest-reference.js +35 -0
  133. package/dist/lang/ast/parameters/constant-parameter.d.ts +8 -0
  134. package/dist/lang/ast/parameters/constant-parameter.js +54 -0
  135. package/dist/lang/ast/parameters/has-parameter.d.ts +19 -0
  136. package/dist/lang/ast/parameters/has-parameter.js +64 -0
  137. package/dist/lang/ast/query-elements/anonymous-query.d.ts +9 -0
  138. package/dist/lang/ast/query-elements/anonymous-query.js +41 -0
  139. package/dist/lang/ast/query-elements/existing-query.d.ts +11 -0
  140. package/dist/lang/ast/query-elements/existing-query.js +79 -0
  141. package/dist/lang/ast/query-elements/full-query.d.ts +10 -0
  142. package/dist/lang/ast/query-elements/full-query.js +85 -0
  143. package/dist/lang/ast/query-elements/query-head-struct.d.ts +9 -0
  144. package/dist/lang/ast/query-elements/query-head-struct.js +48 -0
  145. package/dist/lang/ast/query-items/field-declaration.d.ts +31 -0
  146. package/dist/lang/ast/query-items/field-declaration.js +137 -0
  147. package/dist/lang/ast/query-items/field-references.d.ts +25 -0
  148. package/dist/lang/ast/query-items/field-references.js +80 -0
  149. package/dist/lang/ast/query-properties/aggregate.d.ts +5 -0
  150. package/dist/lang/ast/query-properties/aggregate.js +39 -0
  151. package/dist/lang/ast/query-properties/declare-fields.d.ts +5 -0
  152. package/dist/lang/ast/query-properties/declare-fields.js +33 -0
  153. package/dist/lang/ast/query-properties/dimmensions.d.ts +5 -0
  154. package/dist/lang/ast/query-properties/dimmensions.js +36 -0
  155. package/dist/lang/ast/query-properties/filters.d.ts +18 -0
  156. package/dist/lang/ast/query-properties/filters.js +89 -0
  157. package/dist/lang/ast/query-properties/group-by.d.ts +5 -0
  158. package/dist/lang/ast/query-properties/group-by.js +39 -0
  159. package/dist/lang/ast/query-properties/indexing.d.ts +10 -0
  160. package/dist/lang/ast/query-properties/indexing.js +39 -0
  161. package/dist/lang/ast/query-properties/joins.d.ts +36 -0
  162. package/dist/lang/ast/query-properties/joins.js +143 -0
  163. package/dist/lang/ast/query-properties/limit.d.ts +6 -0
  164. package/dist/lang/ast/query-properties/limit.js +35 -0
  165. package/dist/lang/ast/query-properties/measures.d.ts +5 -0
  166. package/dist/lang/ast/query-properties/measures.js +36 -0
  167. package/dist/lang/ast/query-properties/nests.d.ts +5 -0
  168. package/dist/lang/ast/query-properties/nests.js +33 -0
  169. package/dist/lang/ast/query-properties/ordering.d.ts +15 -0
  170. package/dist/lang/ast/query-properties/ordering.js +66 -0
  171. package/dist/lang/ast/query-properties/project-statement.d.ts +5 -0
  172. package/dist/lang/ast/query-properties/project-statement.js +33 -0
  173. package/dist/lang/ast/query-properties/qop-desc.d.ts +17 -0
  174. package/dist/lang/ast/query-properties/qop-desc.js +123 -0
  175. package/dist/lang/ast/query-properties/sampling.d.ts +8 -0
  176. package/dist/lang/ast/query-properties/sampling.js +38 -0
  177. package/dist/lang/ast/query-properties/top.d.ts +13 -0
  178. package/dist/lang/ast/query-properties/top.js +60 -0
  179. package/dist/lang/ast/result-spaces/index-field-space.d.ts +10 -0
  180. package/dist/lang/ast/result-spaces/index-field-space.js +57 -0
  181. package/dist/lang/ast/result-spaces/project-field-space.d.ts +6 -0
  182. package/dist/lang/ast/result-spaces/project-field-space.js +51 -0
  183. package/dist/lang/ast/result-spaces/reduce-field-space.d.ts +7 -0
  184. package/dist/lang/ast/result-spaces/reduce-field-space.js +37 -0
  185. package/dist/lang/ast/sources/named-source.d.ts +19 -0
  186. package/dist/lang/ast/sources/named-source.js +147 -0
  187. package/dist/lang/ast/sources/query-source.d.ts +9 -0
  188. package/dist/lang/ast/sources/query-source.js +41 -0
  189. package/dist/lang/ast/sources/sql-source.d.ts +7 -0
  190. package/dist/lang/ast/sources/sql-source.js +54 -0
  191. package/dist/lang/ast/sources/table-source.d.ts +8 -0
  192. package/dist/lang/ast/sources/table-source.js +60 -0
  193. package/dist/lang/ast/space-fields/column-space-field.d.ts +9 -0
  194. package/dist/lang/ast/space-fields/column-space-field.js +40 -0
  195. package/dist/lang/ast/space-fields/join-space-field.d.ts +8 -0
  196. package/dist/lang/ast/space-fields/join-space-field.js +35 -0
  197. package/dist/lang/ast/space-fields/query-field-struct.d.ts +10 -0
  198. package/dist/lang/ast/space-fields/query-field-struct.js +46 -0
  199. package/dist/lang/ast/space-fields/query-space-field.d.ts +11 -0
  200. package/dist/lang/ast/space-fields/query-space-field.js +37 -0
  201. package/dist/lang/ast/space-fields/reference-field.d.ts +11 -0
  202. package/dist/lang/ast/space-fields/reference-field.js +45 -0
  203. package/dist/lang/ast/space-fields/rename-space-field.d.ts +11 -0
  204. package/dist/lang/ast/space-fields/rename-space-field.js +50 -0
  205. package/dist/lang/ast/space-fields/wild-space-field.d.ts +10 -0
  206. package/dist/lang/ast/space-fields/wild-space-field.js +40 -0
  207. package/dist/lang/ast/space-parameters/abstract-parameter.d.ts +10 -0
  208. package/dist/lang/ast/space-parameters/abstract-parameter.js +41 -0
  209. package/dist/lang/ast/space-parameters/defined-parameter.d.ts +9 -0
  210. package/dist/lang/ast/space-parameters/defined-parameter.js +40 -0
  211. package/dist/lang/ast/space-seed.d.ts +17 -0
  212. package/dist/lang/ast/space-seed.js +59 -0
  213. package/dist/lang/ast/sql-elements/sql-statement.d.ts +19 -0
  214. package/dist/lang/ast/sql-elements/sql-statement.js +80 -0
  215. package/dist/lang/ast/sql-elements/sql-string.d.ts +12 -0
  216. package/dist/lang/ast/sql-elements/sql-string.js +60 -0
  217. package/dist/lang/ast/static-space.d.ts +33 -0
  218. package/dist/lang/ast/static-space.js +167 -0
  219. package/dist/lang/ast/struct-utils.d.ts +4 -0
  220. package/dist/lang/ast/struct-utils.js +48 -0
  221. package/dist/lang/ast/time-utils.d.ts +5 -2
  222. package/dist/lang/ast/time-utils.js +37 -1
  223. package/dist/lang/ast/types/comparison.d.ts +11 -0
  224. package/dist/lang/ast/types/comparison.js +41 -0
  225. package/dist/lang/ast/types/compart-types.d.ts +10 -0
  226. package/dist/lang/ast/types/compart-types.js +37 -0
  227. package/dist/lang/ast/types/document-compile-result.d.ts +8 -0
  228. package/dist/lang/ast/types/document-compile-result.js +25 -0
  229. package/dist/lang/ast/types/equality.d.ts +7 -0
  230. package/dist/lang/ast/types/equality.js +37 -0
  231. package/dist/lang/ast/types/executor.d.ts +9 -0
  232. package/dist/lang/ast/types/executor.js +25 -0
  233. package/dist/lang/ast/types/explore-desc.d.ts +5 -0
  234. package/dist/lang/ast/types/explore-desc.js +33 -0
  235. package/dist/lang/ast/types/explore-field.d.ts +5 -0
  236. package/dist/lang/ast/types/explore-field.js +32 -0
  237. package/dist/lang/ast/types/explore-property.d.ts +10 -0
  238. package/dist/lang/ast/types/explore-property.js +43 -0
  239. package/dist/lang/ast/types/expr-result.d.ts +5 -0
  240. package/dist/lang/ast/types/expr-result.js +25 -0
  241. package/dist/lang/ast/types/expr-value.d.ts +3 -0
  242. package/dist/lang/ast/types/expr-value.js +25 -0
  243. package/dist/lang/ast/types/expression-def.d.ts +69 -0
  244. package/dist/lang/ast/types/expression-def.js +346 -0
  245. package/dist/lang/ast/types/expression-value-type.d.ts +2 -0
  246. package/dist/lang/ast/types/expression-value-type.js +25 -0
  247. package/dist/lang/ast/types/field-collection-member.d.ts +5 -0
  248. package/dist/lang/ast/types/field-collection-member.js +34 -0
  249. package/dist/lang/ast/types/field-decl.d.ts +7 -0
  250. package/dist/lang/ast/types/field-decl.js +37 -0
  251. package/dist/lang/ast/types/field-map.d.ts +2 -0
  252. package/dist/lang/ast/types/field-map.js +25 -0
  253. package/dist/lang/ast/types/field-space.d.ts +26 -0
  254. package/dist/lang/ast/types/field-space.js +48 -0
  255. package/dist/lang/ast/types/field-type.d.ts +6 -0
  256. package/dist/lang/ast/types/field-type.js +25 -0
  257. package/dist/lang/ast/types/field-value-type.d.ts +3 -0
  258. package/dist/lang/ast/types/field-value-type.js +25 -0
  259. package/dist/lang/ast/types/frag-type.d.ts +6 -0
  260. package/dist/lang/ast/types/frag-type.js +25 -0
  261. package/dist/lang/ast/types/granular-result.d.ts +7 -0
  262. package/dist/lang/ast/types/granular-result.js +11 -0
  263. package/dist/lang/ast/types/lookup-result.d.ts +10 -0
  264. package/dist/lang/ast/types/lookup-result.js +25 -0
  265. package/dist/lang/ast/types/malloy-element.d.ts +105 -0
  266. package/dist/lang/ast/types/malloy-element.js +398 -0
  267. package/dist/lang/ast/types/model-entry.d.ts +6 -0
  268. package/dist/lang/ast/types/model-entry.js +25 -0
  269. package/dist/lang/ast/types/name-space.d.ts +5 -0
  270. package/dist/lang/ast/types/name-space.js +25 -0
  271. package/dist/lang/ast/types/nested-query.d.ts +3 -0
  272. package/dist/lang/ast/types/nested-query.js +25 -0
  273. package/dist/lang/ast/types/op-desc.d.ts +6 -0
  274. package/dist/lang/ast/types/op-desc.js +25 -0
  275. package/dist/lang/ast/types/query-comp.d.ts +5 -0
  276. package/dist/lang/ast/types/query-comp.js +25 -0
  277. package/dist/lang/ast/types/query-element.d.ts +5 -0
  278. package/dist/lang/ast/types/query-element.js +32 -0
  279. package/dist/lang/ast/types/query-item.d.ts +5 -0
  280. package/dist/lang/ast/types/query-item.js +25 -0
  281. package/dist/lang/ast/types/query-property.d.ts +17 -0
  282. package/dist/lang/ast/types/query-property.js +55 -0
  283. package/dist/lang/ast/types/space-entry.d.ts +5 -0
  284. package/dist/lang/ast/types/space-entry.js +29 -0
  285. package/dist/lang/ast/types/space-field.d.ts +10 -0
  286. package/dist/lang/ast/types/space-field.js +48 -0
  287. package/dist/lang/ast/types/space-param.d.ts +6 -0
  288. package/dist/lang/ast/types/space-param.js +34 -0
  289. package/dist/lang/ast/types/stage-field-type.d.ts +1 -0
  290. package/dist/lang/ast/types/stage-field-type.js +25 -0
  291. package/dist/lang/ast/types/time-result.d.ts +6 -0
  292. package/dist/lang/ast/types/time-result.js +25 -0
  293. package/dist/lang/ast/types/turtle-headed-pipe.d.ts +7 -0
  294. package/dist/lang/ast/types/turtle-headed-pipe.js +37 -0
  295. package/dist/lang/space-field.d.ts +4 -1
  296. package/dist/lang/space-field.js +4 -3
  297. package/dist/lang/test/field-symbols.spec.js +25 -21
  298. package/dist/lang/test/parse.spec.js +4 -3
  299. package/dist/lang/test/test-translator.d.ts +3 -1
  300. package/package.json +1 -1
  301. package/dist/lang/ast/apply-expr.d.ts +0 -3
  302. package/dist/lang/ast/ast-expr.d.ts +0 -206
  303. package/dist/lang/ast/ast-expr.js +0 -781
  304. package/dist/lang/ast/ast-time-expr.d.ts +0 -69
  305. package/dist/lang/ast/ast-time-expr.js +0 -389
  306. package/dist/lang/ast/ast-types.d.ts +0 -83
  307. package/dist/lang/ast/ast-types.js +0 -225
@@ -0,0 +1,11 @@
1
+ import { ExpressionType, Fragment, TimeFieldType } from "../../../model/malloy_types";
2
+ import { FieldSpace } from "../types/field-space";
3
+ import { ExprValue } from "../types/expr-value";
4
+ import { ExpressionDef } from "../types/expression-def";
5
+ export declare class ExprTime extends ExpressionDef {
6
+ elementType: string;
7
+ readonly translationValue: ExprValue;
8
+ constructor(timeType: TimeFieldType, value: Fragment[] | string, expressionType?: ExpressionType);
9
+ getExpression(_fs: FieldSpace): ExprValue;
10
+ static fromValue(timeType: TimeFieldType, expr: ExprValue): ExprTime;
11
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.ExprTime = void 0;
26
+ const malloy_types_1 = require("../../../model/malloy_types");
27
+ const utils_1 = require("./utils");
28
+ const expression_def_1 = require("../types/expression-def");
29
+ class ExprTime extends expression_def_1.ExpressionDef {
30
+ constructor(timeType, value, expressionType = "scalar") {
31
+ super();
32
+ this.elementType = "timestampOrDate";
33
+ this.elementType = timeType;
34
+ this.translationValue = {
35
+ dataType: timeType,
36
+ expressionType,
37
+ value: typeof value === "string" ? [value] : value,
38
+ };
39
+ }
40
+ getExpression(_fs) {
41
+ return this.translationValue;
42
+ }
43
+ static fromValue(timeType, expr) {
44
+ let value = expr.value;
45
+ if (timeType != expr.dataType) {
46
+ const toTs = {
47
+ type: "dialect",
48
+ function: "cast",
49
+ safe: false,
50
+ dstType: timeType,
51
+ expr: expr.value,
52
+ };
53
+ if ((0, malloy_types_1.isTimeFieldType)(expr.dataType)) {
54
+ toTs.srcType = expr.dataType;
55
+ }
56
+ value = (0, utils_1.compressExpr)([toTs]);
57
+ }
58
+ return new ExprTime(timeType, value, expr.expressionType);
59
+ }
60
+ }
61
+ exports.ExprTime = ExprTime;
62
+ //# sourceMappingURL=expr-time.js.map
@@ -0,0 +1,14 @@
1
+ import { ExprValue } from "../types/expr-value";
2
+ import { FieldValueType } from "../types/field-value-type";
3
+ import { FieldName, FieldSpace } from "../types/field-space";
4
+ import { ExpressionDef } from "../types/expression-def";
5
+ export declare class ExprUngroup extends ExpressionDef {
6
+ readonly control: "all" | "exclude";
7
+ readonly expr: ExpressionDef;
8
+ readonly fields: FieldName[];
9
+ legalChildTypes: import("../types/frag-type").FragType[];
10
+ elementType: string;
11
+ constructor(control: "all" | "exclude", expr: ExpressionDef, fields: FieldName[]);
12
+ returns(_forExpression: ExprValue): FieldValueType;
13
+ getExpression(fs: FieldSpace): ExprValue;
14
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExprUngroup = void 0;
4
+ /*
5
+ * Copyright 2023 Google LLC
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining
8
+ * a copy of this software and associated documentation files
9
+ * (the "Software"), to deal in the Software without restriction,
10
+ * including without limitation the rights to use, copy, modify, merge,
11
+ * publish, distribute, sublicense, and/or sell copies of the Software,
12
+ * and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ */
26
+ const malloy_types_1 = require("../../../model/malloy_types");
27
+ const ast_main_1 = require("../ast-main");
28
+ const ast_utils_1 = require("../ast-utils");
29
+ const field_declaration_1 = require("../query-items/field-declaration");
30
+ const fragtype_utils_1 = require("../fragtype-utils");
31
+ const expression_def_1 = require("../types/expression-def");
32
+ class ExprUngroup extends expression_def_1.ExpressionDef {
33
+ constructor(control, expr, fields) {
34
+ super({ expr, fields });
35
+ this.control = control;
36
+ this.expr = expr;
37
+ this.fields = fields;
38
+ this.legalChildTypes = fragtype_utils_1.FT.anyAtomicT;
39
+ this.elementType = "ungroup";
40
+ }
41
+ returns(_forExpression) {
42
+ return "number";
43
+ }
44
+ getExpression(fs) {
45
+ const exprVal = this.expr.getExpression(fs);
46
+ if (!(0, malloy_types_1.expressionIsAggregate)(exprVal.expressionType)) {
47
+ this.expr.log(`${this.control}() expression must be an aggregate`);
48
+ return (0, ast_utils_1.errorFor)("ungrouped scalar");
49
+ }
50
+ const ungroup = { type: this.control, e: exprVal.value };
51
+ if (this.typeCheck(this.expr, { ...exprVal, expressionType: "scalar" })) {
52
+ if (this.fields.length > 0) {
53
+ let qs = fs;
54
+ if (fs instanceof field_declaration_1.DefSpace) {
55
+ qs = fs.realFS;
56
+ }
57
+ if (!(qs instanceof ast_main_1.QuerySpace)) {
58
+ this.log(`${this.control}() must be in a query -- weird internal error`);
59
+ return (0, ast_utils_1.errorFor)("ungroup query check");
60
+ }
61
+ const output = qs.result;
62
+ const dstFields = [];
63
+ const isExclude = this.control == "exclude";
64
+ for (const mustBeInOutput of this.fields) {
65
+ output.whenComplete(() => {
66
+ output.checkUngroup(mustBeInOutput, isExclude);
67
+ });
68
+ dstFields.push(mustBeInOutput.refString);
69
+ }
70
+ ungroup.fields = dstFields;
71
+ }
72
+ return {
73
+ dataType: this.returns(exprVal),
74
+ expressionType: "analytic",
75
+ value: [ungroup],
76
+ };
77
+ }
78
+ this.log(`${this.control}() incompatible type`);
79
+ return (0, ast_utils_1.errorFor)("ungrouped type check");
80
+ }
81
+ }
82
+ exports.ExprUngroup = ExprUngroup;
83
+ //# sourceMappingURL=expr-ungroup.js.map
@@ -0,0 +1,19 @@
1
+ import { FieldSpace } from "../types/field-space";
2
+ import { ExprValue } from "../types/expr-value";
3
+ import { ExpressionDef } from "../types/expression-def";
4
+ import { Timeframe } from "./time-frame";
5
+ /**
6
+ * TODO: This is sort of a hand clone of the "Range" class, they should
7
+ * be siblings of a common abstract classs.
8
+ */
9
+ export declare class ForRange extends ExpressionDef {
10
+ readonly from: ExpressionDef;
11
+ readonly duration: ExpressionDef;
12
+ readonly timeframe: Timeframe;
13
+ elementType: string;
14
+ legalChildTypes: import("../types/frag-type").FragType[];
15
+ constructor(from: ExpressionDef, duration: ExpressionDef, timeframe: Timeframe);
16
+ apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
17
+ requestExpression(_fs: FieldSpace): ExprValue | undefined;
18
+ getExpression(_fs: FieldSpace): ExprValue;
19
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.ForRange = void 0;
26
+ const ast_utils_1 = require("../ast-utils");
27
+ const fragtype_utils_1 = require("../fragtype-utils");
28
+ const time_utils_1 = require("../time-utils");
29
+ const expression_def_1 = require("../types/expression-def");
30
+ const granular_result_1 = require("../types/granular-result");
31
+ const expr_time_1 = require("./expr-time");
32
+ const range_1 = require("./range");
33
+ /**
34
+ * TODO: This is sort of a hand clone of the "Range" class, they should
35
+ * be siblings of a common abstract classs.
36
+ */
37
+ class ForRange extends expression_def_1.ExpressionDef {
38
+ constructor(from, duration, timeframe) {
39
+ super({ from, duration, timeframe });
40
+ this.from = from;
41
+ this.duration = duration;
42
+ this.timeframe = timeframe;
43
+ this.elementType = "forRange";
44
+ this.legalChildTypes = [fragtype_utils_1.FT.timestampT, fragtype_utils_1.FT.dateT];
45
+ }
46
+ apply(fs, op, expr) {
47
+ const startV = this.from.getExpression(fs);
48
+ const checkV = expr.getExpression(fs);
49
+ if (!this.typeCheck(expr, checkV)) {
50
+ return (0, ast_utils_1.errorFor)("no time for range");
51
+ }
52
+ const nV = this.duration.getExpression(fs);
53
+ if (nV.dataType !== "number") {
54
+ this.log(`FOR duration count must be a number, not '${nV.dataType}'`);
55
+ return (0, ast_utils_1.errorFor)("FOR not number");
56
+ }
57
+ const units = this.timeframe.text;
58
+ // If the duration resolution is smaller than date, we have
59
+ // to do the computaion with timestamps.
60
+ const durationRes = (0, time_utils_1.resolution)(units);
61
+ let rangeType = durationRes;
62
+ // Next, if the beginning of the range is a timestamp, then we
63
+ // also have to do the computation as a timestamp
64
+ if (startV.dataType === "timestamp") {
65
+ rangeType = "timestamp";
66
+ }
67
+ // everything is dates, do date math
68
+ if (checkV.dataType === "date" && rangeType === "date") {
69
+ const rangeStart = this.from;
70
+ const rangeEndV = (0, time_utils_1.timeOffset)("date", startV.value, "+", nV.value, units);
71
+ const rangeEnd = new expr_time_1.ExprTime("date", rangeEndV);
72
+ return new range_1.Range(rangeStart, rangeEnd).apply(fs, op, expr);
73
+ }
74
+ // Now it doesn't matter if the range is a date or a timestamp,
75
+ // the comparison will be in timestamp space,
76
+ const applyTo = expr_time_1.ExprTime.fromValue("timestamp", checkV);
77
+ let rangeStart = this.from;
78
+ let from = startV.value;
79
+ if (startV.dataType === "date") {
80
+ // Time literals with timestamp units can also be used as timestamps;
81
+ const alreadyTs = (0, granular_result_1.isGranularResult)(startV) && startV.alsoTimestamp;
82
+ if (!alreadyTs) {
83
+ // ... not a literal, need a cast
84
+ from = (0, time_utils_1.castDateToTimestamp)(from);
85
+ }
86
+ rangeStart = new expr_time_1.ExprTime("timestamp", from, startV.expressionType);
87
+ }
88
+ const to = (0, time_utils_1.timeOffset)("timestamp", from, "+", nV.value, units);
89
+ const rangeEnd = new expr_time_1.ExprTime("timestamp", to, startV.expressionType);
90
+ return new range_1.Range(rangeStart, rangeEnd).apply(fs, op, applyTo);
91
+ }
92
+ requestExpression(_fs) {
93
+ return undefined;
94
+ }
95
+ getExpression(_fs) {
96
+ this.log("A Range is not a value");
97
+ return (0, ast_utils_1.errorFor)("range has no value");
98
+ }
99
+ }
100
+ exports.ForRange = ForRange;
101
+ //# sourceMappingURL=for-range.js.map
@@ -0,0 +1,20 @@
1
+ import { TimeFieldType, TimestampUnit } from "../../../model/malloy_types";
2
+ import { ExprValue } from "../types/expr-value";
3
+ import { FieldSpace } from "../types/field-space";
4
+ import { ExpressionDef } from "../types/expression-def";
5
+ /**
6
+ * GranularTime made from a literal. Funky because it doesn't know if it
7
+ * is a date or a timestamp in many cases until it is applied.
8
+ */
9
+ export declare class GranularLiteral extends ExpressionDef {
10
+ readonly moment: string;
11
+ readonly until: string;
12
+ readonly units: TimestampUnit;
13
+ elementType: string;
14
+ timeType?: TimeFieldType;
15
+ constructor(moment: string, until: string, units: TimestampUnit);
16
+ granular(): boolean;
17
+ static parse(possibleLiteral: string): GranularLiteral | undefined;
18
+ apply(fs: FieldSpace, op: string, left: ExpressionDef): ExprValue;
19
+ getExpression(_fs: FieldSpace): ExprValue;
20
+ }
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GranularLiteral = void 0;
4
+ /*
5
+ * Copyright 2023 Google LLC
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining
8
+ * a copy of this software and associated documentation files
9
+ * (the "Software"), to deal in the Software without restriction,
10
+ * including without limitation the rights to use, copy, modify, merge,
11
+ * publish, distribute, sublicense, and/or sell copies of the Software,
12
+ * and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ */
26
+ const luxon_1 = require("luxon");
27
+ const malloy_types_1 = require("../../../model/malloy_types");
28
+ const range_1 = require("./range");
29
+ const expr_time_1 = require("./expr-time");
30
+ const time_utils_1 = require("../time-utils");
31
+ const expression_def_1 = require("../types/expression-def");
32
+ /**
33
+ * GranularTime made from a literal. Funky because it doesn't know if it
34
+ * is a date or a timestamp in many cases until it is applied.
35
+ */
36
+ class GranularLiteral extends expression_def_1.ExpressionDef {
37
+ constructor(moment, until, units) {
38
+ super();
39
+ this.moment = moment;
40
+ this.until = until;
41
+ this.units = units;
42
+ this.elementType = "timeLiteral";
43
+ }
44
+ granular() {
45
+ return true;
46
+ }
47
+ static parse(possibleLiteral) {
48
+ const s = possibleLiteral.slice(1);
49
+ const fYear = "yyyy";
50
+ const fMonth = `${fYear}-LL`;
51
+ const fDay = `${fMonth}-dd`;
52
+ const fMinute = `${fDay} HH:mm`;
53
+ const fSecond = `${fMinute}:ss`;
54
+ const tss = luxon_1.DateTime.fromFormat(s, fSecond);
55
+ if (tss.isValid) {
56
+ const nextSecond = tss.plus({ second: 1 }).toFormat(fSecond);
57
+ const tsLit = new GranularLiteral(s, nextSecond, "second");
58
+ tsLit.timeType = "timestamp";
59
+ return tsLit;
60
+ }
61
+ const tsm = luxon_1.DateTime.fromFormat(s, fMinute);
62
+ if (tsm.isValid) {
63
+ // working around a weird bigquery bug ...
64
+ const thisMin = s + ":00";
65
+ const nextMinute = tsm.plus({ minute: 1 }).toFormat(fMinute) + ":00";
66
+ const tsLit = new GranularLiteral(thisMin, nextMinute, "minute");
67
+ tsLit.timeType = "timestamp";
68
+ return tsLit;
69
+ }
70
+ const quarter = s.match(/(\d{4})-[qQ](\d)$/);
71
+ if (quarter) {
72
+ const qplus = Number.parseInt(quarter[2]) - 1;
73
+ let qstart = luxon_1.DateTime.fromFormat(quarter[1], "yyyy");
74
+ if (qplus > 0) {
75
+ qstart = qstart.plus({ quarters: qplus });
76
+ }
77
+ const qend = qstart.plus({ quarter: 1 });
78
+ return new GranularLiteral(`${qstart.toFormat(fDay)}`, `${qend.toFormat(fDay)}`, "quarter");
79
+ }
80
+ const yyyymmdd = luxon_1.DateTime.fromFormat(s, fDay);
81
+ if (yyyymmdd.isValid) {
82
+ const next = yyyymmdd.plus({ days: 1 });
83
+ return new GranularLiteral(`${yyyymmdd.toFormat(fDay)}`, `${next.toFormat(fDay)}`, "day");
84
+ }
85
+ const yyyymm = luxon_1.DateTime.fromFormat(s, fMonth);
86
+ if (yyyymm.isValid) {
87
+ const next = yyyymm.plus({ months: 1 });
88
+ return new GranularLiteral(`${yyyymm.toFormat(fDay)}`, `${next.toFormat(fDay)}`, "month");
89
+ }
90
+ const yyyy = luxon_1.DateTime.fromFormat(s, fYear);
91
+ if (yyyy.isValid) {
92
+ const year = yyyy.toFormat(`yyyy-01-01`);
93
+ const nextYear = yyyy.plus({ year: 1 }).toFormat(`yyyy-01-01`);
94
+ return new GranularLiteral(year, nextYear, "year");
95
+ }
96
+ if (s.startsWith("WK")) {
97
+ const yyyymmdd = luxon_1.DateTime.fromFormat(s.slice(2), fDay);
98
+ if (yyyymmdd.isValid) {
99
+ // wonky because luxon uses monday weeks and bigquery uses sunday weeks
100
+ let sunday = yyyymmdd;
101
+ if (yyyymmdd.weekday !== 7) {
102
+ sunday = yyyymmdd.startOf("week").minus({ day: 1 });
103
+ }
104
+ const next = sunday.plus({ days: 7 });
105
+ return new GranularLiteral(`${sunday.toFormat(fDay)}`, `${next.toFormat(fDay)}`, "week");
106
+ }
107
+ }
108
+ return undefined;
109
+ }
110
+ apply(fs, op, left) {
111
+ const lhs = left.getExpression(fs);
112
+ if ((0, malloy_types_1.isTimeFieldType)(lhs.dataType)) {
113
+ let rangeType = "timestamp";
114
+ if (lhs.dataType === "date" && !this.timeType) {
115
+ rangeType = "date";
116
+ }
117
+ const range = new range_1.Range(new expr_time_1.ExprTime(rangeType, (0, time_utils_1.timeLiteral)(this.moment, rangeType, "UTC")), new expr_time_1.ExprTime(rangeType, (0, time_utils_1.timeLiteral)(this.until, rangeType, "UTC")));
118
+ return range.apply(fs, op, left);
119
+ }
120
+ return super.apply(fs, op, left);
121
+ }
122
+ getExpression(_fs) {
123
+ const dataType = this.timeType || "date";
124
+ const value = {
125
+ dataType,
126
+ expressionType: "scalar",
127
+ value: (0, time_utils_1.timeLiteral)(this.moment, dataType, "UTC"),
128
+ };
129
+ // Literals with date resolution can be used as timestamps or dates,
130
+ // this is the third attempt to make that work. It still feels like
131
+ // there should be a better way to make this happen, but the point
132
+ // at which the data is needed, the handle is gone to the ExpressionDef
133
+ // which would allow a method call into this class. I think the second
134
+ // if clause is redundant (see "parse" above, but I'm paranoid)
135
+ if (dataType == "date" && (0, malloy_types_1.isDateUnit)(this.units)) {
136
+ value.alsoTimestamp = true;
137
+ }
138
+ if (this.units != "second") {
139
+ return {
140
+ ...value,
141
+ timeframe: this.units,
142
+ };
143
+ }
144
+ return value;
145
+ }
146
+ }
147
+ exports.GranularLiteral = GranularLiteral;
148
+ //# sourceMappingURL=granular-literal.js.map
@@ -0,0 +1,14 @@
1
+ import { Comparison } from "../types/comparison";
2
+ import { ExprValue } from "../types/expr-value";
3
+ import { FieldSpace } from "../types/field-space";
4
+ import { ExpressionDef } from "../types/expression-def";
5
+ export declare class PartialCompare extends ExpressionDef {
6
+ readonly op: Comparison;
7
+ readonly right: ExpressionDef;
8
+ elementType: string;
9
+ constructor(op: Comparison, right: ExpressionDef);
10
+ granular(): boolean;
11
+ apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
12
+ requestExpression(_fs: FieldSpace): ExprValue | undefined;
13
+ getExpression(_fs: FieldSpace): ExprValue;
14
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PartialCompare = void 0;
4
+ /*
5
+ * Copyright 2023 Google LLC
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining
8
+ * a copy of this software and associated documentation files
9
+ * (the "Software"), to deal in the Software without restriction,
10
+ * including without limitation the rights to use, copy, modify, merge,
11
+ * publish, distribute, sublicense, and/or sell copies of the Software,
12
+ * and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ */
26
+ const ast_utils_1 = require("../ast-utils");
27
+ const expression_def_1 = require("../types/expression-def");
28
+ class PartialCompare extends expression_def_1.ExpressionDef {
29
+ constructor(op, right) {
30
+ super({ right });
31
+ this.op = op;
32
+ this.right = right;
33
+ this.elementType = "<=> a";
34
+ }
35
+ granular() {
36
+ return this.right.granular();
37
+ }
38
+ apply(fs, op, expr) {
39
+ return this.right.apply(fs, this.op, expr);
40
+ }
41
+ requestExpression(_fs) {
42
+ return undefined;
43
+ }
44
+ getExpression(_fs) {
45
+ this.log(`Partial comparison does not have a value`);
46
+ return (0, ast_utils_1.errorFor)("no value for partial compare");
47
+ }
48
+ }
49
+ exports.PartialCompare = PartialCompare;
50
+ //# sourceMappingURL=partial-compare.js.map
@@ -0,0 +1,19 @@
1
+ import { ExprValue } from "../types/expr-value";
2
+ import { FieldSpace } from "../types/field-space";
3
+ import { MalloyElement } from "../types/malloy-element";
4
+ import { ExpressionDef } from "../types/expression-def";
5
+ export declare class Pick extends ExpressionDef {
6
+ readonly choices: PickWhen[];
7
+ readonly elsePick?: ExpressionDef | undefined;
8
+ elementType: string;
9
+ constructor(choices: PickWhen[], elsePick?: ExpressionDef | undefined);
10
+ requestExpression(fs: FieldSpace): ExprValue | undefined;
11
+ apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
12
+ getExpression(fs: FieldSpace): ExprValue;
13
+ }
14
+ export declare class PickWhen extends MalloyElement {
15
+ readonly pick: ExpressionDef | undefined;
16
+ readonly when: ExpressionDef;
17
+ elementType: string;
18
+ constructor(pick: ExpressionDef | undefined, when: ExpressionDef);
19
+ }