@uwdata/mosaic-sql 0.17.0 → 0.18.0

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 (409) hide show
  1. package/LICENSE +47 -0
  2. package/README.md +0 -2
  3. package/dist/src/ast/aggregate.d.ts +82 -0
  4. package/dist/src/ast/aggregate.d.ts.map +1 -0
  5. package/dist/src/ast/aggregate.js +180 -0
  6. package/dist/src/ast/aggregate.js.map +1 -0
  7. package/dist/src/ast/between-op.d.ts +46 -0
  8. package/dist/src/ast/between-op.d.ts.map +1 -0
  9. package/dist/src/ast/between-op.js +60 -0
  10. package/dist/src/ast/between-op.js.map +1 -0
  11. package/dist/src/ast/binary-op.d.ts +21 -0
  12. package/dist/src/ast/binary-op.d.ts.map +1 -0
  13. package/dist/src/ast/binary-op.js +29 -0
  14. package/dist/src/ast/binary-op.js.map +1 -0
  15. package/dist/src/ast/case.d.ts +53 -0
  16. package/dist/src/ast/case.d.ts.map +1 -0
  17. package/dist/src/ast/case.js +75 -0
  18. package/dist/src/ast/case.js.map +1 -0
  19. package/dist/src/ast/cast.d.ts +18 -0
  20. package/dist/src/ast/cast.d.ts.map +1 -0
  21. package/dist/src/ast/cast.js +26 -0
  22. package/dist/src/ast/cast.js.map +1 -0
  23. package/dist/src/ast/collate.d.ts +18 -0
  24. package/dist/src/ast/collate.d.ts.map +1 -0
  25. package/dist/src/ast/collate.js +25 -0
  26. package/dist/src/ast/collate.js.map +1 -0
  27. package/dist/src/ast/column-param.d.ts +23 -0
  28. package/dist/src/ast/column-param.d.ts.map +1 -0
  29. package/dist/src/ast/column-param.js +29 -0
  30. package/dist/src/ast/column-param.js.map +1 -0
  31. package/dist/src/ast/column-ref.d.ts +40 -0
  32. package/dist/src/ast/column-ref.d.ts.map +1 -0
  33. package/dist/src/ast/column-ref.js +58 -0
  34. package/dist/src/ast/column-ref.js.map +1 -0
  35. package/dist/src/ast/fragment.d.ts +20 -0
  36. package/dist/src/ast/fragment.d.ts.map +1 -0
  37. package/dist/src/ast/fragment.js +26 -0
  38. package/dist/src/ast/fragment.js.map +1 -0
  39. package/dist/src/ast/from.d.ts +22 -0
  40. package/dist/src/ast/from.d.ts.map +1 -0
  41. package/dist/src/ast/from.js +37 -0
  42. package/dist/src/ast/from.js.map +1 -0
  43. package/dist/src/ast/function.d.ts +18 -0
  44. package/dist/src/ast/function.d.ts.map +1 -0
  45. package/dist/src/ast/function.js +26 -0
  46. package/dist/src/ast/function.js.map +1 -0
  47. package/dist/src/ast/in-op.d.ts +18 -0
  48. package/dist/src/ast/in-op.d.ts.map +1 -0
  49. package/dist/src/ast/in-op.js +25 -0
  50. package/dist/src/ast/in-op.js.map +1 -0
  51. package/dist/src/ast/interval.d.ts +18 -0
  52. package/dist/src/ast/interval.d.ts.map +1 -0
  53. package/dist/src/ast/interval.js +25 -0
  54. package/dist/src/ast/interval.js.map +1 -0
  55. package/dist/src/ast/literal.d.ts +16 -0
  56. package/dist/src/ast/literal.d.ts.map +1 -0
  57. package/dist/src/ast/literal.js +53 -0
  58. package/dist/src/ast/literal.js.map +1 -0
  59. package/dist/src/ast/logical-op.d.ts +32 -0
  60. package/dist/src/ast/logical-op.d.ts.map +1 -0
  61. package/dist/src/ast/logical-op.js +46 -0
  62. package/dist/src/ast/logical-op.js.map +1 -0
  63. package/dist/src/ast/node.d.ts +25 -0
  64. package/dist/src/ast/node.d.ts.map +1 -0
  65. package/dist/src/ast/node.js +36 -0
  66. package/dist/src/ast/node.js.map +1 -0
  67. package/dist/src/ast/order-by.d.ts +21 -0
  68. package/dist/src/ast/order-by.d.ts.map +1 -0
  69. package/dist/src/ast/order-by.js +36 -0
  70. package/dist/src/ast/order-by.js.map +1 -0
  71. package/dist/src/ast/param.d.ts +20 -0
  72. package/dist/src/ast/param.d.ts.map +1 -0
  73. package/dist/src/ast/param.js +28 -0
  74. package/dist/src/ast/param.js.map +1 -0
  75. package/dist/src/ast/query.d.ts +294 -0
  76. package/dist/src/ast/query.d.ts.map +1 -0
  77. package/dist/src/ast/query.js +584 -0
  78. package/dist/src/ast/query.js.map +1 -0
  79. package/dist/src/ast/sample.d.ts +27 -0
  80. package/dist/src/ast/sample.d.ts.map +1 -0
  81. package/dist/src/ast/sample.js +38 -0
  82. package/dist/src/ast/sample.js.map +1 -0
  83. package/dist/src/ast/select.d.ts +19 -0
  84. package/dist/src/ast/select.d.ts.map +1 -0
  85. package/dist/src/ast/select.js +35 -0
  86. package/dist/src/ast/select.js.map +1 -0
  87. package/dist/src/ast/subquery.d.ts +16 -0
  88. package/dist/src/ast/subquery.d.ts.map +1 -0
  89. package/dist/src/ast/subquery.js +21 -0
  90. package/dist/src/ast/subquery.js.map +1 -0
  91. package/dist/src/ast/table-ref.d.ts +24 -0
  92. package/dist/src/ast/table-ref.d.ts.map +1 -0
  93. package/dist/src/ast/table-ref.js +35 -0
  94. package/dist/src/ast/table-ref.js.map +1 -0
  95. package/dist/src/ast/unary-op.d.ts +40 -0
  96. package/dist/src/ast/unary-op.d.ts.map +1 -0
  97. package/dist/src/ast/unary-op.js +52 -0
  98. package/dist/src/ast/unary-op.js.map +1 -0
  99. package/dist/src/ast/verbatim.d.ts +18 -0
  100. package/dist/src/ast/verbatim.d.ts.map +1 -0
  101. package/dist/src/ast/verbatim.js +25 -0
  102. package/dist/src/ast/verbatim.js.map +1 -0
  103. package/dist/src/ast/window-frame.d.ts +54 -0
  104. package/dist/src/ast/window-frame.d.ts.map +1 -0
  105. package/dist/src/ast/window-frame.js +79 -0
  106. package/dist/src/ast/window-frame.js.map +1 -0
  107. package/dist/src/ast/window.d.ts +128 -0
  108. package/dist/src/ast/window.d.ts.map +1 -0
  109. package/dist/src/ast/window.js +194 -0
  110. package/dist/src/ast/window.js.map +1 -0
  111. package/dist/src/ast/with.d.ts +25 -0
  112. package/dist/src/ast/with.d.ts.map +1 -0
  113. package/dist/src/ast/with.js +36 -0
  114. package/dist/src/ast/with.js.map +1 -0
  115. package/dist/src/constants.d.ts +38 -0
  116. package/dist/src/constants.d.ts.map +1 -0
  117. package/dist/src/constants.js +38 -0
  118. package/dist/src/constants.js.map +1 -0
  119. package/dist/src/functions/aggregate.d.ts +236 -0
  120. package/dist/src/functions/aggregate.d.ts.map +1 -0
  121. package/dist/src/functions/aggregate.js +308 -0
  122. package/dist/src/functions/aggregate.js.map +1 -0
  123. package/dist/src/functions/case.d.ts +13 -0
  124. package/dist/src/functions/case.d.ts.map +1 -0
  125. package/dist/src/functions/case.js +17 -0
  126. package/dist/src/functions/case.js.map +1 -0
  127. package/dist/src/functions/cast.d.ts +23 -0
  128. package/dist/src/functions/cast.d.ts.map +1 -0
  129. package/dist/src/functions/cast.js +32 -0
  130. package/dist/src/functions/cast.js.map +1 -0
  131. package/dist/src/functions/collate.d.ts +10 -0
  132. package/dist/src/functions/collate.d.ts.map +1 -0
  133. package/dist/src/functions/collate.js +12 -0
  134. package/dist/src/functions/collate.js.map +1 -0
  135. package/dist/src/functions/column.d.ts +10 -0
  136. package/dist/src/functions/column.d.ts.map +1 -0
  137. package/dist/src/functions/column.js +17 -0
  138. package/dist/src/functions/column.js.map +1 -0
  139. package/dist/src/functions/cte.d.ts +13 -0
  140. package/dist/src/functions/cte.d.ts.map +1 -0
  141. package/dist/src/functions/cte.js +14 -0
  142. package/dist/src/functions/cte.js.map +1 -0
  143. package/dist/src/functions/datetime.d.ts +32 -0
  144. package/dist/src/functions/datetime.d.ts.map +1 -0
  145. package/dist/src/functions/datetime.js +45 -0
  146. package/dist/src/functions/datetime.js.map +1 -0
  147. package/dist/src/functions/interval.d.ts +48 -0
  148. package/dist/src/functions/interval.d.ts.map +1 -0
  149. package/dist/src/functions/interval.js +66 -0
  150. package/dist/src/functions/interval.js.map +1 -0
  151. package/dist/src/functions/literal.d.ts +16 -0
  152. package/dist/src/functions/literal.d.ts.map +1 -0
  153. package/dist/src/functions/literal.js +20 -0
  154. package/dist/src/functions/literal.js.map +1 -0
  155. package/dist/src/functions/numeric.d.ts +80 -0
  156. package/dist/src/functions/numeric.d.ts.map +1 -0
  157. package/dist/src/functions/numeric.js +110 -0
  158. package/dist/src/functions/numeric.js.map +1 -0
  159. package/dist/src/functions/operators.d.ts +169 -0
  160. package/dist/src/functions/operators.d.ts.map +1 -0
  161. package/dist/src/functions/operators.js +235 -0
  162. package/dist/src/functions/operators.js.map +1 -0
  163. package/dist/src/functions/order-by.d.ts +15 -0
  164. package/dist/src/functions/order-by.d.ts.map +1 -0
  165. package/dist/src/functions/order-by.js +19 -0
  166. package/dist/src/functions/order-by.js.map +1 -0
  167. package/dist/src/functions/spatial.d.ts +32 -0
  168. package/dist/src/functions/spatial.d.ts.map +1 -0
  169. package/dist/src/functions/spatial.js +44 -0
  170. package/dist/src/functions/spatial.js.map +1 -0
  171. package/dist/src/functions/sql-template-tag.d.ts +13 -0
  172. package/dist/src/functions/sql-template-tag.d.ts.map +1 -0
  173. package/dist/src/functions/sql-template-tag.js +44 -0
  174. package/dist/src/functions/sql-template-tag.js.map +1 -0
  175. package/dist/src/functions/string.d.ts +49 -0
  176. package/dist/src/functions/string.d.ts.map +1 -0
  177. package/dist/src/functions/string.js +67 -0
  178. package/dist/src/functions/string.js.map +1 -0
  179. package/dist/src/functions/table-ref.d.ts +10 -0
  180. package/dist/src/functions/table-ref.d.ts.map +1 -0
  181. package/dist/src/functions/table-ref.js +13 -0
  182. package/dist/src/functions/table-ref.js.map +1 -0
  183. package/dist/src/functions/util.d.ts +7 -0
  184. package/dist/src/functions/util.d.ts.map +1 -0
  185. package/dist/src/functions/util.js +9 -0
  186. package/dist/src/functions/util.js.map +1 -0
  187. package/dist/src/functions/window-frame.d.ts +41 -0
  188. package/dist/src/functions/window-frame.d.ts.map +1 -0
  189. package/dist/src/functions/window-frame.js +52 -0
  190. package/dist/src/functions/window-frame.js.map +1 -0
  191. package/dist/src/functions/window.d.ts +74 -0
  192. package/dist/src/functions/window.d.ts.map +1 -0
  193. package/dist/src/functions/window.js +96 -0
  194. package/dist/src/functions/window.js.map +1 -0
  195. package/dist/src/index.d.ts +69 -0
  196. package/dist/src/index.d.ts.map +1 -0
  197. package/{src → dist/src}/index.js +4 -8
  198. package/dist/src/index.js.map +1 -0
  199. package/dist/src/load/create.d.ts +10 -0
  200. package/dist/src/load/create.d.ts.map +1 -0
  201. package/dist/src/load/create.js +14 -0
  202. package/dist/src/load/create.js.map +1 -0
  203. package/dist/src/load/extension.d.ts +2 -0
  204. package/dist/src/load/extension.d.ts.map +1 -0
  205. package/dist/src/load/extension.js +4 -0
  206. package/dist/src/load/extension.js.map +1 -0
  207. package/dist/src/load/load.d.ts +18 -0
  208. package/dist/src/load/load.d.ts.map +1 -0
  209. package/dist/src/load/load.js +80 -0
  210. package/dist/src/load/load.js.map +1 -0
  211. package/dist/src/load/sql-from.d.ts +14 -0
  212. package/dist/src/load/sql-from.d.ts.map +1 -0
  213. package/dist/src/load/sql-from.js +29 -0
  214. package/dist/src/load/sql-from.js.map +1 -0
  215. package/dist/src/transforms/bin-1d.d.ts +16 -0
  216. package/dist/src/transforms/bin-1d.d.ts.map +1 -0
  217. package/dist/src/transforms/bin-1d.js +21 -0
  218. package/dist/src/transforms/bin-1d.js.map +1 -0
  219. package/dist/src/transforms/bin-2d.d.ts +19 -0
  220. package/dist/src/transforms/bin-2d.d.ts.map +1 -0
  221. package/dist/src/transforms/bin-2d.js +27 -0
  222. package/dist/src/transforms/bin-2d.js.map +1 -0
  223. package/dist/src/transforms/bin-date.d.ts +31 -0
  224. package/dist/src/transforms/bin-date.d.ts.map +1 -0
  225. package/dist/src/transforms/bin-date.js +20 -0
  226. package/dist/src/transforms/bin-date.js.map +1 -0
  227. package/dist/src/transforms/bin-histogram.d.ts +37 -0
  228. package/dist/src/transforms/bin-histogram.d.ts.map +1 -0
  229. package/dist/src/transforms/bin-histogram.js +32 -0
  230. package/dist/src/transforms/bin-histogram.js.map +1 -0
  231. package/dist/src/transforms/bin-linear-1d.d.ts +11 -0
  232. package/dist/src/transforms/bin-linear-1d.d.ts.map +1 -0
  233. package/dist/src/transforms/bin-linear-1d.js +25 -0
  234. package/dist/src/transforms/bin-linear-1d.js.map +1 -0
  235. package/dist/src/transforms/bin-linear-2d.d.ts +20 -0
  236. package/dist/src/transforms/bin-linear-2d.d.ts.map +1 -0
  237. package/dist/src/transforms/bin-linear-2d.js +49 -0
  238. package/dist/src/transforms/bin-linear-2d.js.map +1 -0
  239. package/dist/src/transforms/filter-query.d.ts +12 -0
  240. package/dist/src/transforms/filter-query.d.ts.map +1 -0
  241. package/dist/src/transforms/filter-query.js +39 -0
  242. package/dist/src/transforms/filter-query.js.map +1 -0
  243. package/dist/src/transforms/line-density.d.ts +24 -0
  244. package/dist/src/transforms/line-density.d.ts.map +1 -0
  245. package/dist/src/transforms/line-density.js +98 -0
  246. package/dist/src/transforms/line-density.js.map +1 -0
  247. package/dist/src/transforms/m4.d.ts +19 -0
  248. package/dist/src/transforms/m4.d.ts.map +1 -0
  249. package/dist/src/transforms/m4.js +38 -0
  250. package/dist/src/transforms/m4.js.map +1 -0
  251. package/dist/src/transforms/scales.d.ts +30 -0
  252. package/dist/src/transforms/scales.d.ts.map +1 -0
  253. package/dist/src/transforms/scales.js +103 -0
  254. package/dist/src/transforms/scales.js.map +1 -0
  255. package/dist/src/transforms/util/bin-step.d.ts +50 -0
  256. package/dist/src/transforms/util/bin-step.d.ts.map +1 -0
  257. package/dist/src/transforms/util/bin-step.js +53 -0
  258. package/dist/src/transforms/util/bin-step.js.map +1 -0
  259. package/dist/src/transforms/util/time-interval.d.ts +14 -0
  260. package/dist/src/transforms/util/time-interval.d.ts.map +1 -0
  261. package/dist/src/transforms/util/time-interval.js +88 -0
  262. package/dist/src/transforms/util/time-interval.js.map +1 -0
  263. package/dist/src/types.d.ts +49 -0
  264. package/dist/src/types.d.ts.map +1 -0
  265. package/dist/src/types.js +2 -0
  266. package/dist/src/types.js.map +1 -0
  267. package/dist/src/util/ast.d.ts +62 -0
  268. package/dist/src/util/ast.d.ts.map +1 -0
  269. package/{src → dist/src}/util/ast.js +36 -41
  270. package/dist/src/util/ast.js.map +1 -0
  271. package/dist/src/util/function.d.ts +56 -0
  272. package/dist/src/util/function.d.ts.map +1 -0
  273. package/dist/src/util/function.js +73 -0
  274. package/dist/src/util/function.js.map +1 -0
  275. package/dist/src/util/identity.d.ts +6 -0
  276. package/dist/src/util/identity.d.ts.map +1 -0
  277. package/dist/src/util/identity.js +8 -0
  278. package/dist/src/util/identity.js.map +1 -0
  279. package/dist/src/util/string.d.ts +4 -0
  280. package/dist/src/util/string.d.ts.map +1 -0
  281. package/dist/src/util/string.js +14 -0
  282. package/dist/src/util/string.js.map +1 -0
  283. package/dist/src/util/type-check.d.ts +17 -0
  284. package/dist/src/util/type-check.d.ts.map +1 -0
  285. package/dist/src/util/type-check.js +28 -0
  286. package/dist/src/util/type-check.js.map +1 -0
  287. package/dist/src/visit/clone.d.ts +7 -0
  288. package/dist/src/visit/clone.d.ts.map +1 -0
  289. package/dist/src/visit/clone.js +52 -0
  290. package/dist/src/visit/clone.js.map +1 -0
  291. package/dist/src/visit/recurse.d.ts +2 -0
  292. package/dist/src/visit/recurse.d.ts.map +1 -0
  293. package/dist/src/visit/recurse.js +36 -0
  294. package/dist/src/visit/recurse.js.map +1 -0
  295. package/dist/src/visit/rewrite.d.ts +9 -0
  296. package/dist/src/visit/rewrite.d.ts.map +1 -0
  297. package/dist/src/visit/rewrite.js +39 -0
  298. package/dist/src/visit/rewrite.js.map +1 -0
  299. package/dist/src/visit/visitors.d.ts +32 -0
  300. package/dist/src/visit/visitors.d.ts.map +1 -0
  301. package/dist/src/visit/visitors.js +95 -0
  302. package/dist/src/visit/visitors.js.map +1 -0
  303. package/dist/src/visit/walk.d.ts +21 -0
  304. package/dist/src/visit/walk.d.ts.map +1 -0
  305. package/dist/src/visit/walk.js +32 -0
  306. package/dist/src/visit/walk.js.map +1 -0
  307. package/package.json +13 -7
  308. package/src/ast/{aggregate.js → aggregate.ts} +49 -60
  309. package/src/ast/{between-op.js → between-op.ts} +19 -26
  310. package/src/ast/binary-op.ts +31 -0
  311. package/src/ast/{case.js → case.ts} +29 -44
  312. package/src/ast/{cast.js → cast.ts} +8 -14
  313. package/src/ast/{collate.js → collate.ts} +8 -14
  314. package/src/ast/column-param.ts +34 -0
  315. package/src/ast/{column-ref.js → column-ref.ts} +16 -25
  316. package/src/ast/fragment.ts +28 -0
  317. package/src/ast/{from.js → from.ts} +12 -21
  318. package/src/ast/{function.js → function.ts} +8 -14
  319. package/src/ast/{in-op.js → in-op.ts} +8 -14
  320. package/src/ast/{interval.js → interval.ts} +8 -14
  321. package/src/ast/{literal.js → literal.ts} +6 -9
  322. package/src/ast/logical-op.ts +50 -0
  323. package/src/ast/{node.js → node.ts} +10 -13
  324. package/src/ast/order-by.ts +38 -0
  325. package/src/ast/{param.js → param.ts} +6 -12
  326. package/src/ast/{query.js → query.ts} +159 -203
  327. package/src/ast/sample.ts +47 -0
  328. package/src/ast/{select.js → select.ts} +10 -16
  329. package/src/ast/{subquery.js → subquery.ts} +9 -8
  330. package/src/ast/{table-ref.js → table-ref.ts} +7 -12
  331. package/src/ast/{unary-op.js → unary-op.ts} +16 -23
  332. package/src/ast/verbatim.ts +27 -0
  333. package/src/ast/{window-frame.js → window-frame.ts} +37 -47
  334. package/src/ast/window.ts +246 -0
  335. package/src/ast/{with.js → with.ts} +19 -20
  336. package/src/functions/aggregate.ts +344 -0
  337. package/src/functions/{case.js → case.ts} +5 -8
  338. package/src/functions/{cast.js → cast.ts} +9 -13
  339. package/src/functions/{collate.js → collate.ts} +4 -7
  340. package/src/functions/{column.js → column.ts} +9 -10
  341. package/src/functions/{cte.js → cte.ts} +9 -6
  342. package/src/functions/{datetime.js → datetime.ts} +12 -20
  343. package/src/functions/interval.ts +74 -0
  344. package/src/functions/{literal.js → literal.ts} +5 -7
  345. package/src/functions/numeric.ts +125 -0
  346. package/src/functions/operators.ts +272 -0
  347. package/src/functions/order-by.ts +21 -0
  348. package/src/functions/spatial.ts +50 -0
  349. package/src/functions/{sql-template-tag.js → sql-template-tag.ts} +16 -13
  350. package/src/functions/string.ts +79 -0
  351. package/src/functions/{table-ref.js → table-ref.ts} +4 -4
  352. package/src/functions/util.ts +10 -0
  353. package/src/functions/window-frame.ts +58 -0
  354. package/src/functions/{window.js → window.ts} +18 -35
  355. package/src/index.ts +75 -0
  356. package/src/load/{create.js → create.ts} +9 -3
  357. package/src/load/extension.ts +3 -0
  358. package/src/load/{load.js → load.ts} +25 -10
  359. package/src/load/{sql-from.js → sql-from.ts} +14 -7
  360. package/src/transforms/{bin-1d.js → bin-1d.ts} +13 -9
  361. package/src/transforms/{bin-2d.js → bin-2d.ts} +17 -13
  362. package/src/transforms/bin-date.ts +48 -0
  363. package/src/transforms/bin-histogram.ts +61 -0
  364. package/src/transforms/{bin-linear-1d.js → bin-linear-1d.ts} +16 -11
  365. package/src/transforms/{bin-linear-2d.js → bin-linear-2d.ts} +23 -35
  366. package/src/transforms/{filter-query.js → filter-query.ts} +10 -14
  367. package/src/transforms/{line-density.js → line-density.ts} +19 -17
  368. package/src/transforms/{m4.js → m4.ts} +17 -14
  369. package/src/transforms/{scales.js → scales.ts} +57 -14
  370. package/src/transforms/util/bin-step.ts +100 -0
  371. package/src/transforms/util/{time-interval.js → time-interval.ts} +32 -21
  372. package/src/types.ts +5 -39
  373. package/src/util/ast.ts +104 -0
  374. package/src/util/{function.js → function.ts} +40 -31
  375. package/src/util/identity.ts +7 -0
  376. package/src/util/{string.js → string.ts} +4 -4
  377. package/src/util/type-check.ts +31 -0
  378. package/src/visit/{clone.js → clone.ts} +10 -10
  379. package/src/visit/{recurse.js → recurse.ts} +1 -1
  380. package/src/visit/{rewrite.js → rewrite.ts} +7 -7
  381. package/src/visit/{visitors.js → visitors.ts} +22 -30
  382. package/src/visit/walk.ts +46 -0
  383. package/src/ast/binary-op.js +0 -40
  384. package/src/ast/column-param.js +0 -40
  385. package/src/ast/fragment.js +0 -26
  386. package/src/ast/logical-op.js +0 -67
  387. package/src/ast/order-by.js +0 -48
  388. package/src/ast/sample.js +0 -53
  389. package/src/ast/verbatim.js +0 -33
  390. package/src/ast/window.js +0 -260
  391. package/src/functions/aggregate.js +0 -347
  392. package/src/functions/interval.js +0 -83
  393. package/src/functions/numeric.js +0 -143
  394. package/src/functions/operators.js +0 -301
  395. package/src/functions/order-by.js +0 -27
  396. package/src/functions/spatial.js +0 -59
  397. package/src/functions/string.js +0 -85
  398. package/src/functions/util.js +0 -14
  399. package/src/functions/window-frame.js +0 -61
  400. package/src/index-types.ts +0 -2
  401. package/src/load/extension.js +0 -3
  402. package/src/transforms/bin-date.js +0 -38
  403. package/src/transforms/bin-histogram.js +0 -52
  404. package/src/transforms/util/bin-step.js +0 -79
  405. package/src/util/type-check.js +0 -33
  406. package/src/visit/walk.js +0 -34
  407. package/tsconfig.json +0 -8
  408. package/vitest.config.ts +0 -3
  409. /package/src/{constants.js → constants.ts} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,47 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023-2025, UW Interactive Data Lab
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ ---
31
+
32
+ Portions of this software are derived from Observable Plot, which is released
33
+ under the ISC license.
34
+
35
+ Copyright 2020-2023 Observable, Inc.
36
+
37
+ Permission to use, copy, modify, and/or distribute this software for any purpose
38
+ with or without fee is hereby granted, provided that the above copyright notice
39
+ and this permission notice appear in all copies.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
42
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
43
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
44
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
46
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
47
+ THIS SOFTWARE.
package/README.md CHANGED
@@ -3,5 +3,3 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@uwdata/mosaic-sql.svg)](https://www.npmjs.com/package/@uwdata/mosaic-sql)
4
4
 
5
5
  An API for convenient construction and analysis of SQL queries. Constructed `Query` objects coerce to SQL query strings.
6
-
7
- Many `mosaic-sql` utilities are included as part of the [vgplot](https://github.com/uwdata/mosaic/tree/main/packages/vgplot) API.
@@ -0,0 +1,82 @@
1
+ import type { ExprVarArgs, OrderByExpr } from '../types.js';
2
+ import type { WindowFrameNode } from './window-frame.js';
3
+ import { ExprNode } from './node.js';
4
+ import { WindowNode } from './window.js';
5
+ export declare class AggregateNode extends ExprNode {
6
+ /** The aggregate function name. */
7
+ readonly name: string;
8
+ /** The aggregate function arguments. */
9
+ readonly args: ExprNode[];
10
+ /** The distinct flag. */
11
+ readonly isDistinct: boolean;
12
+ /** Filter criteria. */
13
+ readonly filter: ExprNode | null;
14
+ /** Order by expression for order-sensitive aggregates. */
15
+ readonly order: ExprNode[];
16
+ /**
17
+ * Instantiate an aggregate function node.
18
+ * @param name The aggregate function name.
19
+ * @param args The aggregate function arguments.
20
+ * @param distinct The distinct flag.
21
+ * @param filter Filter expression.
22
+ * @param argOrder Order by expression.
23
+ */
24
+ constructor(name: string, args: ExprNode[], distinct?: boolean, filter?: ExprNode | null, argOrder?: OrderByExpr);
25
+ /**
26
+ * Return a new derived aggregate over distinct values.
27
+ * @param isDistinct The distinct flag.
28
+ * @returns A new aggregate node.
29
+ */
30
+ distinct(isDistinct?: boolean): AggregateNode;
31
+ /**
32
+ * Return a new derived aggregate function that filters values.
33
+ * @param The filter expression.
34
+ * @returns A new aggregate node.
35
+ */
36
+ where(filter: ExprNode | string): AggregateNode;
37
+ /**
38
+ * Return a new derived aggregate function that sorts values prior to aggregation.
39
+ * @param order The order by expression.
40
+ * @returns A new aggregate node.
41
+ */
42
+ argOrder(order: OrderByExpr): AggregateNode;
43
+ /**
44
+ * Return a new window function over this aggregate.
45
+ * @returns A new window node.
46
+ */
47
+ window(): WindowNode;
48
+ /**
49
+ * Return a new window function over this aggregate with the given partitions.
50
+ * @param expr The partition by criteria.
51
+ * @returns A new window node.
52
+ */
53
+ partitionby(...expr: ExprVarArgs[]): WindowNode;
54
+ /**
55
+ * Return a new window function over this aggregate with the given ordering.
56
+ * @param expr The order by criteria.
57
+ * @returns A new window node.
58
+ */
59
+ orderby(...expr: ExprVarArgs[]): WindowNode;
60
+ /**
61
+ * Return a new window function over this aggregate with the given frame.
62
+ * @param framedef The window frame definition.
63
+ * @returns A new window node.
64
+ */
65
+ frame(framedef: WindowFrameNode): WindowNode;
66
+ /**
67
+ * Generate a SQL query string for this node.
68
+ */
69
+ toString(): string;
70
+ }
71
+ /**
72
+ * Check if a function name corresponds to an aggregate function.
73
+ * @param name The function name to check
74
+ * @returns True if a known aggregate function, false otherwise.
75
+ */
76
+ export declare function isAggregateFunction(name: string): boolean;
77
+ /**
78
+ * An array of known aggregate function names.
79
+ * From https://duckdb.org/docs/sql/functions/aggregates.html.
80
+ */
81
+ export declare const aggregateNames: string[];
82
+ //# sourceMappingURL=aggregate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../../src/ast/aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,qBAAa,aAAc,SAAQ,QAAQ;IACzC,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC1B,yBAAyB;IACzB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,uBAAuB;IACvB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAE3B;;;;;;;OAOG;gBAED,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EAAE,EAChB,QAAQ,GAAE,OAAe,EACzB,MAAM,GAAE,QAAQ,GAAG,IAAW,EAC9B,QAAQ,GAAE,WAAgB;IAU5B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,GAAE,OAAc;IAInC;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM;IAK/B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW;IAI3B;;;OAGG;IACH,MAAM;IAIN;;;;OAIG;IACH,WAAW,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE;IAIlC;;;;OAIG;IACH,OAAO,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE;IAI9B;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,eAAe;IAI/B;;OAEG;IACH,QAAQ;CAYT;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,WAE/C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,UA4D1B,CAAC"}
@@ -0,0 +1,180 @@
1
+ import { AGGREGATE } from '../constants.js';
2
+ import { asVerbatim } from '../util/ast.js';
3
+ import { nodeList } from '../util/function.js';
4
+ import { isString } from '../util/type-check.js';
5
+ import { ExprNode } from './node.js';
6
+ import { WindowNode } from './window.js';
7
+ export class AggregateNode extends ExprNode {
8
+ /** The aggregate function name. */
9
+ name;
10
+ /** The aggregate function arguments. */
11
+ args;
12
+ /** The distinct flag. */
13
+ isDistinct;
14
+ /** Filter criteria. */
15
+ filter;
16
+ /** Order by expression for order-sensitive aggregates. */
17
+ order;
18
+ /**
19
+ * Instantiate an aggregate function node.
20
+ * @param name The aggregate function name.
21
+ * @param args The aggregate function arguments.
22
+ * @param distinct The distinct flag.
23
+ * @param filter Filter expression.
24
+ * @param argOrder Order by expression.
25
+ */
26
+ constructor(name, args, distinct = false, filter = null, argOrder = []) {
27
+ super(AGGREGATE);
28
+ this.name = name;
29
+ this.args = args;
30
+ this.isDistinct = distinct;
31
+ this.filter = filter;
32
+ this.order = nodeList([argOrder]);
33
+ }
34
+ /**
35
+ * Return a new derived aggregate over distinct values.
36
+ * @param isDistinct The distinct flag.
37
+ * @returns A new aggregate node.
38
+ */
39
+ distinct(isDistinct = true) {
40
+ return new AggregateNode(this.name, this.args, isDistinct, this.filter, this.order);
41
+ }
42
+ /**
43
+ * Return a new derived aggregate function that filters values.
44
+ * @param The filter expression.
45
+ * @returns A new aggregate node.
46
+ */
47
+ where(filter) {
48
+ if (isString(filter))
49
+ filter = asVerbatim(filter);
50
+ return new AggregateNode(this.name, this.args, this.isDistinct, filter, this.order);
51
+ }
52
+ /**
53
+ * Return a new derived aggregate function that sorts values prior to aggregation.
54
+ * @param order The order by expression.
55
+ * @returns A new aggregate node.
56
+ */
57
+ argOrder(order) {
58
+ return new AggregateNode(this.name, this.args, this.isDistinct, this.filter, order);
59
+ }
60
+ /**
61
+ * Return a new window function over this aggregate.
62
+ * @returns A new window node.
63
+ */
64
+ window() {
65
+ return new WindowNode(this);
66
+ }
67
+ /**
68
+ * Return a new window function over this aggregate with the given partitions.
69
+ * @param expr The partition by criteria.
70
+ * @returns A new window node.
71
+ */
72
+ partitionby(...expr) {
73
+ return this.window().partitionby(...expr);
74
+ }
75
+ /**
76
+ * Return a new window function over this aggregate with the given ordering.
77
+ * @param expr The order by criteria.
78
+ * @returns A new window node.
79
+ */
80
+ orderby(...expr) {
81
+ return this.window().orderby(...expr);
82
+ }
83
+ /**
84
+ * Return a new window function over this aggregate with the given frame.
85
+ * @param framedef The window frame definition.
86
+ * @returns A new window node.
87
+ */
88
+ frame(framedef) {
89
+ return this.window().frame(framedef);
90
+ }
91
+ /**
92
+ * Generate a SQL query string for this node.
93
+ */
94
+ toString() {
95
+ const { name, args, isDistinct, filter, order } = this;
96
+ const arg = [
97
+ isDistinct ? 'DISTINCT' : '',
98
+ args?.length ? args.join(', ')
99
+ : name.toLowerCase() === 'count' ? '*'
100
+ : '',
101
+ order.length ? `ORDER BY ${order.join(', ')}` : ''
102
+ ].filter(x => x).join(' ');
103
+ const filt = filter ? ` FILTER (WHERE ${filter})` : '';
104
+ return `${name}(${arg})${filt}`;
105
+ }
106
+ }
107
+ /**
108
+ * Check if a function name corresponds to an aggregate function.
109
+ * @param name The function name to check
110
+ * @returns True if a known aggregate function, false otherwise.
111
+ */
112
+ export function isAggregateFunction(name) {
113
+ return aggregateNames.includes(name.toLowerCase());
114
+ }
115
+ /**
116
+ * An array of known aggregate function names.
117
+ * From https://duckdb.org/docs/sql/functions/aggregates.html.
118
+ */
119
+ export const aggregateNames = [
120
+ 'any_value',
121
+ 'approx_count_distinct',
122
+ 'approx_quantile',
123
+ 'arbitrary',
124
+ 'arg_max',
125
+ 'arg_max_null',
126
+ 'arg_min',
127
+ 'arg_min_null',
128
+ 'array_agg',
129
+ 'avg',
130
+ 'bit_and',
131
+ 'bit_or',
132
+ 'bit_xor',
133
+ 'bitstring_agg',
134
+ 'bool_and',
135
+ 'bool_or',
136
+ 'corr',
137
+ 'count',
138
+ 'count_star',
139
+ 'covar_pop',
140
+ 'covar_samp',
141
+ 'entropy',
142
+ 'favg',
143
+ 'first',
144
+ 'fsum',
145
+ 'geomean',
146
+ 'kurtosis_pop',
147
+ 'kurtosis',
148
+ 'last',
149
+ 'mad',
150
+ 'max',
151
+ 'max_by',
152
+ 'median',
153
+ 'min',
154
+ 'min_by',
155
+ 'mode',
156
+ 'product',
157
+ 'quantile',
158
+ 'quantile_cont',
159
+ 'quantile_disc',
160
+ 'regr_avgx',
161
+ 'regr_avgy',
162
+ 'regr_count',
163
+ 'regr_intercept',
164
+ 'regr_r2',
165
+ 'regr_sxx',
166
+ 'regr_sxy',
167
+ 'regr_syy',
168
+ 'regr_slope',
169
+ 'reservoir_quantile',
170
+ 'skewness',
171
+ 'stddev',
172
+ 'stddev_pop',
173
+ 'stddev_samp',
174
+ 'string_agg',
175
+ 'sum',
176
+ 'variance',
177
+ 'var_pop',
178
+ 'var_samp'
179
+ ];
180
+ //# sourceM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Y;IACZ,oBAAoB;IACpB,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,KAAK;IACL,UAAU;IACV,SAAS;IACT,UAAU;CACX,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { ExprNode } from './node.js';
2
+ export type Extent = [ExprNode, ExprNode] | null;
3
+ declare class AbstractBetweenOpNode extends ExprNode {
4
+ /** The input expression. */
5
+ readonly expr: ExprNode;
6
+ /** The range extent. */
7
+ readonly extent?: Extent;
8
+ /**
9
+ * Instantiate an abstract between operator node.
10
+ * @param type The node type.
11
+ * @param expr The input expression.
12
+ * @param extent The range extent.
13
+ */
14
+ constructor(type: string, expr: ExprNode, extent?: Extent);
15
+ /**
16
+ * Generate a SQL query string for this node.
17
+ * @param op The operator to apply.
18
+ */
19
+ toSQL(op: string): string;
20
+ }
21
+ export declare class BetweenOpNode extends AbstractBetweenOpNode {
22
+ /**
23
+ * Instantiate a between operator node.
24
+ * @param expr The input expression.
25
+ * @param extent The range extent.
26
+ */
27
+ constructor(expr: ExprNode, extent?: Extent);
28
+ /**
29
+ * Generate a SQL query string for this node.
30
+ */
31
+ toString(): string;
32
+ }
33
+ export declare class NotBetweenOpNode extends AbstractBetweenOpNode {
34
+ /**
35
+ * Instantiate a not between operator node.
36
+ * @param expr The input expression.
37
+ * @param extent The range extent.
38
+ */
39
+ constructor(expr: ExprNode, extent?: Extent);
40
+ /**
41
+ * Generate a SQL query string for this node.
42
+ */
43
+ toString(): string;
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=between-op.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"between-op.d.ts","sourceRoot":"","sources":["../../../src/ast/between-op.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;AAEjD,cAAM,qBAAsB,SAAQ,QAAQ;IAC1C,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,wBAAwB;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM;IAMzD;;;OAGG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM;CAIjB;AAED,qBAAa,aAAc,SAAQ,qBAAqB;IACtD;;;;OAIG;gBACS,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM;IAI3C;;OAEG;IACH,QAAQ;CAGT;AAED,qBAAa,gBAAiB,SAAQ,qBAAqB;IACzD;;;;OAIG;gBACS,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM;IAI3C;;OAEG;IACH,QAAQ;CAGT"}
@@ -0,0 +1,60 @@
1
+ import { BETWEEN_OPERATOR, NOT_BETWEEN_OPERATOR } from '../constants.js';
2
+ import { ExprNode } from './node.js';
3
+ class AbstractBetweenOpNode extends ExprNode {
4
+ /** The input expression. */
5
+ expr;
6
+ /** The range extent. */
7
+ extent;
8
+ /**
9
+ * Instantiate an abstract between operator node.
10
+ * @param type The node type.
11
+ * @param expr The input expression.
12
+ * @param extent The range extent.
13
+ */
14
+ constructor(type, expr, extent) {
15
+ super(type);
16
+ this.expr = expr;
17
+ this.extent = extent;
18
+ }
19
+ /**
20
+ * Generate a SQL query string for this node.
21
+ * @param op The operator to apply.
22
+ */
23
+ toSQL(op) {
24
+ const { extent: r, expr } = this;
25
+ return r ? `(${expr} ${op} ${r[0]} AND ${r[1]})` : '';
26
+ }
27
+ }
28
+ export class BetweenOpNode extends AbstractBetweenOpNode {
29
+ /**
30
+ * Instantiate a between operator node.
31
+ * @param expr The input expression.
32
+ * @param extent The range extent.
33
+ */
34
+ constructor(expr, extent) {
35
+ super(BETWEEN_OPERATOR, expr, extent);
36
+ }
37
+ /**
38
+ * Generate a SQL query string for this node.
39
+ */
40
+ toString() {
41
+ return super.toSQL('BETWEEN');
42
+ }
43
+ }
44
+ export class NotBetweenOpNode extends AbstractBetweenOpNode {
45
+ /**
46
+ * Instantiate a not between operator node.
47
+ * @param expr The input expression.
48
+ * @param extent The range extent.
49
+ */
50
+ constructor(expr, extent) {
51
+ super(NOT_BETWEEN_OPERATOR, expr, extent);
52
+ }
53
+ /**
54
+ * Generate a SQL query string for this node.
55
+ */
56
+ toString() {
57
+ return super.toSQL('NOT BETWEEN');
58
+ }
59
+ }
60
+ //# sourceMappingURL=between-op.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"between-op.js","sourceRoot":"","sources":["../../../src/ast/between-op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAIrC,MAAM,qBAAsB,SAAQ,QAAQ;IAC1C,4BAA4B;IACnB,IAAI,CAAW;IACxB,wBAAwB;IACf,MAAM,CAAU;IAEzB;;;;;OAKG;IACH,YAAY,IAAY,EAAE,IAAc,EAAE,MAAe;QACvD,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,EAAU;QACd,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACjC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,qBAAqB;IACtD;;;;OAIG;IACH,YAAY,IAAc,EAAE,MAAe;QACzC,KAAK,CAAC,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,qBAAqB;IACzD;;;;OAIG;IACH,YAAY,IAAc,EAAE,MAAe;QACzC,KAAK,CAAC,oBAAoB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { ExprNode } from './node.js';
2
+ export declare class BinaryOpNode extends ExprNode {
3
+ /** The operator type. */
4
+ readonly op: string;
5
+ /** The left input expression. */
6
+ readonly left: ExprNode;
7
+ /** The right input expression. */
8
+ readonly right: ExprNode;
9
+ /**
10
+ * Instantiate a binary operator node.
11
+ * @param op The operator type.
12
+ * @param left The left input expression.
13
+ * @param right The right input expression.
14
+ */
15
+ constructor(op: string, left: ExprNode, right: ExprNode);
16
+ /**
17
+ * Generate a SQL query string for this node.
18
+ */
19
+ toString(): string;
20
+ }
21
+ //# sourceMappingURL=binary-op.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-op.d.ts","sourceRoot":"","sources":["../../../src/ast/binary-op.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,YAAa,SAAQ,QAAQ;IACxC,yBAAyB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAEzB;;;;;OAKG;gBACS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ;IAOvD;;OAEG;IACH,QAAQ;CAGT"}
@@ -0,0 +1,29 @@
1
+ import { BINARY_OPERATOR } from '../constants.js';
2
+ import { ExprNode } from './node.js';
3
+ export class BinaryOpNode extends ExprNode {
4
+ /** The operator type. */
5
+ op;
6
+ /** The left input expression. */
7
+ left;
8
+ /** The right input expression. */
9
+ right;
10
+ /**
11
+ * Instantiate a binary operator node.
12
+ * @param op The operator type.
13
+ * @param left The left input expression.
14
+ * @param right The right input expression.
15
+ */
16
+ constructor(op, left, right) {
17
+ super(BINARY_OPERATOR);
18
+ this.op = op;
19
+ this.left = left;
20
+ this.right = right;
21
+ }
22
+ /**
23
+ * Generate a SQL query string for this node.
24
+ */
25
+ toString() {
26
+ return `(${this.left} ${this.op} ${this.right})`;
27
+ }
28
+ }
29
+ //# sourceMappingURL=binary-op.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-op.js","sourceRoot":"","sources":["../../../src/ast/binary-op.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAO,YAAa,SAAQ,QAAQ;IACxC,yBAAyB;IAChB,EAAE,CAAS;IACpB,iCAAiC;IACxB,IAAI,CAAW;IACxB,kCAAkC;IACzB,KAAK,CAAW;IAEzB;;;;;OAKG;IACH,YAAY,EAAU,EAAE,IAAc,EAAE,KAAe;QACrD,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC;IACnD,CAAC;CACF"}
@@ -0,0 +1,53 @@
1
+ import { ExprValue } from '../types.js';
2
+ import { ExprNode, SQLNode } from './node.js';
3
+ export declare class CaseNode extends ExprNode {
4
+ /** The optional base expression. */
5
+ readonly expr?: ExprNode;
6
+ /** An array of WHEN/THEN expression nodes. */
7
+ readonly _when: WhenNode[];
8
+ /** An ELSE expression. */
9
+ readonly _else?: ExprNode;
10
+ /**
11
+ * Instantiate a case node.
12
+ * @param expr An optional base expression, that comes
13
+ * immediately after the CASE keyword. If specified, this case statement
14
+ * acts like a switch statement, with WHEN expressions as values to
15
+ * match against the switch value rather than boolean conditions.
16
+ * @param when An array of WHEN/THEN expression nodes.
17
+ * @param elseExpr An ELSE expression.
18
+ */
19
+ constructor(expr?: ExprNode | undefined, when?: WhenNode[], elseExpr?: ExprNode | undefined);
20
+ /**
21
+ * Return a new case node with the given conditional added as
22
+ * the last WHEN / THEN pair.
23
+ * @param cond The WHEN condition expression.
24
+ * @param value The THEN value expression.
25
+ */
26
+ when(cond: ExprValue, value: ExprValue): CaseNode;
27
+ /**
28
+ * Return a new case node with the given ELSE expression.
29
+ * @param expr The ELSE expression.
30
+ */
31
+ else(expr: ExprValue): CaseNode;
32
+ /**
33
+ * Generate a SQL query string for this node.
34
+ */
35
+ toString(): string;
36
+ }
37
+ export declare class WhenNode extends SQLNode {
38
+ /** The condition expression. */
39
+ readonly when: ExprNode;
40
+ /** The value expression. */
41
+ readonly then: ExprNode;
42
+ /**
43
+ * Instantiate a case node.
44
+ * @param when The WHEN condition expression.
45
+ * @param then The THEN value expression.
46
+ */
47
+ constructor(when: ExprNode, then: ExprNode);
48
+ /**
49
+ * Generate a SQL query string for this node.
50
+ */
51
+ toString(): string;
52
+ }
53
+ //# sourceMappingURL=case.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"case.d.ts","sourceRoot":"","sources":["../../../src/ast/case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,qBAAa,QAAS,SAAQ,QAAQ;IACpC,oCAAoC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC3B,0BAA0B;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC;IAE1B;;;;;;;;OAQG;gBAED,IAAI,GAAE,QAAQ,GAAG,SAAqB,EACtC,IAAI,GAAE,QAAQ,EAAO,EACrB,QAAQ,GAAE,QAAQ,GAAG,SAAqB;IAQ5C;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS;IAQtC;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,SAAS;IAIpB;;OAEG;IACH,QAAQ;CAOT;AAED,qBAAa,QAAS,SAAQ,OAAO;IACnC,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAExB;;;;OAIG;gBACS,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ;IAM1C;;OAEG;IACH,QAAQ;CAGT"}
@@ -0,0 +1,75 @@
1
+ import { CASE, WHEN } from '../constants.js';
2
+ import { asNode } from '../util/ast.js';
3
+ import { ExprNode, SQLNode } from './node.js';
4
+ export class CaseNode extends ExprNode {
5
+ /** The optional base expression. */
6
+ expr;
7
+ /** An array of WHEN/THEN expression nodes. */
8
+ _when;
9
+ /** An ELSE expression. */
10
+ _else;
11
+ /**
12
+ * Instantiate a case node.
13
+ * @param expr An optional base expression, that comes
14
+ * immediately after the CASE keyword. If specified, this case statement
15
+ * acts like a switch statement, with WHEN expressions as values to
16
+ * match against the switch value rather than boolean conditions.
17
+ * @param when An array of WHEN/THEN expression nodes.
18
+ * @param elseExpr An ELSE expression.
19
+ */
20
+ constructor(expr = undefined, when = [], elseExpr = undefined) {
21
+ super(CASE);
22
+ this.expr = expr;
23
+ this._when = when;
24
+ this._else = elseExpr;
25
+ }
26
+ /**
27
+ * Return a new case node with the given conditional added as
28
+ * the last WHEN / THEN pair.
29
+ * @param cond The WHEN condition expression.
30
+ * @param value The THEN value expression.
31
+ */
32
+ when(cond, value) {
33
+ return new CaseNode(this.expr, this._when.concat(new WhenNode(asNode(cond), asNode(value))), this._else);
34
+ }
35
+ /**
36
+ * Return a new case node with the given ELSE expression.
37
+ * @param expr The ELSE expression.
38
+ */
39
+ else(expr) {
40
+ return new CaseNode(this.expr, this._when, asNode(expr));
41
+ }
42
+ /**
43
+ * Generate a SQL query string for this node.
44
+ */
45
+ toString() {
46
+ return 'CASE '
47
+ + (this.expr ? `${this.expr} ` : '')
48
+ + this._when.join(' ')
49
+ + (this._else ? ` ELSE ${this._else}` : '')
50
+ + ' END';
51
+ }
52
+ }
53
+ export class WhenNode extends SQLNode {
54
+ /** The condition expression. */
55
+ when;
56
+ /** The value expression. */
57
+ then;
58
+ /**
59
+ * Instantiate a case node.
60
+ * @param when The WHEN condition expression.
61
+ * @param then The THEN value expression.
62
+ */
63
+ constructor(when, then) {
64
+ super(WHEN);
65
+ this.when = when;
66
+ this.then = then;
67
+ }
68
+ /**
69
+ * Generate a SQL query string for this node.
70
+ */
71
+ toString() {
72
+ return `WHEN ${this.when} THEN ${this.then}`;
73
+ }
74
+ }
75
+ //# sourceMappingURL=case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"case.js","sourceRoot":"","sources":["../../../src/ast/case.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,OA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AAW;IACxB,4BAA4B;IACnB,IAAI,CAAW;IAExB;;;;OAIG;IACH,YAAY,IAAc,EAAE,IAAc;QACxC,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,QAAQ,IAAI,CAAC,IAAI,SAAS,IAAI,CAAC,IAAI,EAAE,CAAC;IAC/C,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ import { ExprNode } from './node.js';
2
+ export declare class CastNode extends ExprNode {
3
+ /** The expression to type cast. */
4
+ readonly expr: ExprNode;
5
+ /** The type to cast to. */
6
+ readonly cast: string;
7
+ /**
8
+ * Instantiate a cast node.
9
+ * @param expr The expression to type cast.
10
+ * @param type The type to cast to.
11
+ */
12
+ constructor(expr: ExprNode, type: string);
13
+ /**
14
+ * Generate a SQL query string for this node.
15
+ */
16
+ toString(): string;
17
+ }
18
+ //# sourceMappingURL=cast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cast.d.ts","sourceRoot":"","sources":["../../../src/ast/cast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,QAAS,SAAQ,QAAQ;IACpC,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;OAIG;gBACS,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM;IAMxC;;OAEG;IACH,QAAQ;CAIT"}