@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
@@ -1,67 +0,0 @@
1
- import { LOGICAL_OPERATOR } from '../constants.js';
2
- import { ExprNode } from './node.js';
3
-
4
- /**
5
- * @template {ExprNode} T
6
- */
7
- export class LogicalOpNode extends ExprNode {
8
- /**
9
- * Instantiate a logical operator node.
10
- * @param {string} op The logical operation.
11
- * @param {T[]} clauses The input clause expressions.
12
- */
13
- constructor(op, clauses) {
14
- super(LOGICAL_OPERATOR);
15
- /**
16
- * The logical operator.
17
- * @type {string}
18
- * @readonly
19
- */
20
- this.op = op;
21
- /**
22
- * The input clause expressions.
23
- * @type {T[]}
24
- * @readonly
25
- */
26
- this.clauses = clauses;
27
- }
28
-
29
- /**
30
- * Generate a SQL query string for this node.
31
- * @returns {string}
32
- */
33
- toString() {
34
- const c = this.clauses;
35
- return c.length === 0 ? ''
36
- : c.length === 1 ? `${c[0]}`
37
- : `(${c.join(` ${this.op} `)})`;
38
- }
39
- }
40
-
41
- /**
42
- * @template {ExprNode} T
43
- * @extends {LogicalOpNode<T>}
44
- */
45
- export class AndNode extends LogicalOpNode {
46
- /**
47
- * Instantiate a logical AND operator node.
48
- * @param {T[]} clauses The input clause expressions.
49
- */
50
- constructor(clauses) {
51
- super('AND', clauses);
52
- }
53
- }
54
-
55
- /**
56
- * @template {ExprNode} T
57
- * @extends {LogicalOpNode<T>}
58
- */
59
- export class OrNode extends LogicalOpNode {
60
- /**
61
- * Instantiate a logical OR operator node.
62
- * @param {T[]} clauses The input clause expressions.
63
- */
64
- constructor(clauses) {
65
- super('OR', clauses);
66
- }
67
- }
@@ -1,48 +0,0 @@
1
- import { ORDER_BY } from '../constants.js';
2
- import { ExprNode } from './node.js';
3
-
4
- export class OrderByNode extends ExprNode {
5
- /**
6
- * Instantiate an order by entry node.
7
- * @param {ExprNode} expr The expression to order by.
8
- * @param {boolean | undefined} [desc] Flag indicating descending order.
9
- * @param {boolean | undefined} [nullsFirst] Flag indicating if null
10
- * values should be sorted first.
11
- */
12
- constructor(expr, desc, nullsFirst) {
13
- super(ORDER_BY);
14
- /**
15
- * The expression to order by.
16
- * @type {ExprNode}
17
- * @readonly
18
- */
19
- this.expr = expr;
20
- /**
21
- * Flag indicating descending order.
22
- * @type {boolean | undefined}
23
- * @readonly
24
- */
25
- this.desc = desc;
26
- /**
27
- * Flag indicating if null values should be sorted first.
28
- * @type {boolean | undefined}
29
- * @readonly
30
- */
31
- this.nullsFirst = nullsFirst;
32
- }
33
-
34
- /**
35
- * Generate a SQL query string for this node.
36
- * @returns {string}
37
- */
38
- toString() {
39
- const { expr, desc, nullsFirst } = this;
40
- const dir = desc ? ' DESC'
41
- : desc === false ? ' ASC'
42
- : '';
43
- const nf = nullsFirst ? ' NULLS FIRST'
44
- : nullsFirst === false ? ' NULLS LAST'
45
- : '';
46
- return `${expr}${dir}${nf}`;
47
- }
48
- }
package/src/ast/sample.js DELETED
@@ -1,53 +0,0 @@
1
- import { SAMPLE_CLAUSE } from '../constants.js';
2
- import { SQLNode } from './node.js';
3
-
4
- /**
5
- * @typedef {'reservoir' | 'bernoulli' | 'system'} SampleMethod
6
- */
7
-
8
- export class SampleClauseNode extends SQLNode {
9
- /**
10
- * Instantiate a sample clause node.
11
- * @param {number} size The sample size as either a row count or percentage.
12
- * @param {boolean} [perc=false] Flag indicating if the sampling unit is
13
- * rows (`false`) or a percentage (`true`).
14
- * @param {SampleMethod} [method] The sampling method. If unspecified,
15
- * a default method is applied based on the sampling unit.
16
- * @param {number} [seed] The random seed.
17
- */
18
- constructor(size, perc = false, method = undefined, seed = undefined) {
19
- super(SAMPLE_CLAUSE);
20
- /**
21
- * The sample size as either a row count or percentage.
22
- * @type {number}
23
- * @readonly
24
- */
25
- this.size = size;
26
- /**
27
- * Flag indicating if the sampling unit is rows (`false`) or a
28
- * percentage (`true`).
29
- * @type {boolean}
30
- * @readonly
31
- */
32
- this.perc = perc;
33
- /**
34
- * The sampling method.
35
- * @type {SampleMethod}
36
- * @readonly
37
- */
38
- this.method = method;
39
- /**
40
- * The random seed.
41
- * @type {number}
42
- * @readonly
43
- */
44
- this.seed = seed;
45
- }
46
-
47
- toString() {
48
- const { size, perc, method, seed } = this;
49
- const m = method ? `${method} ` : '';
50
- const s = seed != null ? ` REPEATABLE (${seed})` : '';
51
- return `${m}(${size}${perc ? '%' : ' ROWS'})${s}`;
52
- }
53
- }
@@ -1,33 +0,0 @@
1
- import { VERBATIM } from '../constants.js';
2
- import { ExprNode } from './node.js';
3
-
4
- export class VerbatimNode extends ExprNode {
5
- /**
6
- * Instantiate a raw node with verbatim content.
7
- * @param {string} value The verbatim content to include.
8
- * @param {string} [hint] A type hint for analyzing verbatim content.
9
- */
10
- constructor(value, hint) {
11
- super(VERBATIM);
12
- /**
13
- * The verbatim content to include.
14
- * @type {string}
15
- * @readonly
16
- */
17
- this.value = value;
18
- /**
19
- * A type hint for analyzing verbatim content.
20
- * @type {string}
21
- * @readonly
22
- */
23
- this.hint = hint;
24
- }
25
-
26
- /**
27
- * Generate a SQL query string for this node.
28
- * @returns {string}
29
- */
30
- toString() {
31
- return this.value;
32
- }
33
- }
package/src/ast/window.js DELETED
@@ -1,260 +0,0 @@
1
- /**
2
- * @import { ExprVarArgs, OrderByExpr, WindowFunctionName } from '../types.js'
3
- * @import { AggregateNode } from './aggregate.js'
4
- * @import { WindowFrameNode } from './window-frame.js'
5
- */
6
- import { WINDOW, WINDOW_CLAUSE, WINDOW_DEF, WINDOW_FUNCTION } from '../constants.js';
7
- import { exprList } from '../util/function.js';
8
- import { quoteIdentifier } from '../util/string.js';
9
- import { ExprNode, SQLNode } from './node.js';
10
-
11
- export class WindowClauseNode extends SQLNode {
12
- /**
13
- * Instantiate a window clause node.
14
- * @param {string} name The window name.
15
- * @param {WindowDefNode} def The window definition.
16
- */
17
- constructor(name, def) {
18
- super(WINDOW_CLAUSE);
19
- /**
20
- * The window name.
21
- * @type {string}
22
- * @readonly
23
- */
24
- this.name = name;
25
- /**
26
- * The window definition.
27
- * @type {WindowDefNode}
28
- * @readonly
29
- */
30
- this.def = def;
31
- }
32
-
33
- toString() {
34
- return `${quoteIdentifier(this.name)} AS ${this.def}`;
35
- }
36
- }
37
-
38
- export class WindowNode extends ExprNode {
39
- /**
40
- * Instantiate a window node.
41
- * @param {WindowFunctionNode | AggregateNode} func The window function call.
42
- * @param {WindowDefNode} [over] The window definition or name.
43
- */
44
- constructor(func, over = new WindowDefNode()) {
45
- super(WINDOW);
46
- /**
47
- * @type {WindowFunctionNode | AggregateNode}
48
- * @readonly
49
- */
50
- this.func = func;
51
- /**
52
- * @type {WindowDefNode}
53
- * @readonly
54
- */
55
- this.def = over;
56
- }
57
-
58
- /**
59
- * Return an updated window over a named window definition.
60
- * @param {string} name The window definition name.
61
- * @returns {WindowNode} A new window node.
62
- */
63
- over(name) {
64
- return new WindowNode(this.func, this.def.over(name));
65
- }
66
-
67
- /**
68
- * Return an updated window with the given partitions.
69
- * @param {...ExprVarArgs} expr The partition by criteria.
70
- * @returns {WindowNode} A new window node.
71
- */
72
- partitionby(...expr) {
73
- return new WindowNode(this.func, this.def.partitionby(...expr));
74
- }
75
-
76
- /**
77
- * Return an updated window with the given ordering.
78
- * @param {...ExprVarArgs} expr The order by criteria.
79
- * @returns {WindowNode} A new window node.
80
- */
81
- orderby(...expr) {
82
- return new WindowNode(this.func, this.def.orderby(...expr));
83
- }
84
-
85
- /**
86
- * Return an updated window with the given frame definition.
87
- * @param {WindowFrameNode} framedef The frame definition.
88
- * @returns {WindowNode} A new window node.
89
- */
90
- frame(framedef) {
91
- return new WindowNode(this.func, this.def.frame(framedef));
92
- }
93
-
94
- /**
95
- * Generate a SQL query string for this node.
96
- * @returns {string}
97
- */
98
- toString() {
99
- return `${this.func} OVER ${this.def}`;
100
- }
101
- }
102
-
103
- export class WindowFunctionNode extends ExprNode {
104
- /**
105
- * Instantiate a window function call node.
106
- * @param {WindowFunctionName} name The window function name.
107
- * @param {ExprNode[]} [args=[]] The window function arguments.
108
- * @param {boolean} [ignoreNulls=false] Flag to ignore null values.
109
- * @param {OrderByExpr} [argOrder] Order expressions for window arguments.
110
- * Note that this argument ordering is distinct from the window ordering.
111
- */
112
- constructor(name, args = [], ignoreNulls = false, argOrder = []) {
113
- super(WINDOW_FUNCTION);
114
- /**
115
- * The window function name.
116
- * @type {string}
117
- * @readonly
118
- */
119
- this.name = name;
120
- /**
121
- * The window function arguments.
122
- * @type {ExprNode[]}
123
- * @readonly
124
- */
125
- this.args = args;
126
- /**
127
- * Flag to ignore null values.
128
- * @type {boolean}
129
- * @readonly
130
- */
131
- this.ignoreNulls = ignoreNulls;
132
- /**
133
- * Order by expression for window arguments.
134
- * @type {ExprNode[]}
135
- * @readonly
136
- */
137
- this.order = exprList([argOrder]);
138
- }
139
-
140
- /**
141
- * Generate a SQL query string for this node.
142
- * @returns {string}
143
- */
144
- toString() {
145
- const { name, args, ignoreNulls, order } = this;
146
- const arg = [
147
- args.join(', '),
148
- order.length ? `ORDER BY ${order.join(', ')}` : '',
149
- ignoreNulls ? 'IGNORE NULLS' : ''
150
- ].filter(x => x).join(' ');
151
- return `${name}(${arg})`;
152
- }
153
- }
154
-
155
- export class WindowDefNode extends SQLNode {
156
- /**
157
- * Instantiate a window definition node.
158
- * @param {string} [name] The base window definition name.
159
- * @param {ExprNode[]} [partition] The partition by criteria.
160
- * @param {ExprNode[]} [order] The order by criteria.
161
- * @param {WindowFrameNode} [framedef] The window frame definition.
162
- */
163
- constructor(name, partition, order, framedef) {
164
- super(WINDOW_DEF);
165
- /**
166
- * The base window definition name.
167
- * @type {string}
168
- * @readonly
169
- */
170
- this.name = name;
171
- /**
172
- * The partition by criteria.
173
- * @type {ExprNode[]}
174
- * @readonly
175
- */
176
- this.partition = partition;
177
- /**
178
- * The order by criteria.
179
- * @type {ExprNode[]}
180
- * @readonly
181
- */
182
- this.order = order;
183
- /**
184
- * The window frame definition.
185
- * @type {WindowFrameNode}
186
- * @readonly
187
- */
188
- this.framedef = framedef;
189
- }
190
-
191
- /**
192
- * Return an updated window definition with the given base name.
193
- * @param {string} name The base window definition name.
194
- * @returns {WindowDefNode} A new window definition node.
195
- */
196
- over(name) {
197
- return deriveDef(this, { name });
198
- }
199
-
200
- /**
201
- * Return an updated window definition with the given partitions.
202
- * @param {...ExprVarArgs} expr The partition by criteria.
203
- * @returns {WindowDefNode} A new window definition node.
204
- */
205
- partitionby(...expr) {
206
- return deriveDef(this, { partition: exprList(expr) });
207
- }
208
-
209
- /**
210
- * Return an updated window definition with the given ordering.
211
- * @param {...ExprVarArgs} expr The order by criteria.
212
- * @returns {WindowDefNode} A new window definition node.
213
- */
214
- orderby(...expr) {
215
- return deriveDef(this, { order: exprList(expr) });
216
- }
217
-
218
- /**
219
- * Return an updated window definition with the given frame definition.
220
- * @param {WindowFrameNode} framedef The frame definition.
221
- * @returns {WindowDefNode} A new window definition node.
222
- */
223
- frame(framedef) {
224
- return deriveDef(this, { framedef });
225
- }
226
-
227
- /**
228
- * Generate a SQL query string for this node.
229
- * @returns {string}
230
- */
231
- toString() {
232
- const { name, partition, order, framedef } = this;
233
- const base = name && quoteIdentifier(name);
234
- const def = [
235
- base,
236
- partition?.length && `PARTITION BY ${partition.join(', ')}`,
237
- order?.length && `ORDER BY ${order.join(', ')}`,
238
- framedef
239
- ].filter(x => x);
240
- return base && def.length < 2 ? base : `(${def.join(' ')})`;
241
- }
242
- }
243
-
244
- /**
245
- * Derive a new window definition node from an existing one.
246
- * @param {WindowDefNode} def The existing window definition.
247
- * @param {object} options An options object with new definition properties.
248
- * @param {string} [options.name] The base window definition name.
249
- * @param {ExprNode[]} [options.partition] The partition by criteria.
250
- * @param {ExprNode[]} [options.order] The order by criteria.
251
- * @param {WindowFrameNode} [options.framedef] The window frame definition.
252
- */
253
- function deriveDef(def, options) {
254
- return new WindowDefNode(
255
- options.name ?? def.name,
256
- options.partition ?? def.partition,
257
- options.order ?? def.order,
258
- options.framedef ?? def.framedef
259
- );
260
- }