@math.gl/sql 0.0.0-stage → 5.0.0-beta.12

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 (353) hide show
  1. package/LICENSE +249 -0
  2. package/README.md +26 -2
  3. package/THIRD-PARTY-NOTICES.md +5 -0
  4. package/dist/arrow/aggregates.d.ts +46 -0
  5. package/dist/arrow/aggregates.d.ts.map +1 -0
  6. package/dist/arrow/aggregates.js +289 -0
  7. package/dist/arrow/aggregates.js.map +1 -0
  8. package/dist/arrow/buffers.d.ts +30 -0
  9. package/dist/arrow/buffers.d.ts.map +1 -0
  10. package/dist/arrow/buffers.js +177 -0
  11. package/dist/arrow/buffers.js.map +1 -0
  12. package/dist/arrow/cast.d.ts +19 -0
  13. package/dist/arrow/cast.d.ts.map +1 -0
  14. package/dist/arrow/cast.js +138 -0
  15. package/dist/arrow/cast.js.map +1 -0
  16. package/dist/arrow/compiler.d.ts +10 -0
  17. package/dist/arrow/compiler.d.ts.map +1 -0
  18. package/dist/arrow/compiler.js +1538 -0
  19. package/dist/arrow/compiler.js.map +1 -0
  20. package/dist/arrow/float16.d.ts +7 -0
  21. package/dist/arrow/float16.d.ts.map +1 -0
  22. package/dist/arrow/float16.js +26 -0
  23. package/dist/arrow/float16.js.map +1 -0
  24. package/dist/arrow/index.cjs +3321 -0
  25. package/dist/arrow/index.cjs.map +6 -0
  26. package/dist/arrow/index.d.ts +5 -0
  27. package/dist/arrow/index.d.ts.map +1 -0
  28. package/dist/arrow/index.js +7 -0
  29. package/dist/arrow/index.js.map +1 -0
  30. package/dist/arrow/like.d.ts +3 -0
  31. package/dist/arrow/like.d.ts.map +1 -0
  32. package/dist/arrow/like.js +75 -0
  33. package/dist/arrow/like.js.map +1 -0
  34. package/dist/arrow/list-values.d.ts +14 -0
  35. package/dist/arrow/list-values.d.ts.map +1 -0
  36. package/dist/arrow/list-values.js +201 -0
  37. package/dist/arrow/list-values.js.map +1 -0
  38. package/dist/arrow/predicate.d.ts +7 -0
  39. package/dist/arrow/predicate.d.ts.map +1 -0
  40. package/dist/arrow/predicate.js +10 -0
  41. package/dist/arrow/predicate.js.map +1 -0
  42. package/dist/arrow/query-arrow-aggregate-snapshots.d.ts +24 -0
  43. package/dist/arrow/query-arrow-aggregate-snapshots.d.ts.map +1 -0
  44. package/dist/arrow/query-arrow-aggregate-snapshots.js +64 -0
  45. package/dist/arrow/query-arrow-aggregate-snapshots.js.map +1 -0
  46. package/dist/arrow/query-arrow-sql.d.ts +8 -0
  47. package/dist/arrow/query-arrow-sql.d.ts.map +1 -0
  48. package/dist/arrow/query-arrow-sql.js +223 -0
  49. package/dist/arrow/query-arrow-sql.js.map +1 -0
  50. package/dist/arrow/query-arrow-table.d.ts +36 -0
  51. package/dist/arrow/query-arrow-table.d.ts.map +1 -0
  52. package/dist/arrow/query-arrow-table.js +208 -0
  53. package/dist/arrow/query-arrow-table.js.map +1 -0
  54. package/dist/arrow/query-worker-entry.d.ts +2 -0
  55. package/dist/arrow/query-worker-entry.d.ts.map +1 -0
  56. package/dist/arrow/query-worker-entry.js +7 -0
  57. package/dist/arrow/query-worker-entry.js.map +1 -0
  58. package/dist/arrow/query-worker.d.ts +65 -0
  59. package/dist/arrow/query-worker.d.ts.map +1 -0
  60. package/dist/arrow/query-worker.js +135 -0
  61. package/dist/arrow/query-worker.js.map +1 -0
  62. package/dist/arrow/registry.d.ts +4 -0
  63. package/dist/arrow/registry.d.ts.map +1 -0
  64. package/dist/arrow/registry.js +66 -0
  65. package/dist/arrow/registry.js.map +1 -0
  66. package/dist/arrow/relational-query.d.ts +36 -0
  67. package/dist/arrow/relational-query.d.ts.map +1 -0
  68. package/dist/arrow/relational-query.js +174 -0
  69. package/dist/arrow/relational-query.js.map +1 -0
  70. package/dist/arrow/replace-arrow-columns.d.ts +8 -0
  71. package/dist/arrow/replace-arrow-columns.d.ts.map +1 -0
  72. package/dist/arrow/replace-arrow-columns.js +63 -0
  73. package/dist/arrow/replace-arrow-columns.js.map +1 -0
  74. package/dist/arrow/signature.d.ts +6 -0
  75. package/dist/arrow/signature.d.ts.map +1 -0
  76. package/dist/arrow/signature.js +51 -0
  77. package/dist/arrow/signature.js.map +1 -0
  78. package/dist/arrow/temporal-cast.d.ts +9 -0
  79. package/dist/arrow/temporal-cast.d.ts.map +1 -0
  80. package/dist/arrow/temporal-cast.js +60 -0
  81. package/dist/arrow/temporal-cast.js.map +1 -0
  82. package/dist/arrow/types.d.ts +62 -0
  83. package/dist/arrow/types.d.ts.map +1 -0
  84. package/dist/arrow/types.js +5 -0
  85. package/dist/arrow/types.js.map +1 -0
  86. package/dist/arrow/unnest-arrow-column.d.ts +22 -0
  87. package/dist/arrow/unnest-arrow-column.d.ts.map +1 -0
  88. package/dist/arrow/unnest-arrow-column.js +112 -0
  89. package/dist/arrow/unnest-arrow-column.js.map +1 -0
  90. package/dist/arrow/worker-entry.d.ts +2 -0
  91. package/dist/arrow/worker-entry.d.ts.map +1 -0
  92. package/dist/arrow/worker-entry.js +9 -0
  93. package/dist/arrow/worker-entry.js.map +1 -0
  94. package/dist/arrow/worker.cjs +4074 -0
  95. package/dist/arrow/worker.cjs.map +6 -0
  96. package/dist/arrow/worker.d.ts +58 -0
  97. package/dist/arrow/worker.d.ts.map +1 -0
  98. package/dist/arrow/worker.js +84 -0
  99. package/dist/arrow/worker.js.map +1 -0
  100. package/dist/color-functions/index.cjs +382 -0
  101. package/dist/color-functions/index.cjs.map +6 -0
  102. package/dist/color-functions/index.d.ts +26 -0
  103. package/dist/color-functions/index.d.ts.map +1 -0
  104. package/dist/color-functions/index.js +306 -0
  105. package/dist/color-functions/index.js.map +1 -0
  106. package/dist/diagnostic-log.d.ts +8 -0
  107. package/dist/diagnostic-log.d.ts.map +1 -0
  108. package/dist/diagnostic-log.js +15 -0
  109. package/dist/diagnostic-log.js.map +1 -0
  110. package/dist/expressions/ast.d.ts +12 -0
  111. package/dist/expressions/ast.d.ts.map +1 -0
  112. package/dist/expressions/ast.js +114 -0
  113. package/dist/expressions/ast.js.map +1 -0
  114. package/dist/expressions/columnar-predicate.d.ts +56 -0
  115. package/dist/expressions/columnar-predicate.d.ts.map +1 -0
  116. package/dist/expressions/columnar-predicate.js +176 -0
  117. package/dist/expressions/columnar-predicate.js.map +1 -0
  118. package/dist/expressions/evaluation-error.d.ts +14 -0
  119. package/dist/expressions/evaluation-error.d.ts.map +1 -0
  120. package/dist/expressions/evaluation-error.js +26 -0
  121. package/dist/expressions/evaluation-error.js.map +1 -0
  122. package/dist/expressions/expression-eval.d.ts +105 -0
  123. package/dist/expressions/expression-eval.d.ts.map +1 -0
  124. package/dist/expressions/expression-eval.js +330 -0
  125. package/dist/expressions/expression-eval.js.map +1 -0
  126. package/dist/expressions/function-libraries.d.ts +63 -0
  127. package/dist/expressions/function-libraries.d.ts.map +1 -0
  128. package/dist/expressions/function-libraries.js +69 -0
  129. package/dist/expressions/function-libraries.js.map +1 -0
  130. package/dist/expressions/function-registry.d.ts +93 -0
  131. package/dist/expressions/function-registry.d.ts.map +1 -0
  132. package/dist/expressions/function-registry.js +139 -0
  133. package/dist/expressions/function-registry.js.map +1 -0
  134. package/dist/expressions/get.d.ts +9 -0
  135. package/dist/expressions/get.d.ts.map +1 -0
  136. package/dist/expressions/get.js +32 -0
  137. package/dist/expressions/get.js.map +1 -0
  138. package/dist/expressions/index.cjs +1888 -0
  139. package/dist/expressions/index.cjs.map +6 -0
  140. package/dist/expressions/index.d.ts +13 -0
  141. package/dist/expressions/index.d.ts.map +1 -0
  142. package/dist/expressions/index.js +14 -0
  143. package/dist/expressions/index.js.map +1 -0
  144. package/dist/expressions/numeric-functions.d.ts +277 -0
  145. package/dist/expressions/numeric-functions.d.ts.map +1 -0
  146. package/dist/expressions/numeric-functions.js +52 -0
  147. package/dist/expressions/numeric-functions.js.map +1 -0
  148. package/dist/expressions/parse-expression-string.d.ts +21 -0
  149. package/dist/expressions/parse-expression-string.d.ts.map +1 -0
  150. package/dist/expressions/parse-expression-string.js +61 -0
  151. package/dist/expressions/parse-expression-string.js.map +1 -0
  152. package/dist/expressions/predicate-expression.d.ts +7 -0
  153. package/dist/expressions/predicate-expression.d.ts.map +1 -0
  154. package/dist/expressions/predicate-expression.js +112 -0
  155. package/dist/expressions/predicate-expression.js.map +1 -0
  156. package/dist/expressions/scalar-type.d.ts +6 -0
  157. package/dist/expressions/scalar-type.d.ts.map +1 -0
  158. package/dist/expressions/scalar-type.js +23 -0
  159. package/dist/expressions/scalar-type.js.map +1 -0
  160. package/dist/expressions/vendor/jsep/runtime.d.ts +3 -0
  161. package/dist/expressions/vendor/jsep/runtime.d.ts.map +1 -0
  162. package/dist/expressions/vendor/jsep/runtime.js +972 -0
  163. package/dist/expressions/vendor/jsep/runtime.js.map +1 -0
  164. package/dist/expressions/vendor/jsep/types.d.ts +148 -0
  165. package/dist/expressions/vendor/jsep/types.d.ts.map +1 -0
  166. package/dist/expressions/vendor/jsep/types.js +6 -0
  167. package/dist/expressions/vendor/jsep/types.js.map +1 -0
  168. package/dist/index.cjs +5294 -0
  169. package/dist/index.cjs.map +6 -0
  170. package/dist/index.d.ts +11 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +11 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/math-functions/index.cjs +444 -0
  175. package/dist/math-functions/index.cjs.map +6 -0
  176. package/dist/math-functions/index.d.ts +44 -0
  177. package/dist/math-functions/index.d.ts.map +1 -0
  178. package/dist/math-functions/index.js +182 -0
  179. package/dist/math-functions/index.js.map +1 -0
  180. package/dist/parser/bind-sql-predicate.d.ts +4 -0
  181. package/dist/parser/bind-sql-predicate.d.ts.map +1 -0
  182. package/dist/parser/bind-sql-predicate.js +11 -0
  183. package/dist/parser/bind-sql-predicate.js.map +1 -0
  184. package/dist/parser/index.cjs +1807 -0
  185. package/dist/parser/index.cjs.map +6 -0
  186. package/dist/parser/index.d.ts +12 -0
  187. package/dist/parser/index.d.ts.map +1 -0
  188. package/dist/parser/index.js +11 -0
  189. package/dist/parser/index.js.map +1 -0
  190. package/dist/parser/parameter-snapshots.d.ts +21 -0
  191. package/dist/parser/parameter-snapshots.d.ts.map +1 -0
  192. package/dist/parser/parameter-snapshots.js +85 -0
  193. package/dist/parser/parameter-snapshots.js.map +1 -0
  194. package/dist/parser/parse-sql-expression.d.ts +50 -0
  195. package/dist/parser/parse-sql-expression.d.ts.map +1 -0
  196. package/dist/parser/parse-sql-expression.js +501 -0
  197. package/dist/parser/parse-sql-expression.js.map +1 -0
  198. package/dist/parser/parse-sql-predicate.d.ts +13 -0
  199. package/dist/parser/parse-sql-predicate.d.ts.map +1 -0
  200. package/dist/parser/parse-sql-predicate.js +365 -0
  201. package/dist/parser/parse-sql-predicate.js.map +1 -0
  202. package/dist/parser/parse-sql-query.d.ts +9 -0
  203. package/dist/parser/parse-sql-query.d.ts.map +1 -0
  204. package/dist/parser/parse-sql-query.js +81 -0
  205. package/dist/parser/parse-sql-query.js.map +1 -0
  206. package/dist/parser/parse-sql-select.d.ts +57 -0
  207. package/dist/parser/parse-sql-select.d.ts.map +1 -0
  208. package/dist/parser/parse-sql-select.js +247 -0
  209. package/dist/parser/parse-sql-select.js.map +1 -0
  210. package/dist/parser/parse-sql-statement.d.ts +54 -0
  211. package/dist/parser/parse-sql-statement.d.ts.map +1 -0
  212. package/dist/parser/parse-sql-statement.js +207 -0
  213. package/dist/parser/parse-sql-statement.js.map +1 -0
  214. package/dist/parser/query-types.d.ts +56 -0
  215. package/dist/parser/query-types.d.ts.map +1 -0
  216. package/dist/parser/query-types.js +5 -0
  217. package/dist/parser/query-types.js.map +1 -0
  218. package/dist/parser/sql-parameters.d.ts +29 -0
  219. package/dist/parser/sql-parameters.d.ts.map +1 -0
  220. package/dist/parser/sql-parameters.js +110 -0
  221. package/dist/parser/sql-parameters.js.map +1 -0
  222. package/dist/parser/sql-parse-error.d.ts +13 -0
  223. package/dist/parser/sql-parse-error.d.ts.map +1 -0
  224. package/dist/parser/sql-parse-error.js +20 -0
  225. package/dist/parser/sql-parse-error.js.map +1 -0
  226. package/dist/parser/sql-predicate-schema.d.ts +164 -0
  227. package/dist/parser/sql-predicate-schema.d.ts.map +1 -0
  228. package/dist/parser/sql-predicate-schema.js +249 -0
  229. package/dist/parser/sql-predicate-schema.js.map +1 -0
  230. package/dist/parser/sql-predicate-types.d.ts +48 -0
  231. package/dist/parser/sql-predicate-types.d.ts.map +1 -0
  232. package/dist/parser/sql-predicate-types.js +9 -0
  233. package/dist/parser/sql-predicate-types.js.map +1 -0
  234. package/dist/parser/sql-predicate.d.ts +6 -0
  235. package/dist/parser/sql-predicate.d.ts.map +1 -0
  236. package/dist/parser/sql-predicate.js +8 -0
  237. package/dist/parser/sql-predicate.js.map +1 -0
  238. package/dist/scales/arrow-domains.d.ts +22 -0
  239. package/dist/scales/arrow-domains.d.ts.map +1 -0
  240. package/dist/scales/arrow-domains.js +166 -0
  241. package/dist/scales/arrow-domains.js.map +1 -0
  242. package/dist/scales/arrow-scales.d.ts +44 -0
  243. package/dist/scales/arrow-scales.d.ts.map +1 -0
  244. package/dist/scales/arrow-scales.js +255 -0
  245. package/dist/scales/arrow-scales.js.map +1 -0
  246. package/dist/scales/compile-scale.d.ts +2 -0
  247. package/dist/scales/compile-scale.d.ts.map +1 -0
  248. package/dist/scales/compile-scale.js +5 -0
  249. package/dist/scales/compile-scale.js.map +1 -0
  250. package/dist/scales/conformance.cjs +180 -0
  251. package/dist/scales/conformance.cjs.map +6 -0
  252. package/dist/scales/conformance.d.ts +26 -0
  253. package/dist/scales/conformance.d.ts.map +1 -0
  254. package/dist/scales/conformance.js +164 -0
  255. package/dist/scales/conformance.js.map +1 -0
  256. package/dist/scales/hdr-colors.d.ts +2 -0
  257. package/dist/scales/hdr-colors.d.ts.map +1 -0
  258. package/dist/scales/hdr-colors.js +5 -0
  259. package/dist/scales/hdr-colors.js.map +1 -0
  260. package/dist/scales/index.cjs +4334 -0
  261. package/dist/scales/index.cjs.map +6 -0
  262. package/dist/scales/index.d.ts +10 -0
  263. package/dist/scales/index.d.ts.map +1 -0
  264. package/dist/scales/index.js +11 -0
  265. package/dist/scales/index.js.map +1 -0
  266. package/dist/scales/palettes.d.ts +2 -0
  267. package/dist/scales/palettes.d.ts.map +1 -0
  268. package/dist/scales/palettes.js +5 -0
  269. package/dist/scales/palettes.js.map +1 -0
  270. package/dist/scales/parse-sql-scale.d.ts +27 -0
  271. package/dist/scales/parse-sql-scale.d.ts.map +1 -0
  272. package/dist/scales/parse-sql-scale.js +257 -0
  273. package/dist/scales/parse-sql-scale.js.map +1 -0
  274. package/dist/scales/quantile-sketch.d.ts +2 -0
  275. package/dist/scales/quantile-sketch.d.ts.map +1 -0
  276. package/dist/scales/quantile-sketch.js +5 -0
  277. package/dist/scales/quantile-sketch.js.map +1 -0
  278. package/dist/scales/scale-types.d.ts +2 -0
  279. package/dist/scales/scale-types.d.ts.map +1 -0
  280. package/dist/scales/scale-types.js +5 -0
  281. package/dist/scales/scale-types.js.map +1 -0
  282. package/dist/scales/streaming-domains.d.ts +18 -0
  283. package/dist/scales/streaming-domains.d.ts.map +1 -0
  284. package/dist/scales/streaming-domains.js +115 -0
  285. package/dist/scales/streaming-domains.js.map +1 -0
  286. package/package.json +92 -4
  287. package/src/arrow/aggregates.ts +386 -0
  288. package/src/arrow/buffers.ts +177 -0
  289. package/src/arrow/cast.ts +160 -0
  290. package/src/arrow/compiler.ts +1778 -0
  291. package/src/arrow/float16.ts +25 -0
  292. package/src/arrow/index.ts +22 -0
  293. package/src/arrow/like.ts +72 -0
  294. package/src/arrow/list-values.ts +221 -0
  295. package/src/arrow/predicate.ts +19 -0
  296. package/src/arrow/query-arrow-aggregate-snapshots.ts +107 -0
  297. package/src/arrow/query-arrow-sql.ts +255 -0
  298. package/src/arrow/query-arrow-table.ts +298 -0
  299. package/src/arrow/query-worker-entry.ts +8 -0
  300. package/src/arrow/query-worker.ts +194 -0
  301. package/src/arrow/registry.ts +87 -0
  302. package/src/arrow/relational-query.ts +247 -0
  303. package/src/arrow/replace-arrow-columns.ts +71 -0
  304. package/src/arrow/signature.ts +50 -0
  305. package/src/arrow/temporal-cast.ts +66 -0
  306. package/src/arrow/types.ts +76 -0
  307. package/src/arrow/unnest-arrow-column.ts +145 -0
  308. package/src/arrow/worker-entry.ts +10 -0
  309. package/src/arrow/worker.ts +143 -0
  310. package/src/color-functions/index.ts +405 -0
  311. package/src/diagnostic-log.ts +20 -0
  312. package/src/expressions/ast.ts +143 -0
  313. package/src/expressions/columnar-predicate.ts +293 -0
  314. package/src/expressions/evaluation-error.ts +29 -0
  315. package/src/expressions/expression-eval.ts +489 -0
  316. package/src/expressions/function-libraries.ts +126 -0
  317. package/src/expressions/function-registry.ts +171 -0
  318. package/src/expressions/get.ts +37 -0
  319. package/src/expressions/index.ts +40 -0
  320. package/src/expressions/numeric-functions.ts +99 -0
  321. package/src/expressions/parse-expression-string.ts +80 -0
  322. package/src/expressions/predicate-expression.ts +128 -0
  323. package/src/expressions/scalar-type.ts +39 -0
  324. package/src/expressions/vendor/jsep/LICENSE.txt +23 -0
  325. package/src/expressions/vendor/jsep/runtime.ts +949 -0
  326. package/src/expressions/vendor/jsep/types.ts +191 -0
  327. package/src/index.ts +54 -0
  328. package/src/math-functions/index.ts +235 -0
  329. package/src/parser/bind-sql-predicate.ts +21 -0
  330. package/src/parser/index.ts +43 -0
  331. package/src/parser/parameter-snapshots.ts +103 -0
  332. package/src/parser/parse-sql-expression.ts +500 -0
  333. package/src/parser/parse-sql-predicate.ts +454 -0
  334. package/src/parser/parse-sql-query.ts +90 -0
  335. package/src/parser/parse-sql-select.ts +272 -0
  336. package/src/parser/parse-sql-statement.ts +260 -0
  337. package/src/parser/query-types.ts +71 -0
  338. package/src/parser/sql-parameters.ts +174 -0
  339. package/src/parser/sql-parse-error.ts +33 -0
  340. package/src/parser/sql-predicate-schema.ts +279 -0
  341. package/src/parser/sql-predicate-types.ts +91 -0
  342. package/src/parser/sql-predicate.ts +28 -0
  343. package/src/scales/arrow-domains.ts +190 -0
  344. package/src/scales/arrow-scales.ts +363 -0
  345. package/src/scales/compile-scale.ts +5 -0
  346. package/src/scales/conformance.ts +186 -0
  347. package/src/scales/hdr-colors.ts +5 -0
  348. package/src/scales/index.ts +37 -0
  349. package/src/scales/palettes.ts +5 -0
  350. package/src/scales/parse-sql-scale.ts +300 -0
  351. package/src/scales/quantile-sketch.ts +5 -0
  352. package/src/scales/scale-types.ts +5 -0
  353. package/src/scales/streaming-domains.ts +139 -0
