@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
@@ -5,19 +5,17 @@ import { VerbatimNode } from '../ast/verbatim.js';
5
5
  * Return a SQL AST node for a literal value. The supported types are
6
6
  * null, string, number, boolean, Date, and RegExp. Otherwise, the
7
7
  * input value will be directly coerced to a string.
8
- * @param {*} value The literal value.
9
- * @returns {LiteralNode}
8
+ * @param value The literal value.
10
9
  */
11
- export function literal(value) {
10
+ export function literal(value: unknown) {
12
11
  return new LiteralNode(value);
13
12
  }
14
13
 
15
14
  /**
16
15
  * Return a SQL AST node for verbatim string content.
17
- * @param {string} value The verbatim value.
18
- * @param {string} [hint] A type hint for analyzing verbatim content.
19
- * @returns {VerbatimNode}
16
+ * @param value The verbatim value.
17
+ * @param hint A type hint for analyzing verbatim content.
20
18
  */
21
- export function verbatim(value, hint) {
19
+ export function verbatim(value: string, hint?: string) {
22
20
  return new VerbatimNode(value, hint);
23
21
  }
@@ -0,0 +1,125 @@
1
+ import type { ExprValue } from '../types.js';
2
+ import { fn } from '../util/function.js';
3
+
4
+ /**
5
+ * Return true if the floating point value is not a number, false otherwise.
6
+ * @param expr The input number.
7
+ */
8
+ export function isNaN(expr: ExprValue) {
9
+ return fn('isnan', expr);
10
+ }
11
+
12
+ /**
13
+ * Return true if the floating point value is finite, false otherwise.
14
+ * @param expr The input number.
15
+ */
16
+ export function isFinite(expr: ExprValue) {
17
+ return fn('isfinite', expr);
18
+ }
19
+
20
+ /**
21
+ * Return true if the floating point value is infinite, false otherwise.
22
+ * @param expr The input number.
23
+ */
24
+ export function isInfinite(expr: ExprValue) {
25
+ return fn('isinf', expr);
26
+ }
27
+
28
+ /**
29
+ * Selects the largest value.
30
+ * @param expr The input expressions.
31
+ */
32
+ export function greatest(...expr: ExprValue[]) {
33
+ return fn('greatest', ...expr);
34
+ }
35
+
36
+ /**
37
+ * Selects the smallest value.
38
+ * @param expr The input expressions.
39
+ */
40
+ export function least(...expr: ExprValue[]) {
41
+ return fn('least', ...expr);
42
+ }
43
+
44
+ /**
45
+ * Compute the exponentional function `e ** expr`.
46
+ * @param expr The input number.
47
+ */
48
+ export function exp(expr: ExprValue) {
49
+ return fn('exp', expr);
50
+ }
51
+
52
+ /**
53
+ * Compute a base 10 logarithm.
54
+ * @param expr The input number.
55
+ */
56
+ export function log(expr: ExprValue) {
57
+ return fn('log', expr);
58
+ }
59
+
60
+ /**
61
+ * Compute a natural logarithm.
62
+ * @param expr The input number.
63
+ */
64
+ export function ln(expr: ExprValue) {
65
+ return fn('ln', expr);
66
+ }
67
+
68
+ /**
69
+ * Compute the sign of a number.
70
+ * @param expr The input number.
71
+ */
72
+ export function sign(expr: ExprValue) {
73
+ return fn('sign', expr);
74
+ }
75
+
76
+ /**
77
+ * Compute the absolute value of a number.
78
+ * @param expr The input number.
79
+ */
80
+ export function abs(expr: ExprValue) {
81
+ return fn('abs', expr);
82
+ }
83
+
84
+ /**
85
+ * Compute the square root of a number.
86
+ * @param expr The input number.
87
+ */
88
+ export function sqrt(expr: ExprValue) {
89
+ return fn('sqrt', expr);
90
+ }
91
+
92
+ /**
93
+ * Rounds the number up.
94
+ * @param expr The input number.
95
+ */
96
+ export function ceil(expr: ExprValue) {
97
+ return fn('ceil', expr);
98
+ }
99
+
100
+ /**
101
+ * Rounds the number down.
102
+ * @param expr The input number.
103
+ */
104
+ export function floor(expr: ExprValue) {
105
+ return fn('floor', expr);
106
+ }
107
+
108
+ /**
109
+ * Round to the given decimal places.
110
+ * @param expr The input number.
111
+ * @param places The decimal places.
112
+ * Negative values are allowed, to round to tens, hundreds, etc.
113
+ * If unspecified, defaults to zero.
114
+ */
115
+ export function round(expr: ExprValue, places?: ExprValue) {
116
+ return fn('round', expr, places);
117
+ }
118
+
119
+ /**
120
+ * Truncates the number.
121
+ * @param expr The input number.
122
+ */
123
+ export function trunc(expr: ExprValue) {
124
+ return fn('trunc', expr);
125
+ }
@@ -0,0 +1,272 @@
1
+ import type { ExprValue, ExprVarArgs } from '../types.js';
2
+ import { BetweenOpNode, Extent, NotBetweenOpNode } from '../ast/between-op.js';
3
+ import { BinaryOpNode } from '../ast/binary-op.js';
4
+ import { InOpNode } from '../ast/in-op.js';
5
+ import { AndNode, OrNode } from '../ast/logical-op.js';
6
+ import { UnaryOpNode, UnaryPostfixOpNode } from '../ast/unary-op.js';
7
+ import { asNode } from '../util/ast.js';
8
+ import { nodeList } from '../util/function.js';
9
+
10
+ function unaryOp(op: string, expr: unknown) {
11
+ return new UnaryOpNode(op, asNode(expr));
12
+ }
13
+
14
+ function unaryPostfixOp(op: string, expr: unknown) {
15
+ return new UnaryPostfixOpNode(op, asNode(expr));
16
+ }
17
+
18
+ function binaryOp(op: string, left: unknown, right: unknown) {
19
+ return new BinaryOpNode(op, asNode(left), asNode(right));
20
+ }
21
+
22
+ /**
23
+ * Logical and (AND) operator.
24
+ * @param clauses The input expressions.
25
+ */
26
+ export function and(...clauses: ExprVarArgs[]) {
27
+ return new AndNode(nodeList(clauses));
28
+ }
29
+
30
+ /**
31
+ * Logical or (OR) operator.
32
+ * @param clauses The input expressions.
33
+ */
34
+ export function or(...clauses: ExprVarArgs[]) {
35
+ return new OrNode(nodeList(clauses));
36
+ }
37
+
38
+ /**
39
+ * Logical not (NOT) operator.
40
+ * @param expr The expression to negate.
41
+ */
42
+ export function not(expr: ExprValue) {
43
+ return unaryOp('NOT', expr);
44
+ }
45
+
46
+ /**
47
+ * Null check (IS NULL) operator.
48
+ * @param expr The expression to test.
49
+ */
50
+ export function isNull(expr: ExprValue) {
51
+ return unaryPostfixOp('IS NULL', expr);
52
+ }
53
+
54
+ /**
55
+ * Non-null check (IS NOT NULL) operator.
56
+ * @param expr The expression to test.
57
+ */
58
+ export function isNotNull(expr: ExprValue) {
59
+ return unaryPostfixOp('IS NOT NULL', expr);
60
+ }
61
+
62
+ /**
63
+ * Bitwise not (~) operator.
64
+ * @param expr The input expression.
65
+ */
66
+ export function bitNot(expr: ExprValue) {
67
+ return unaryOp('~', expr);
68
+ }
69
+
70
+ /**
71
+ * Bitwise and (&) operator.
72
+ * @param left The left argument.
73
+ * @param right The right argument.
74
+ */
75
+ export function bitAnd(left: ExprValue, right: ExprValue) {
76
+ return binaryOp('&', left, right);
77
+ }
78
+
79
+ /**
80
+ * Bitwise or (|) operator.
81
+ * @param left The left argument.
82
+ * @param right The right argument.
83
+ */
84
+ export function bitOr(left: ExprValue, right: ExprValue) {
85
+ return binaryOp('|', left, right);
86
+ }
87
+
88
+ /**
89
+ * Bit shift left (<<) operator.
90
+ * @param left The left argument.
91
+ * @param right The right argument.
92
+ */
93
+ export function bitLeft(left: ExprValue, right: ExprValue) {
94
+ return binaryOp('<<', left, right);
95
+ }
96
+
97
+ /**
98
+ * Bit shift right (>>) operator.
99
+ * @param left The left argument.
100
+ * @param right The right argument.
101
+ */
102
+ export function bitRight(left: ExprValue, right: ExprValue) {
103
+ return binaryOp('>>', left, right);
104
+ }
105
+
106
+ /**
107
+ * Addition (+) operator.
108
+ * @param left The left argument.
109
+ * @param right The right argument.
110
+ */
111
+ export function add(left: ExprValue, right: ExprValue) {
112
+ return binaryOp('+', left, right);
113
+ }
114
+
115
+ /**
116
+ * Subtraction (-) operator.
117
+ * @param left The left argument.
118
+ * @param right The right argument.
119
+ */
120
+ export function sub(left: ExprValue, right: ExprValue) {
121
+ return binaryOp('-', left, right);
122
+ }
123
+
124
+ /**
125
+ * Multiplication (*) operator.
126
+ * @param left The left argument.
127
+ * @param right The right argument.
128
+ */
129
+ export function mul(left: ExprValue, right: ExprValue) {
130
+ return binaryOp('*', left, right);
131
+ }
132
+
133
+ /**
134
+ * Division (/) operator.
135
+ * @param left The left argument.
136
+ * @param right The right argument.
137
+ */
138
+ export function div(left: ExprValue, right: ExprValue) {
139
+ return binaryOp('/', left, right);
140
+ }
141
+
142
+ /**
143
+ * Integer division (//) operator.
144
+ * @param left The left argument.
145
+ * @param right The right argument.
146
+ */
147
+ export function idiv(left: ExprValue, right: ExprValue) {
148
+ return binaryOp('//', left, right);
149
+ }
150
+
151
+ /**
152
+ * Modulo (%) operator.
153
+ * @param left The left argument.
154
+ * @param right The right argument.
155
+ */
156
+ export function mod(left: ExprValue, right: ExprValue) {
157
+ return binaryOp('%', left, right);
158
+ }
159
+
160
+ /**
161
+ * Exponentiation (**) operator.
162
+ * @param left The left argument.
163
+ * @param right The right argument.
164
+ */
165
+ export function pow(left: ExprValue, right: ExprValue) {
166
+ return binaryOp('**', left, right);
167
+ }
168
+
169
+ /**
170
+ * Equality comparision (=) operator.
171
+ * @param left The left argument.
172
+ * @param right The right argument.
173
+ */
174
+ export function eq(left: ExprValue, right: ExprValue) {
175
+ return binaryOp('=', left, right);
176
+ }
177
+
178
+ /**
179
+ * Non-equality comparision (<>) operator.
180
+ * @param left The left argument.
181
+ * @param right The right argument.
182
+ */
183
+ export function neq(left: ExprValue, right: ExprValue) {
184
+ return binaryOp('<>', left, right);
185
+ }
186
+
187
+ /**
188
+ * Less-than comparision (<) operator.
189
+ * @param left The left argument.
190
+ * @param right The right argument.
191
+ */
192
+ export function lt(left: ExprValue, right: ExprValue) {
193
+ return binaryOp('<', left, right);
194
+ }
195
+
196
+ /**
197
+ * Greater-than comparision (>) operator.
198
+ * @param left The left argument.
199
+ * @param right The right argument.
200
+ */
201
+ export function gt(left: ExprValue, right: ExprValue) {
202
+ return binaryOp('>', left, right);
203
+ }
204
+
205
+ /**
206
+ * Less-than or equal comparision (<=) operator.
207
+ * @param left The left argument.
208
+ * @param right The right argument.
209
+ */
210
+ export function lte(left: ExprValue, right: ExprValue) {
211
+ return binaryOp('<=', left, right);
212
+ }
213
+
214
+ /**
215
+ * Greater-than or equal comparision (>=) operator.
216
+ * @param left The left argument.
217
+ * @param right The right argument.
218
+ */
219
+ export function gte(left: ExprValue, right: ExprValue) {
220
+ return binaryOp('>=', left, right);
221
+ }
222
+
223
+ /**
224
+ * Null-inclusive non-equality (IS DISTINCT FROM) operator.
225
+ * @param left The left argument.
226
+ * @param right The right argument.
227
+ */
228
+ export function isDistinct(left: ExprValue, right: ExprValue) {
229
+ return binaryOp('IS DISTINCT FROM', left, right);
230
+ }
231
+
232
+ /**
233
+ * Null-inclusive equality (IS NOT DISTINCT FROM) operator.
234
+ * @param left The left argument.
235
+ * @param right The right argument.
236
+ */
237
+ export function isNotDistinct(left: ExprValue, right: ExprValue) {
238
+ return binaryOp('IS NOT DISTINCT FROM', left, right);
239
+ }
240
+
241
+ /**
242
+ * Range inclusion (BETWEEN) operator.
243
+ * @param expr The expression to test.
244
+ * @param extent The range extent.
245
+ */
246
+ export function isBetween(expr: ExprValue, extent?: ExprValue[] | null) {
247
+ return new BetweenOpNode(
248
+ asNode(expr),
249
+ extent?.map(asNode) as (Extent | null | undefined)
250
+ );
251
+ }
252
+
253
+ /**
254
+ * Range exclusion (NOT BETWEEN) operator.
255
+ * @param expr The expression to test.
256
+ * @param extent The range extent.
257
+ */
258
+ export function isNotBetween(expr: ExprValue, extent?: ExprValue[] | null) {
259
+ return new NotBetweenOpNode(
260
+ asNode(expr),
261
+ extent?.map(asNode) as (Extent | null | undefined)
262
+ );
263
+ }
264
+
265
+ /**
266
+ * Set inclusion (IN) operator.
267
+ * @param expr The expression to test.
268
+ * @param values The included values.
269
+ */
270
+ export function isIn(expr: ExprValue, values: ExprValue[]) {
271
+ return new InOpNode(asNode(expr), values.map(asNode));
272
+ }
@@ -0,0 +1,21 @@
1
+ import type { ExprValue } from '../types.js';
2
+ import { OrderByNode } from '../ast/order-by.js';
3
+ import { asNode } from '../util/ast.js';
4
+
5
+ /**
6
+ * Indicate ascending sort order for an expression.
7
+ * @param expr An expression to order by.
8
+ * @param nullsFirst Flag indicating if null values should be sorted first.
9
+ */
10
+ export function asc(expr: ExprValue, nullsFirst?: boolean) {
11
+ return new OrderByNode(asNode(expr), false, nullsFirst);
12
+ }
13
+
14
+ /**
15
+ * Indicate descending sort order for an expression.
16
+ * @param expr An expression to order by.
17
+ * @param nullsFirst Flag indicating if null values should be sorted first.
18
+ */
19
+ export function desc(expr: ExprValue, nullsFirst?: boolean) {
20
+ return new OrderByNode(asNode(expr), true, nullsFirst);
21
+ }
@@ -0,0 +1,50 @@
1
+ import type { ExprValue } from '../types.js';
2
+ import { fn } from '../util/function.js';
3
+
4
+ /**
5
+ * Function that converts geometry data to GeoJSON format.
6
+ * @param expr The input expression.
7
+ */
8
+ export function geojson(expr: ExprValue) {
9
+ return fn('st_asgeojson', expr);
10
+ }
11
+
12
+ /**
13
+ * Function that returns a spatial x position (using ST_X).
14
+ * @param expr The input expression.
15
+ */
16
+ export function x(expr: ExprValue) {
17
+ return fn('st_x', expr);
18
+ }
19
+
20
+ /**
21
+ * Function that returns a spatial y position (using ST_Y).
22
+ * @param expr The input expression.
23
+ */
24
+ export function y(expr: ExprValue) {
25
+ return fn('st_y', expr);
26
+ }
27
+
28
+ /**
29
+ * Function that returns the centroid point for geometry data.
30
+ * @param expr The input expression.
31
+ */
32
+ export function centroid(expr: ExprValue) {
33
+ return fn('st_centroid', expr);
34
+ }
35
+
36
+ /**
37
+ * Function that returns the centroid x-coordinate for geometry data.
38
+ * @param expr The input expression.
39
+ */
40
+ export function centroidX(expr: ExprValue) {
41
+ return x(centroid(expr));
42
+ }
43
+
44
+ /**
45
+ * Function that returns yhe centroid y-coordinate for geometry data.
46
+ * @param expr The input expression.
47
+ */
48
+ export function centroidY(expr: ExprValue) {
49
+ return y(centroid(expr));
50
+ }
@@ -1,7 +1,5 @@
1
- /**
2
- * @import { ExprNode } from '../ast/node.js'
3
- * @import { ParamLike } from '../types.js'
4
- */
1
+ import type { ExprNode } from '../ast/node.js';
2
+ import type { ParamLike } from '../types.js';
5
3
  import { FragmentNode } from '../ast/fragment.js';
6
4
  import { isNode } from '../ast/node.js';
7
5
  import { ParamNode } from '../ast/param.js';
@@ -9,23 +7,28 @@ import { VerbatimNode } from '../ast/verbatim.js';
9
7
  import { isParamLike, isString } from '../util/type-check.js';
10
8
  import { literal } from './literal.js';
11
9
 
12
- /**
13
- * @typedef { ExprNode | ParamLike | string | number | boolean | Date } TemplateValue
14
- */
10
+ export type TemplateValue =
11
+ | ExprNode
12
+ | ParamLike
13
+ | string
14
+ | number
15
+ | boolean
16
+ | Date
17
+ ;
15
18
 
16
19
  /**
17
20
  * Template tag function for SQL fragments. Interpolated values
18
21
  * may be strings, other SQL expression objects (such as column
19
22
  * references), primitive values, or dynamic parameters.
20
- * @param {TemplateStringsArray} strings Template string constants.
21
- * @param {...TemplateValue} exprs Template expression values.
23
+ * @param strings Template string constants.
24
+ * @param exprs Template expression values.
22
25
  */
23
- export function sql(strings, ...exprs) {
26
+ export function sql(strings: TemplateStringsArray, ...exprs: TemplateValue[]) {
24
27
  return new FragmentNode(parseSQL(strings, exprs));
25
28
  }
26
29
 
27
- function parseSQL(strings, exprs) {
28
- const spans = [strings[0]];
30
+ function parseSQL(strings: TemplateStringsArray, exprs: TemplateValue[]) {
31
+ const spans: (string | ExprNode)[] = [strings[0]];
29
32
  const n = exprs.length;
30
33
  for (let i = 0, k = 0; i < n;) {
31
34
  const e = exprs[i];
@@ -34,7 +37,7 @@ function parseSQL(strings, exprs) {
34
37
  } else if (isParamLike(e)) {
35
38
  spans[++k] = new ParamNode(e);
36
39
  } else {
37
- spans[k] += isString(e) ? e : literal(e);
40
+ spans[k] += isString(e) ? e : `${literal(e)}`;
38
41
  }
39
42
  const s = strings[++i];
40
43
  if (isNode(spans[k])) {
@@ -0,0 +1,79 @@
1
+ import type { ExprValue, StringValue } from '../types.js';
2
+ import { asLiteral } from '../util/ast.js';
3
+ import { argsList, fn } from '../util/function.js';
4
+
5
+ function strFn(name: string, expr: ExprValue, ...args: unknown[]) {
6
+ return fn(name, expr, ...(argsList(args).map(asLiteral)));
7
+ }
8
+
9
+ /**
10
+ * Function that returns true if a string contains a regexp pattern,
11
+ * false otherwise.
12
+ * @param string The string match against.
13
+ * @param pattern The regular expression pattern to match.
14
+ * @param options Regular expression options:
15
+ * 'c': case-sensitive matching
16
+ * 'i': case-insensitive matching
17
+ * 'l': match literals instead of regular expression tokens
18
+ * 'm', 'n', 'p': newline sensitive matching
19
+ * 'g': global replace, only available for regexp_replace
20
+ * 's': non-newline sensitive matching
21
+ */
22
+ export function regexp_matches(
23
+ string: ExprValue,
24
+ pattern: StringValue,
25
+ options?: StringValue
26
+ ) {
27
+ return strFn('regexp_matches', string, pattern, options);
28
+ }
29
+
30
+ /**
31
+ * Function that returns true if search_string is found within string.
32
+ * @param string The string to match against.
33
+ * @param search_string The substring to search for.
34
+ */
35
+ export function contains(string: ExprValue, search_string: StringValue) {
36
+ return strFn('contains', string, search_string);
37
+ }
38
+
39
+ /**
40
+ * Function that returns true if string begins with search_string.
41
+ * @param string The string to match against.
42
+ * @param search_string The substring to search for.
43
+ */
44
+ export function prefix(string: ExprValue, search_string: StringValue) {
45
+ return strFn('starts_with', string, search_string);
46
+ }
47
+
48
+ /**
49
+ * Function that returns true if string ends with search_string.
50
+ * @param string The string to match against.
51
+ * @param search_string The substring to search for.
52
+ */
53
+ export function suffix(string: ExprValue, search_string: StringValue) {
54
+ return strFn('ends_with', string, search_string);
55
+ }
56
+
57
+ /**
58
+ * Function that converts string to lower case.
59
+ * @param string The string to convert.
60
+ */
61
+ export function lower(string: ExprValue) {
62
+ return strFn('lower', string);
63
+ }
64
+
65
+ /**
66
+ * Function that converts string to upper case.
67
+ * @param string The string to convert.
68
+ */
69
+ export function upper(string: ExprValue) {
70
+ return strFn('upper', string);
71
+ }
72
+
73
+ /**
74
+ * Function that returns the number of characters in string.
75
+ * @param value The string to measure.
76
+ */
77
+ export function length(value: ExprValue) {
78
+ return strFn('length', value);
79
+ }
@@ -1,14 +1,14 @@
1
1
  import { TableRefNode } from '../ast/table-ref.js';
2
+ import { MaybeArray } from '../types.js';
2
3
  import { exprList } from '../util/function.js';
3
4
 
4
5
  /**
5
6
  * Returns a named table or view reference.
6
- * @param {...(string | string[])} ids Table and namespace identifiers.
7
+ * @param ids Table and namespace identifiers.
7
8
  * For example 'name' or ['schema', 'name'].
8
- * @returns {TableRefNode | undefined} A table reference, or undefined
9
- * if the input identifier list is empty.
9
+ * @returns A table reference or undefined if the input list is empty.
10
10
  */
11
- export function tableRef(...ids) {
11
+ export function tableRef(...ids: MaybeArray<string>[]) {
12
12
  const args = exprList(ids, String);
13
13
  return args?.length ? new TableRefNode(args) : undefined;
14
14
  }
@@ -0,0 +1,10 @@
1
+ import type { ExprValue } from '../types.js';
2
+ import { fn } from '../util/function.js';
3
+
4
+ /**
5
+ * Returns the first non-null argument.
6
+ * @param expr The input expressions.
7
+ */
8
+ export function coalesce(...expr: ExprValue[]) {
9
+ return fn('coalesce', ...expr);
10
+ }