package/LICENSE ADDED
@@ -0,0 +1,249 @@
1
+ @math.gl/core
2
+
3
+ The math.gl-authored portions are MIT licensed. The following upstream
4
+ notices apply to their respective adapted source or data, as identified in
5
+ source headers and adjacent notices. This file does not relicense those portions.
6
+
7
+ MIT License
8
+
9
+ Copyright (c) 2017 Uber Technologies, Inc.
10
+ Copyright (c) vis.gl contributors
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in
20
+ all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ THE SOFTWARE.
29
+
30
+
31
+ ---
32
+
33
+ gl-matrix
34
+
35
+ math.gl builds on docs and code from "gl-matrix", which is MIT licensed as follows:
36
+
37
+ Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining a copy
40
+ of this software and associated documentation files (the "Software"), to deal
41
+ in the Software without restriction, including without limitation the rights
42
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43
+ copies of the Software, and to permit persons to whom the Software is
44
+ furnished to do so, subject to the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be included in
47
+ all copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
55
+ THE SOFTWARE.
56
+
57
+ ---
58
+
59
+ three.js
60
+
61
+ math.gl builds on docs and code from THREE.js, which is MIT licensed as follows:
62
+
63
+ The MIT License
64
+
65
+ Copyright © 2010-2017 three.js authors
66
+
67
+ Permission is hereby granted, free of charge, to any person obtaining a copy
68
+ of this software and associated documentation files (the "Software"), to deal
69
+ in the Software without restriction, including without limitation the rights
70
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
71
+ copies of the Software, and to permit persons to whom the Software is
72
+ furnished to do so, subject to the following conditions:
73
+
74
+ The above copyright notice and this permission notice shall be included in
75
+ all copies or substantial portions of the Software.
76
+
77
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
78
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
79
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
80
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
81
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
82
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
83
+ THE SOFTWARE.
84
+
85
+ ---
86
+
87
+ proj4js
88
+
89
+ ## Proj4js -- Javascript reprojection library.
90
+
91
+ Authors:
92
+ - Mike Adair madairATdmsolutions.ca
93
+ - Richard Greenwood richATgreenwoodmap.com
94
+ - Didier Richard didier.richardATign.fr
95
+ - Stephen Irons stephen.ironsATclear.net.nz
96
+ - Olivier Terral oterralATgmail.com
97
+ - Calvin Metcalf cmetcalfATappgeo.com
98
+
99
+ Copyright (c) 2014, Mike Adair, Richard Greenwood, Didier Richard, Stephen Irons, Olivier Terral and Calvin Metcalf
100
+
101
+ Permission is hereby granted, free of charge, to any person obtaining a
102
+ copy of this software and associated documentation files (the "Software"),
103
+ to deal in the Software without restriction, including without limitation
104
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
105
+ and/or sell copies of the Software, and to permit persons to whom the
106
+ Software is furnished to do so, subject to the following conditions:
107
+
108
+ The above copyright notice and this permission notice shall be included
109
+ in all copies or substantial portions of the Software.
110
+
111
+ _THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
112
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
113
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
114
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
115
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
116
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
117
+ DEALINGS IN THE SOFTWARE._
118
+
119
+ ---
120
+
121
+ jsep
122
+
123
+ SPDX-License-Identifier: MIT
124
+ SPDX-FileCopyrightText: Copyright (c) 2013 Stephen Oney
125
+
126
+ Copyright (c) 2013 Stephen Oney, https://ericsmekens.github.io/jsep/
127
+
128
+ Permission is hereby granted, free of charge, to any person obtaining
129
+ a copy of this software and associated documentation files (the
130
+ "Software"), to deal in the Software without restriction, including
131
+ without limitation the rights to use, copy, modify, merge, publish,
132
+ distribute, sublicense, and/or sell copies of the Software, and to
133
+ permit persons to whom the Software is furnished to do so, subject to
134
+ the following conditions:
135
+
136
+ The above copyright notice and this permission notice shall be
137
+ included in all copies or substantial portions of the Software.
138
+
139
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
140
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
141
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
142
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
143
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
144
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
145
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
146
+
147
+ ---
148
+
149
+ expression-eval
150
+
151
+ Copyright (c) 2023 Don McCurdy
152
+
153
+ Permission is hereby granted, free of charge, to any person obtaining a copy
154
+ of this software and associated documentation files (the "Software"), to deal
155
+ in the Software without restriction, including without limitation the rights
156
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
157
+ copies of the Software, and to permit persons to whom the Software is
158
+ furnished to do so, subject to the following conditions:
159
+
160
+ The above copyright notice and this permission notice shall be included in
161
+ all copies or substantial portions of the Software.
162
+
163
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
164
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
166
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
167
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
168
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
169
+ THE SOFTWARE.
170
+
171
+
172
+ ---
173
+
174
+ Apache Arrow BigInt compatibility adaptation
175
+
176
+ Apache Arrow
177
+ Copyright 2016-2019 The Apache Software Foundation
178
+
179
+ This product includes software developed at
180
+ The Apache Software Foundation (http://www.apache.org/).
181
+
182
+ The notice above is the applicable ASF notice from Apache Arrow 4.0.0's
183
+ NOTICE.txt for the adapted JavaScript BigInt compatibility code. Notices for
184
+ unrelated Arrow components are not reproduced here because those components
185
+ are not included in this adaptation.
186
+
187
+ Upstream comparison:
188
+ https://github.com/apache/arrow/blob/apache-arrow-4.0.0/js/src/util/compat.ts
189
+ https://github.com/apache/arrow/blob/apache-arrow-4.0.0/NOTICE.txt
190
+
191
+ math.gl modifications: extraction of the BigInt availability/fallback layer,
192
+ separate availability constants, shared error messages, and narrower exports.
193
+ The comparison version is documented; the original port commit is not known.
194
+
195
+ Apache License
196
+
197
+ Version 2.0, January 2004
198
+
199
+ http://www.apache.org/licenses/
200
+
201
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
202
+
203
+ 1. Definitions.
204
+
205
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
206
+
207
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
208
+
209
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
210
+
211
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
212
+
213
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
214
+
215
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
216
+
217
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
218
+
219
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
220
+
221
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
222
+
223
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
224
+
225
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
226
+
227
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
228
+
229
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
230
+
231
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
232
+
233
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
234
+
235
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
236
+
237
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
238
+
239
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
240
+
241
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
242
+
243
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
244
+
245
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
246
+
247
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
248
+
249
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,3 +1,27 @@
1
- # Temporary Holding Version
1
+ # @math.gl/sql
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A lightweight SQL query engine for Apache Arrow tables.
4
+
5
+ ```bash
6
+ npm install @math.gl/sql apache-arrow
7
+ ```
8
+
9
+ ```ts
10
+ import {tableFromArrays} from 'apache-arrow';
11
+ import {queryArrowSQL} from '@math.gl/sql';
12
+
13
+ const orders = tableFromArrays({quantity: new Int32Array([2, 1, 3])});
14
+ const result = queryArrowSQL(
15
+ 'SELECT SUM(quantity) AS units FROM orders',
16
+ new Map([['orders', orders]])
17
+ );
18
+ console.log(result.getChild('units')?.get(0)); // 6n
19
+ ```
20
+
21
+ Query native Arrow tables, compute columns, aggregate record batches, or run structured queries
22
+ in workers. Apache Arrow 17 or later is required for execution. The `/parser` and `/expressions`
23
+ entry points work without Arrow. Optional `/math-functions` and `/color-functions` entries
24
+ provide typed query functions.
25
+
26
+ See the [SQL documentation](https://math.gl/docs/modules/sql) for the supported SQL subset,
27
+ streaming APIs, worker execution, and examples.
@@ -0,0 +1,5 @@
1
+ # Third-party notices
2
+
3
+ | Copyright | Component |
4
+ | --- | --- |
5
+ | Stephen Oney / jsep contributors | Vendored jsep 1.4.0 parser; MIT, [version and modifications](https://github.com/visgl/math.gl/blob/master/modules/sql/src/expressions/vendor/jsep/README.md), [license](./src/expressions/vendor/jsep/LICENSE.txt). |
@@ -0,0 +1,46 @@
1
+ import { type Table, type RecordBatch } from 'apache-arrow';
2
+ import type { ArrowExpression, ArrowExpressionOptions, ArrowExpressionValue } from "./types.js";
3
+ type Operation = 'COUNT' | 'SUM' | 'MIN' | 'MAX' | 'AVG' | 'EVERY' | 'BOOL_AND' | 'BOOL_OR' | 'BIT_AND' | 'BIT_OR' | 'BIT_XOR';
4
+ /** One scalar reduction. Omit the COUNT expression for COUNT(*). */
5
+ export type ArrowAggregate = {
6
+ readonly operation: 'COUNT';
7
+ readonly expression?: ArrowExpression;
8
+ } | {
9
+ readonly operation: Exclude<Operation, 'COUNT'>;
10
+ readonly expression: ArrowExpression;
11
+ };
12
+ export interface ArrowAggregateAccumulator<K extends string> {
13
+ /** Adds a batch. A failed expression leaves the previous state intact. */
14
+ update(batch: RecordBatch, options?: {
15
+ signal?: AbortSignal;
16
+ }): void;
17
+ /** Adds the partial state of another accumulator from this compiled plan. */
18
+ merge(other: ArrowAggregateAccumulator<K>): void;
19
+ /** Returns a snapshot. Further batches may change the next result. */
20
+ result(): Record<K, ArrowExpressionValue>;
21
+ }
22
+ /** Incrementally reduces rows into groups without storing the input rows. */
23
+ export interface ArrowGroupedAggregateAccumulator<K extends string> {
24
+ /** Adds one batch atomically. An expression error or cancellation leaves the previous state intact. */
25
+ update(batch: RecordBatch, options?: {
26
+ signal?: AbortSignal;
27
+ }): void;
28
+ /** Returns a detached snapshot in first-seen key order. Null keys form one group. */
29
+ result(): ReadonlyMap<ArrowExpressionValue, Record<K, ArrowExpressionValue>>;
30
+ }
31
+ /** A schema-bound plan for scalar or grouped reductions. */
32
+ export interface CompiledArrowAggregates<K extends string> {
33
+ /** Starts a grouped reduction using one scalar key expression. */
34
+ createGroupedAccumulator(groupBy: ArrowExpression): ArrowGroupedAggregateAccumulator<K>;
35
+ createAccumulator(): ArrowAggregateAccumulator<K>;
36
+ evaluate(input: Table | Iterable<RecordBatch>, options?: {
37
+ signal?: AbortSignal;
38
+ }): Record<K, ArrowExpressionValue>;
39
+ evaluateInBatches(input: AsyncIterable<RecordBatch> | Iterable<RecordBatch>, options?: {
40
+ signal?: AbortSignal;
41
+ }): Promise<Record<K, ArrowExpressionValue>>;
42
+ }
43
+ /** Compiles named scalar aggregates. Identical expression strings or shared ASTs run once per batch. */
44
+ export declare function compileArrowAggregates<K extends string>(aggregates: Readonly<Record<K, ArrowAggregate>>, options: ArrowExpressionOptions): CompiledArrowAggregates<K>;
45
+ export {};
46
+ //# sourceMappingURL=aggregates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregates.d.ts","sourceRoot":"","sources":["../../src/arrow/aggregates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,KAAK,EAAE,KAAK,WAAW,EAAC,MAAM,cAAc,CAAC;AAIpE,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EAErB,mBAAgB;AAEjB,KAAK,SAAS,GACV,OAAO,GACP,KAAK,GACL,KAAK,GACL,KAAK,GACL,K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AAC,CAAC;IAClD,QAAQ,CACN,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,EACpC,OAAO,CAAC,EAAE;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAC,GAC/B,MAAM,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IACnC,iBAAiB,CACf,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACzD,OAAO,CAAC,EAAE;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC;CAC7C;AA6BD,wGAAwG;AACxG,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EACrD,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAC/C,OAAO,EAAE,sBAAsB,GAC9B,uBAAuB,CAAC,CAAC,CAAC,CAiI5B"}
@@ -0,0 +1,289 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+ import { DataType } from 'apache-arrow';
5
+ import { compareUTF8 } from '@math.gl/core/utf8';
6
+ import { ColumnReader, valueType } from "./buffers.js";
7
+ import { compileArrowExpression } from "./compiler.js";
8
+ const reductions = new Set([
9
+ 'MIN',
10
+ 'MAX',
11
+ 'EVERY',
12
+ 'BOOL_AND',
13
+ 'BOOL_OR',
14
+ 'BIT_AND',
15
+ 'BIT_OR',
16
+ 'BIT_XOR'
17
+ ]);
18
+ /** Compiles named scalar aggregates. Identical expression strings or shared ASTs run once per batch. */
19
+ export function compileArrowAggregates(aggregates, options) {
20
+ const groups = [];
21
+ const byExpression = new Map();
22
+ const outputs = Object.entries(aggregates).map(([name, aggregate]) => {
23
+ const { operation, expression } = aggregate;
24
+ if (!reductions.has(operation) && !['COUNT', 'SUM', 'AVG'].includes(operation))
25
+ throw new Error(`Unsupported Arrow aggregate: ${operation}`);
26
+ if (expression === undefined && operation !== 'COUNT')
27
+ throw new Error(`${operation} requires an expression`);
28
+ let group = byExpression.get(expression);
29
+ if (!group) {
30
+ const compiled = expression === undefined ? undefined : compileArrowExpression(expression, options);
31
+ const type = compiled && valueType(compiled.outputField.type);
32
+ group = {
33
+ expression: compiled,
34
+ operations: new Set(),
35
+ integer: Boolean(type && DataType.isInt(type)),
36
+ wide: Boolean(type && DataType.isInt(type) && type.bitWidth === 64),
37
+ utf8: Boolean(type && DataType.isUtf8(type)),
38
+ sums: false,
39
+ reductions: []
40
+ };
41
+ byExpression.set(expression, group);
42
+ groups.push(group);
43
+ }
44
+ const type = group.expression && valueType(group.expression.outputField.type);
45
+ if (type && !DataType.isNull(type) && operation !== 'COUNT') {
46
+ const numeric = group.integer || DataType.isFloat(type);
47
+ const supported = operation.startsWith('BIT_')
48
+ ? group.integer
49
+ : operation === 'EVERY' || operation.startsWith('BOOL_')
50
+ ? DataType.isBool(type)
51
+ : numeric || (group.utf8 && (operation === 'MIN' || operation === 'MAX'));
52
+ if (!supported)
53
+ throw new Error(`${operation} does not support Arrow type ${type}`);
54
+ }
55
+ group.operations.add(operation);
56
+ return { name, operation, group };
57
+ });
58
+ for (const group of groups) {
59
+ group.sums = group.operations.has('SUM') || group.operations.has('AVG');
60
+ group.reductions = [...group.operations].filter(operation => reductions.has(operation));
61
+ }
62
+ /** Materializes one aggregate result without exposing accumulator state. */
63
+ const resultFor = (states) => Object.fromEntries(outputs.map(({ name, operation, group }) => [
64
+ name,
65
+ finish(operation, group, states.get(group))
66
+ ]));
67
+ const accumulators = new WeakMap();
68
+ const createAccumulator = () => {
69
+ const states = new Map(groups.map(group => [group, emptyState(group)]));
70
+ const accumulator = {
71
+ update(batch, { signal } = {}) {
72
+ signal?.throwIfAborted();
73
+ const partials = groups.map(group => summarize(group, batch, signal)[0]);
74
+ signal?.throwIfAborted();
75
+ groups.forEach((group, index) => mergeState(group, states.get(group), partials[index]));
76
+ },
77
+ merge(other) {
78
+ const source = accumulators.get(other);
79
+ if (!source || other === accumulator)
80
+ throw new Error('Merge requires another accumulator from the same Arrow aggregate plan');
81
+ for (const group of groups)
82
+ mergeState(group, states.get(group), source.get(group));
83
+ },
84
+ result() {
85
+ return resultFor(states);
86
+ }
87
+ };
88
+ accumulators.set(accumulator, states);
89
+ return accumulator;
90
+ };
91
+ return {
92
+ createAccumulator,
93
+ createGroupedAccumulator(groupBy) {
94
+ const keyExpression = compileArrowExpression(groupBy, options);
95
+ const type = valueType(keyExpression.outputField.type);
96
+ if (!(DataType.isInt(type) ||
97
+ DataType.isFloat(type) ||
98
+ DataType.isBool(type) ||
99
+ DataType.isUtf8(type) ||
100
+ DataType.isNull(type))) {
101
+ throw new Error(`Unsupported Arrow aggregate group key type: ${type}`);
102
+ }
103
+ const statesByKey = new Map();
104
+ return {
105
+ update(batch, { signal } = {}) {
106
+ const partition = partitionRows(keyExpression, batch, signal);
107
+ const partials = groups.map(group => summarize(group, batch, signal, partition));
108
+ signal?.throwIfAborted();
109
+ for (const [key, index] of partition.indexByKey) {
110
+ let states = statesByKey.get(key);
111
+ if (!states) {
112
+ states = new Map(groups.map(group => [group, emptyState(group)]));
113
+ statesByKey.set(key, states);
114
+ }
115
+ groups.forEach((group, groupIndex) => mergeState(group, states.get(group), partials[groupIndex][index]));
116
+ }
117
+ },
118
+ result() {
119
+ return new Map(Array.from(statesByKey, ([key, states]) => [key, resultFor(states)]));
120
+ }
121
+ };
122
+ },
123
+ evaluate(input, evaluation) {
124
+ evaluation?.signal?.throwIfAborted();
125
+ const accumulator = createAccumulator();
126
+ for (const batch of 'batches' in input ? input.batches : input)
127
+ accumulator.update(batch, evaluation);
128
+ return accumulator.result();
129
+ },
130
+ async evaluateInBatches(input, evaluation) {
131
+ evaluation?.signal?.throwIfAborted();
132
+ const accumulator = createAccumulator();
133
+ for await (const batch of input)
134
+ accumulator.update(batch, evaluation);
135
+ evaluation?.signal?.throwIfAborted();
136
+ return accumulator.result();
137
+ }
138
+ };
139
+ }
140
+ function emptyState(group) {
141
+ return { count: 0n, sum: group.integer ? 0n : 0, values: new Map() };
142
+ }
143
+ /** Resolves one group key per row and records first-seen order. */
144
+ function partitionRows(expression, batch, signal) {
145
+ const reader = new ColumnReader(expression.evaluate(batch, { signal }));
146
+ const indexByKey = new Map();
147
+ const indexByRow = new Uint32Array(batch.numRows);
148
+ const rowCounts = [];
149
+ for (let row = 0; row < batch.numRows; row++) {
150
+ if (row % 1024 === 0)
151
+ signal?.throwIfAborted();
152
+ const key = reader.get(row);
153
+ if (typeof key === 'number' && !Number.isFinite(key))
154
+ throw new Error('Arrow aggregate group keys must be finite');
155
+ let index = indexByKey.get(key);
156
+ if (index === undefined) {
157
+ index = indexByKey.size;
158
+ indexByKey.set(key, index);
159
+ rowCounts.push(0);
160
+ }
161
+ indexByRow[row] = index;
162
+ rowCounts[index]++;
163
+ }
164
+ return { indexByKey, indexByRow, rowCounts };
165
+ }
166
+ /** Reduces one expression across the batch, optionally routing rows to groups. */
167
+ function summarize(group, batch, signal, partition) {
168
+ const states = Array.from({ length: partition?.indexByKey.size ?? 1 }, () => emptyState(group));
169
+ if (!group.expression) {
170
+ for (let index = 0; index < states.length; index++)
171
+ states[index].count = BigInt(partition?.rowCounts[index] ?? batch.numRows);
172
+ return states;
173
+ }
174
+ const vector = group.expression.evaluate(batch, { signal });
175
+ const countOnly = !group.sums && !group.reductions.length;
176
+ if (countOnly && !partition) {
177
+ states[0].count = BigInt(vector.length - vector.nullCount);
178
+ return states;
179
+ }
180
+ const reader = new ColumnReader(vector);
181
+ const counts = Array.from({ length: states.length }, () => 0);
182
+ for (let row = 0; row < vector.length; row++) {
183
+ if (row % 1024 === 0)
184
+ signal?.throwIfAborted();
185
+ const index = partition?.indexByRow[row] ?? 0;
186
+ const state = states[index];
187
+ if (countOnly || group.utf8) {
188
+ if (!reader.isValid(row))
189
+ continue;
190
+ counts[index]++;
191
+ if (countOnly)
192
+ continue;
193
+ const bytes = reader.utf8(row);
194
+ for (const operation of group.reductions) {
195
+ const previous = state.values.get(operation);
196
+ if (winsUTF8(operation, bytes, previous))
197
+ state.values.set(operation, bytes[0].slice(bytes[1], bytes[2]));
198
+ }
199
+ }
200
+ else {
201
+ const value = reader.get(row);
202
+ if (value === null)
203
+ continue;
204
+ counts[index]++;
205
+ if (group.sums)
206
+ state.sum = add(group, state.sum, value);
207
+ for (const operation of group.reductions) {
208
+ const operand = operation.startsWith('BIT_') ? BigInt(value) : value;
209
+ state.values.set(operation, reduce(operation, state.values.get(operation), operand));
210
+ }
211
+ }
212
+ }
213
+ states.forEach((state, index) => {
214
+ state.count = BigInt(counts[index]);
215
+ });
216
+ return states;
217
+ }
218
+ function add(group, left, right) {
219
+ return group.integer ? BigInt(left) + BigInt(right) : Number(left) + Number(right);
220
+ }
221
+ function winsUTF8(operation, [bytes, start, end], previous) {
222
+ if (!previous)
223
+ return true;
224
+ const order = compareUTF8(bytes, start, end, previous, 0, previous.length);
225
+ return operation === 'MIN' ? order < 0 : order > 0;
226
+ }
227
+ function reduce(operation, left, right) {
228
+ if (left === undefined)
229
+ return right;
230
+ switch (operation) {
231
+ case 'MIN':
232
+ return typeof left === 'number'
233
+ ? Math.min(left, right)
234
+ : left < right
235
+ ? left
236
+ : right;
237
+ case 'MAX':
238
+ return typeof left === 'number'
239
+ ? Math.max(left, right)
240
+ : left > right
241
+ ? left
242
+ : right;
243
+ case 'EVERY':
244
+ case 'BOOL_AND':
245
+ return Boolean(left && right);
246
+ case 'BOOL_OR':
247
+ return Boolean(left || right);
248
+ case 'BIT_AND':
249
+ return left & right;
250
+ case 'BIT_OR':
251
+ return left | right;
252
+ case 'BIT_XOR':
253
+ return left ^ right;
254
+ default:
255
+ throw new Error(`Invalid Arrow reduction: ${operation}`);
256
+ }
257
+ }
258
+ function mergeState(group, target, source) {
259
+ if (!source.count)
260
+ return;
261
+ target.count += source.count;
262
+ if (group.sums)
263
+ target.sum = add(group, target.sum, source.sum);
264
+ for (const [operation, value] of source.values) {
265
+ const previous = target.values.get(operation);
266
+ if (value instanceof Uint8Array) {
267
+ if (winsUTF8(operation, [value, 0, value.length], previous))
268
+ target.values.set(operation, value);
269
+ }
270
+ else {
271
+ target.values.set(operation, reduce(operation, previous, value));
272
+ }
273
+ }
274
+ }
275
+ function finish(operation, group, state) {
276
+ if (operation === 'COUNT')
277
+ return state.count;
278
+ if (!state.count)
279
+ return null;
280
+ if (operation === 'SUM')
281
+ return state.sum;
282
+ if (operation === 'AVG')
283
+ return Number(state.sum) / Number(state.count);
284
+ const value = state.values.get(operation);
285
+ if (value instanceof Uint8Array)
286
+ return new TextDecoder().decode(value);
287
+ return operation.startsWith('BIT_') && !group.wide ? Number(value) : value;
288
+ }
289
+ //# sourceMappingURL=aggregates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregates.js","sourceRoot":"","sources":["../../src/arrow/aggregates.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,QAAQ,EAA+B,MAAM,cAAc,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,qBAAkB;AAClD,OAAO,EAAC,sBAAsB,EAAC,sBAAmB;AA0ElD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAY;IACpC,KAAK;IACL,KAAK;IACL,OAAO;IACP,UAAU;IACV,SAAS;IACT,SAAS;IACT,QAAQ;IACR,SAAS;CACV,CAAC,CAAC;AAEH,wGAAwG;AACxG,MAAM,UAAU,sBAAsB,CACpC,UAA+C,EAC/C,OAA+B;IAE/B,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,MAAM,YAAY,GAAG,IAAI,GAAG,EAAsC,CAAC;IACnE,MAAM,OAAO,GAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAA2B,CAAC,GAAG,CAAC,CAAC,CAAC,I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