@loaders.gl/core 5.0.0-beta.10 → 5.0.0-beta.11

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 (313) hide show
  1. package/SCAN-README.md +2 -2
  2. package/dist/arrow-geometry/feature-collection-to-arrow.cjs +1 -5
  3. package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
  4. package/dist/arrow-geometry/feature-collection-to-arrow.d.ts +4 -3
  5. package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
  6. package/dist/arrow-geometry/feature-collection-to-arrow.js +2 -6
  7. package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
  8. package/dist/arrow-geometry/feature-table.cjs +2 -10
  9. package/dist/arrow-geometry/feature-table.cjs.map +2 -2
  10. package/dist/arrow-geometry/feature-table.d.ts +6 -5
  11. package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
  12. package/dist/arrow-geometry/feature-table.js +5 -13
  13. package/dist/arrow-geometry/feature-table.js.map +1 -1
  14. package/dist/arrow-geometry/wkb-arrow-utils.cjs +1 -5
  15. package/dist/arrow-geometry/wkb-arrow-utils.cjs.map +2 -2
  16. package/dist/arrow-geometry/wkb-arrow-utils.d.ts +7 -7
  17. package/dist/arrow-geometry/wkb-arrow-utils.d.ts.map +1 -1
  18. package/dist/arrow-geometry/wkb-arrow-utils.js +4 -8
  19. package/dist/arrow-geometry/wkb-arrow-utils.js.map +1 -1
  20. package/dist/arrow-worker-transport.cjs +7 -75
  21. package/dist/arrow-worker-transport.cjs.map +1 -1
  22. package/dist/arrow-worker-transport.d.ts +3 -7
  23. package/dist/arrow-worker-transport.d.ts.map +1 -1
  24. package/dist/arrow-worker-transport.js +15 -89
  25. package/dist/arrow-worker-transport.js.map +1 -1
  26. package/dist/cluster-source.cjs +12 -12
  27. package/dist/cluster-source.cjs.map +1 -1
  28. package/dist/dist.dev.js +71 -60
  29. package/dist/dist.min.js +3 -3
  30. package/dist/federated-table-scan-source.cjs +87 -125
  31. package/dist/federated-table-scan-source.cjs.map +2 -2
  32. package/dist/geoarrow/clustering/cluster-source.cjs +12 -12
  33. package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
  34. package/dist/geoarrow/clustering/cluster-source.d.ts +3 -2
  35. package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
  36. package/dist/geoarrow/clustering/cluster-source.js +12 -14
  37. package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
  38. package/dist/geoarrow/convert-table-to-geoarrow.cjs +4 -12
  39. package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
  40. package/dist/geoarrow/convert-table-to-geoarrow.d.ts +5 -5
  41. package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
  42. package/dist/geoarrow/convert-table-to-geoarrow.js +6 -14
  43. package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
  44. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +1 -1
  45. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
  46. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +2 -2
  47. package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
  48. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +2 -3
  49. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
  50. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
  51. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
  52. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +2 -3
  53. package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
  54. package/dist/geoarrow/geoarrow-stream.cjs +10 -11
  55. package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
  56. package/dist/geoarrow/geoarrow-stream.d.ts +2 -2
  57. package/dist/geoarrow/geoarrow-stream.d.ts.map +1 -1
  58. package/dist/geoarrow/geoarrow-stream.js +9 -12
  59. package/dist/geoarrow/geoarrow-stream.js.map +1 -1
  60. package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.cjs.map +1 -1
  61. package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js +3 -3
  62. package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js.map +1 -1
  63. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
  64. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +5 -2
  65. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
  66. package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
  67. package/dist/index.cjs +69 -54
  68. package/dist/index.cjs.map +3 -3
  69. package/dist/index.d.ts +1 -1
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +1 -1
  72. package/dist/index.js.map +1 -1
  73. package/dist/lib/api/load.d.ts.map +1 -1
  74. package/dist/lib/api/load.js +2 -4
  75. package/dist/lib/api/load.js.map +1 -1
  76. package/dist/lib/api/loader-options.d.ts +6 -0
  77. package/dist/lib/api/loader-options.d.ts.map +1 -1
  78. package/dist/lib/api/loader-options.js +48 -0
  79. package/dist/lib/api/loader-options.js.map +1 -1
  80. package/dist/lib/api/parse-file.d.ts.map +1 -1
  81. package/dist/lib/api/parse-file.js +2 -5
  82. package/dist/lib/api/parse-file.js.map +1 -1
  83. package/dist/lib/api/parse-in-batches.js +6 -10
  84. package/dist/lib/api/parse-in-batches.js.map +1 -1
  85. package/dist/lib/api/parse-sync.d.ts.map +1 -1
  86. package/dist/lib/api/parse-sync.js +2 -5
  87. package/dist/lib/api/parse-sync.js.map +1 -1
  88. package/dist/lib/api/parse.d.ts.map +1 -1
  89. package/dist/lib/api/parse.js +2 -5
  90. package/dist/lib/api/parse.js.map +1 -1
  91. package/dist/lib/init.js +1 -1
  92. package/dist/lib/loader-utils/native-arrow.d.ts +5 -8
  93. package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
  94. package/dist/lib/loader-utils/native-arrow.js +13 -31
  95. package/dist/lib/loader-utils/native-arrow.js.map +1 -1
  96. package/dist/loader-utils/index.cjs +27 -22
  97. package/dist/loader-utils/index.cjs.map +1 -1
  98. package/dist/loader-utils/index.d.ts +1 -1
  99. package/dist/loader-utils/index.d.ts.map +1 -1
  100. package/dist/loader-utils/index.js +1 -1
  101. package/dist/loader-utils/index.js.map +1 -1
  102. package/dist/loader-utils/json-loader.js +1 -1
  103. package/dist/loader-utils/lib/log-utils/log.js +1 -1
  104. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +6 -2
  105. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
  106. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +1 -0
  107. package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
  108. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +15 -12
  109. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
  110. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +36 -22
  111. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
  112. package/dist/loader-utils/lib/sources/table-source-collection.d.ts +2 -1
  113. package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -1
  114. package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -3
  115. package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
  116. package/dist/loader-utils/loader-types.d.ts +3 -5
  117. package/dist/loader-utils/loader-types.d.ts.map +1 -1
  118. package/dist/null-loader.js +1 -1
  119. package/dist/null-worker-node.js +1 -1
  120. package/dist/null-worker.js +1 -1
  121. package/dist/scan/arrow-execution/expressions.cjs +4 -4
  122. package/dist/scan/arrow-execution/expressions.cjs.map +2 -2
  123. package/dist/scan/arrow-execution/expressions.d.ts +4 -4
  124. package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
  125. package/dist/scan/arrow-execution/expressions.js +4 -4
  126. package/dist/scan/arrow-execution/expressions.js.map +1 -1
  127. package/dist/scan/arrow-query-worker-entry.cjs +121 -0
  128. package/dist/scan/arrow-query-worker-entry.cjs.map +7 -0
  129. package/dist/scan/arrow-query-worker-entry.d.ts +2 -0
  130. package/dist/scan/arrow-query-worker-entry.d.ts.map +1 -0
  131. package/dist/scan/arrow-query-worker-entry.js +7 -0
  132. package/dist/scan/arrow-query-worker-entry.js.map +1 -0
  133. package/dist/scan/arrow-query-worker.cjs +197 -0
  134. package/dist/scan/arrow-query-worker.cjs.map +7 -0
  135. package/dist/scan/arrow-query-worker.d.ts +47 -0
  136. package/dist/scan/arrow-query-worker.d.ts.map +1 -0
  137. package/dist/scan/arrow-query-worker.js +101 -0
  138. package/dist/scan/arrow-query-worker.js.map +1 -0
  139. package/dist/scan/federated-table-scan-source.cjs +12 -13
  140. package/dist/scan/federated-table-scan-source.cjs.map +2 -2
  141. package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
  142. package/dist/scan/federated-table-scan-source.js +14 -15
  143. package/dist/scan/federated-table-scan-source.js.map +1 -1
  144. package/dist/scan/index.cjs +5 -2
  145. package/dist/scan/index.cjs.map +2 -2
  146. package/dist/scan/index.d.ts +2 -1
  147. package/dist/scan/index.d.ts.map +1 -1
  148. package/dist/scan/index.js +2 -1
  149. package/dist/scan/index.js.map +1 -1
  150. package/dist/scan/parse-sql-predicate.cjs +2 -2
  151. package/dist/scan/parse-sql-predicate.cjs.map +2 -2
  152. package/dist/scan/parse-sql-predicate.js +1 -1
  153. package/dist/scan/parse-sql-predicate.js.map +1 -1
  154. package/dist/scan/query-pushdown.cjs +6 -6
  155. package/dist/scan/query-pushdown.cjs.map +2 -2
  156. package/dist/scan/query-pushdown.d.ts +1 -1
  157. package/dist/scan/query-pushdown.d.ts.map +1 -1
  158. package/dist/scan/query-pushdown.js +3 -6
  159. package/dist/scan/query-pushdown.js.map +1 -1
  160. package/dist/scan/query-scales.cjs +140 -0
  161. package/dist/scan/query-scales.cjs.map +7 -0
  162. package/dist/scan/query-scales.d.ts +35 -0
  163. package/dist/scan/query-scales.d.ts.map +1 -0
  164. package/dist/scan/query-scales.js +120 -0
  165. package/dist/scan/query-scales.js.map +1 -0
  166. package/dist/scan/query.cjs +49 -45
  167. package/dist/scan/query.cjs.map +2 -2
  168. package/dist/scan/query.d.ts +7 -4
  169. package/dist/scan/query.d.ts.map +1 -1
  170. package/dist/scan/query.js +35 -52
  171. package/dist/scan/query.js.map +1 -1
  172. package/dist/scan/vector-table-scan-source.cjs +19 -13
  173. package/dist/scan/vector-table-scan-source.cjs.map +3 -3
  174. package/dist/scan/vector-table-scan-source.d.ts +3 -4
  175. package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
  176. package/dist/scan/vector-table-scan-source.js +11 -12
  177. package/dist/scan/vector-table-scan-source.js.map +1 -1
  178. package/dist/schema/categories/category-mesh.d.ts +3 -10
  179. package/dist/schema/categories/category-mesh.d.ts.map +1 -1
  180. package/dist/schema/categories/category-mesh.js.map +1 -1
  181. package/dist/schema/categories/category-table.d.ts +2 -19
  182. package/dist/schema/categories/category-table.d.ts.map +1 -1
  183. package/dist/schema/geometry/arrow-binary-features.d.ts +1 -1
  184. package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -1
  185. package/dist/schema/index.cjs.map +1 -1
  186. package/dist/schema/index.d.ts +2 -2
  187. package/dist/schema/index.d.ts.map +1 -1
  188. package/dist/schema/index.js.map +1 -1
  189. package/dist/schema/types/batch.d.ts +0 -4
  190. package/dist/schema/types/batch.d.ts.map +1 -1
  191. package/dist/schema-utils/index.cjs +419 -502
  192. package/dist/schema-utils/index.cjs.map +3 -3
  193. package/dist/schema-utils/index.d.ts +4 -5
  194. package/dist/schema-utils/index.d.ts.map +1 -1
  195. package/dist/schema-utils/index.js +4 -5
  196. package/dist/schema-utils/index.js.map +1 -1
  197. package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +4 -5
  198. package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
  199. package/dist/schema-utils/lib/arrow/arrow-metadata.js +21 -18
  200. package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
  201. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +6 -11
  202. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
  203. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +8 -21
  204. package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
  205. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -4
  206. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
  207. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +13 -15
  208. package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
  209. package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
  210. package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
  211. package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +1 -1
  212. package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
  213. package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +2 -1
  214. package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -1
  215. package/dist/schema-utils/lib/schema/deduce-table-schema.js +3 -1
  216. package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
  217. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +6 -5
  218. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
  219. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +6 -5
  220. package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -1
  221. package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
  222. package/dist/schema-utils/lib/table/batches/convert-batches.js +5 -8
  223. package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
  224. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +1 -1
  225. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
  226. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +2 -6
  227. package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
  228. package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +1 -1
  229. package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
  230. package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +4 -24
  231. package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
  232. package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +3 -6
  233. package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
  234. package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +6 -57
  235. package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
  236. package/dist/schema-utils/lib/table/tables/make-table.js +2 -2
  237. package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
  238. package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
  239. package/dist/schema-utils/lib/table/tables/table-accessors.js +2 -16
  240. package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
  241. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +2 -2
  242. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
  243. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +4 -4
  244. package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
  245. package/dist/schema-utils/lib/table/tables/table-types.d.ts +1 -3
  246. package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -1
  247. package/dist/schema-utils/lib/table/tables/table-types.js +0 -4
  248. package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -1
  249. package/dist/vector-table-scan-source.cjs +16 -10
  250. package/dist/vector-table-scan-source.cjs.map +2 -2
  251. package/dist/worker-utils/index.cjs +2 -2
  252. package/dist/worker-utils/lib/env-utils/version.js +1 -1
  253. package/package.json +23 -8
  254. package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -8
  255. package/src/arrow-geometry/feature-table.ts +8 -21
  256. package/src/arrow-geometry/wkb-arrow-utils.ts +8 -12
  257. package/src/arrow-worker-transport.ts +21 -120
  258. package/src/geoarrow/clustering/cluster-source.ts +16 -23
  259. package/src/geoarrow/convert-table-to-geoarrow.ts +11 -23
  260. package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +2 -2
  261. package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +2 -4
  262. package/src/geoarrow/geoarrow-stream.ts +15 -15
  263. package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts +3 -3
  264. package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +7 -5
  265. package/src/index.ts +1 -1
  266. package/src/lib/api/load.ts +2 -12
  267. package/src/lib/api/loader-options.ts +69 -0
  268. package/src/lib/api/parse-file.ts +2 -11
  269. package/src/lib/api/parse-in-batches.ts +8 -12
  270. package/src/lib/api/parse-sync.ts +3 -7
  271. package/src/lib/api/parse.ts +2 -6
  272. package/src/lib/loader-utils/native-arrow.ts +12 -38
  273. package/src/loader-utils/index.ts +0 -1
  274. package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +7 -6
  275. package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +64 -41
  276. package/src/loader-utils/lib/sources/table-source-collection.ts +2 -1
  277. package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -9
  278. package/src/loader-utils/loader-types.ts +3 -3
  279. package/src/scan/arrow-execution/expressions.ts +7 -7
  280. package/src/scan/arrow-query-worker-entry.ts +8 -0
  281. package/src/scan/arrow-query-worker.ts +158 -0
  282. package/src/scan/federated-table-scan-source.ts +15 -18
  283. package/src/scan/index.ts +7 -1
  284. package/src/scan/parse-sql-predicate.ts +1 -1
  285. package/src/scan/query-pushdown.ts +7 -7
  286. package/src/scan/query-scales.ts +199 -0
  287. package/src/scan/query.ts +68 -71
  288. package/src/scan/vector-table-scan-source.ts +16 -21
  289. package/src/schema/categories/category-mesh.ts +3 -11
  290. package/src/schema/categories/category-table.ts +2 -28
  291. package/src/schema/geometry/arrow-binary-features.ts +1 -1
  292. package/src/schema/index.ts +1 -3
  293. package/src/schema/types/batch.ts +0 -5
  294. package/src/schema-utils/index.ts +4 -10
  295. package/src/schema-utils/lib/arrow/arrow-metadata.ts +33 -30
  296. package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +12 -38
  297. package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +15 -18
  298. package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +4 -13
  299. package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
  300. package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +10 -9
  301. package/src/schema-utils/lib/table/batches/convert-batches.ts +5 -8
  302. package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +2 -6
  303. package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +5 -27
  304. package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +9 -72
  305. package/src/schema-utils/lib/table/tables/make-table.ts +2 -2
  306. package/src/schema-utils/lib/table/tables/table-accessors.ts +2 -22
  307. package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +6 -6
  308. package/src/schema-utils/lib/table/tables/table-types.ts +1 -7
  309. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +0 -27
  310. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +0 -1
  311. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +0 -23
  312. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +0 -1
  313. package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +0 -54
@@ -2,5 +2,74 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ import type {LoaderOptions} from '../../loader-utils/loader-types';
6
+
5
7
  export {setGlobalOptions as setLoaderOptions} from '../loader-utils/option-utils';
6
8
  export {getGlobalLoaderOptions as getLoaderOptions} from '../loader-utils/option-utils';
9
+
10
+ /**
11
+ * Compares two option inputs without applying loader defaults or global options.
12
+ * Compares plain objects and arrays recursively, and callbacks and other objects by reference.
13
+ */
14
+ export function compareLoaderOptions(
15
+ left: LoaderOptions | undefined,
16
+ right: LoaderOptions | undefined
17
+ ): boolean {
18
+ return Object.is(left, right) || compareOptionValues(left, right, new WeakMap());
19
+ }
20
+
21
+ /** Compares option values and tracks visited object pairs to handle cycles. */
22
+ function compareOptionValues(
23
+ left: unknown,
24
+ right: unknown,
25
+ visited: WeakMap<object, WeakSet<object>>
26
+ ): boolean {
27
+ if (Object.is(left, right)) {
28
+ return true;
29
+ }
30
+ if (!left || !right || typeof left !== 'object' || typeof right !== 'object') {
31
+ return false;
32
+ }
33
+
34
+ const leftPrototype = Object.getPrototypeOf(left);
35
+ if (leftPrototype !== Object.getPrototypeOf(right)) {
36
+ return false;
37
+ }
38
+ if (Array.isArray(left)) {
39
+ if (!Array.isArray(right) || left.length !== right.length) {
40
+ return false;
41
+ }
42
+ } else if (leftPrototype !== Object.prototype && leftPrototype !== null) {
43
+ return false;
44
+ }
45
+
46
+ let rightValues = visited.get(left);
47
+ if (rightValues?.has(right)) {
48
+ return true;
49
+ }
50
+ if (!rightValues) {
51
+ rightValues = new WeakSet();
52
+ visited.set(left, rightValues);
53
+ }
54
+ rightValues.add(right);
55
+
56
+ const leftKeys = getEnumerableKeys(left);
57
+ const rightKeys = getEnumerableKeys(right);
58
+ const leftOptions = left as Record<PropertyKey, unknown>;
59
+ const rightOptions = right as Record<PropertyKey, unknown>;
60
+ return (
61
+ leftKeys.length === rightKeys.length &&
62
+ leftKeys.every(
63
+ key =>
64
+ Object.prototype.propertyIsEnumerable.call(right, key) &&
65
+ compareOptionValues(leftOptions[key], rightOptions[key], visited)
66
+ )
67
+ );
68
+ }
69
+
70
+ /** Returns own enumerable keys, including symbols. */
71
+ function getEnumerableKeys(value: object): PropertyKey[] {
72
+ return Reflect.ownKeys(value).filter(key =>
73
+ Object.prototype.propertyIsEnumerable.call(value, key)
74
+ );
75
+ }
@@ -2,8 +2,6 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {getNativeArrowOptions, unwrapArrowTable} from '../loader-utils/native-arrow';
6
-
7
5
  import type {
8
6
  LoaderArrayOptionsType,
9
7
  LoaderShapeType,
@@ -118,21 +116,14 @@ export async function parseFile(
118
116
  url,
119
117
  normalizedOptions
120
118
  );
121
- const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
122
119
  context = getLoaderContext(
123
120
  // @ts-expect-error candidateLoaders may be a single forced loader
124
121
  {url, _parse: parse, loaders: candidateLoaders},
125
- nativeArrowOptions || strictOptions,
122
+ strictOptions,
126
123
  context || null
127
124
  );
128
125
 
129
- const result = await parseFileWithLoader(
130
- loader,
131
- file,
132
- nativeArrowOptions || strictOptions,
133
- context
134
- );
135
- return nativeArrowOptions ? unwrapArrowTable(result) : result;
126
+ return parseFileWithLoader(loader, file, strictOptions, context);
136
127
  }
137
128
 
138
129
  /**
@@ -3,9 +3,9 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {
6
- getNativeArrowOptions,
7
- isNativeArrowTable,
8
- unwrapArrowBatches
6
+ usesNativeArrowBatches,
7
+ isArrowTable,
8
+ normalizeNativeArrowBatches
9
9
  } from '../loader-utils/native-arrow';
10
10
 
11
11
  import type {Batch, Table} from '@loaders.gl/core/schema';
@@ -146,10 +146,10 @@ export async function parseInBatches(
146
146
  url || '',
147
147
  normalizedOptions
148
148
  );
149
- const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, true);
149
+ const nativeArrow = usesNativeArrowBatches(loader, strictOptions);
150
150
  context = getLoaderContext(
151
151
  {url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray},
152
- nativeArrowOptions || strictOptions,
152
+ strictOptions,
153
153
  context || null
154
154
  );
155
155
 
@@ -158,10 +158,10 @@ export async function parseInBatches(
158
158
  loader,
159
159
  loaderWithParser,
160
160
  data,
161
- nativeArrowOptions || strictOptions,
161
+ strictOptions,
162
162
  context
163
163
  );
164
- return nativeArrowOptions ? unwrapArrowBatches(batches) : batches;
164
+ return nativeArrow ? normalizeNativeArrowBatches(batches) : batches;
165
165
  }
166
166
 
167
167
  /**
@@ -289,7 +289,7 @@ async function* parseChunkInBatches(
289
289
  context
290
290
  );
291
291
 
292
- if (isNativeArrowTable(parsedData)) {
292
+ if (isArrowTable(parsedData)) {
293
293
  yield* parsedData.batches;
294
294
  return;
295
295
  }
@@ -334,8 +334,6 @@ function isTable(value: unknown): value is Table {
334
334
  return Array.isArray(table.features);
335
335
  case 'columnar-table':
336
336
  return Boolean(table.data && typeof table.data === 'object');
337
- case 'arrow-table':
338
- return Boolean(table.data && typeof table.data === 'object' && 'numRows' in table.data);
339
337
  default:
340
338
  return false;
341
339
  }
@@ -349,8 +347,6 @@ function getTableLength(table: Table): number {
349
347
  return table.data.length;
350
348
  case 'geojson-table':
351
349
  return table.features.length;
352
- case 'arrow-table':
353
- return table.data.numRows;
354
350
  case 'columnar-table':
355
351
  for (const column of Object.values(table.data)) {
356
352
  return column.length || 0;
@@ -2,8 +2,6 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {getNativeArrowOptions, unwrapArrowTable} from '../loader-utils/native-arrow';
6
-
7
5
  import type {
8
6
  LoaderArrayOptionsType,
9
7
  LoaderShapeType,
@@ -116,21 +114,19 @@ export function parseSync(
116
114
  const parse = () => {
117
115
  throw new Error('parseSync called parse (which is async');
118
116
  };
119
- const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
120
117
  context = getLoaderContext(
121
118
  {url, _parseSync: parse, _parse: parse, loaders: loaders as Loader[]},
122
- nativeArrowOptions || strictOptions,
119
+ strictOptions,
123
120
  context || null
124
121
  );
125
122
 
126
123
  const loaderWithParser = getLoaderImplementationSync(loader);
127
- const result = parseWithLoaderSync(
124
+ return parseWithLoaderSync(
128
125
  loaderWithParser || (loader as LoaderWithParser),
129
126
  data,
130
- nativeArrowOptions || strictOptions,
127
+ strictOptions,
131
128
  context
132
129
  );
133
- return nativeArrowOptions ? unwrapArrowTable(result, loader.supportsNativeArrow) : result;
134
130
  }
135
131
 
136
132
  // TODO - should accept loader.parseSync/parse and generate 1 chunk asyncIterator
@@ -2,8 +2,6 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {getNativeArrowOptions, unwrapArrowTable} from '../loader-utils/native-arrow';
6
-
7
5
  import {resolveLoaderAuthenticationOptions} from '@loaders.gl/core/loader-utils';
8
6
  import type {
9
7
  LoaderArrayOptionsType,
@@ -146,16 +144,14 @@ export async function parse(
146
144
  );
147
145
 
148
146
  // Get a context (if already present, will be unchanged)
149
- const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
150
147
  context = getLoaderContext(
151
148
  // @ts-expect-error
152
149
  {url, _parse: parse, loaders: candidateLoaders},
153
- nativeArrowOptions || strictOptions,
150
+ strictOptions,
154
151
  context || null
155
152
  );
156
153
 
157
- const result = await parseWithLoader(loader, data, nativeArrowOptions || strictOptions, context);
158
- return nativeArrowOptions ? unwrapArrowTable(result, loader.supportsNativeArrow) : result;
154
+ return parseWithLoader(loader, data, strictOptions, context);
159
155
  }
160
156
 
161
157
  // TODO - should accept loader.parseAsyncIterator and concatenate.
@@ -14,56 +14,28 @@ export function getShapeOptionKey(loader: Loader): string | undefined {
14
14
  return keys.includes(loader.id) ? loader.id : keys.length === 1 ? keys[0] : undefined;
15
15
  }
16
16
 
17
- /** Resolves native Arrow selection for native parsers and wrapper-based parsers. */
18
- export function getNativeArrowOptions(
19
- loader: Loader,
20
- options: StrictLoaderOptions,
21
- inBatches = false
22
- ): StrictLoaderOptions | null {
17
+ /** Checks for an Arrow stream and validates its metadata options. */
18
+ export function usesNativeArrowBatches(loader: Loader, options: StrictLoaderOptions): boolean {
23
19
  const key = getShapeOptionKey(loader);
24
20
  const scopedOptions = key && options[key];
25
- if (
26
- loader.supportsNativeArrow &&
27
- scopedOptions &&
28
- typeof scopedOptions === 'object' &&
29
- 'shape' in scopedOptions &&
30
- scopedOptions.shape === 'arrow-table'
31
- ) {
32
- throw new Error('This loader uses shape: "arrow" for native Arrow output');
33
- }
34
21
  if (
35
22
  !scopedOptions ||
36
23
  typeof scopedOptions !== 'object' ||
37
24
  !('shape' in scopedOptions) ||
38
25
  scopedOptions.shape !== 'arrow'
39
26
  ) {
40
- return null;
27
+ return false;
41
28
  }
42
- if (inBatches && options.core?.metadata) {
29
+ if (options.core?.metadata) {
43
30
  throw new Error(
44
31
  'shape: "arrow" carries metadata in the Arrow schema and does not support core.metadata envelopes'
45
32
  );
46
33
  }
47
- if (loader.supportsNativeArrow) return options;
48
- return {
49
- ...options,
50
- core: {...options.core, ...(options.core?.shape === 'arrow' ? {shape: 'arrow-table'} : {})},
51
- [key!]: {...scopedOptions, shape: 'arrow-table'}
52
- };
53
- }
54
-
55
- /** Unwraps legacy tables and passes through results from native parsers. */
56
- export function unwrapArrowTable(result: unknown): arrow.Table;
57
- export function unwrapArrowTable(result: unknown, nativeParser: boolean | undefined): unknown;
58
- export function unwrapArrowTable(result: unknown, nativeParser?: boolean): unknown {
59
- const table = result as {shape?: string; data?: arrow.Table} | null;
60
- if (table?.shape === 'arrow-table' && Array.isArray(table.data?.batches)) return table.data;
61
- if (nativeParser || isNativeArrowTable(result)) return result;
62
- throw new Error('shape: "arrow" requires a loader that supports "arrow-table" output');
34
+ return true;
63
35
  }
64
36
 
65
37
  /** Yields every record batch, preserving order and iterator cancellation. */
66
- export async function* unwrapArrowBatches(
38
+ export async function* normalizeNativeArrowBatches(
67
39
  batches: AsyncIterable<unknown> | Iterable<unknown>
68
40
  ): AsyncIterable<arrow.RecordBatch> {
69
41
  for await (const batch of batches) {
@@ -76,16 +48,18 @@ export async function* unwrapArrowBatches(
76
48
  ) {
77
49
  continue;
78
50
  }
79
- if (isNativeArrowRecordBatch(batch)) {
51
+ if (isArrowRecordBatch(batch)) {
80
52
  yield batch;
53
+ } else if (isArrowTable(batch)) {
54
+ yield* batch.batches;
81
55
  } else {
82
- yield* unwrapArrowTable(batch).batches;
56
+ throw new Error('shape: "arrow" requires a native Arrow table or record batch');
83
57
  }
84
58
  }
85
59
  }
86
60
 
87
61
  /** Identifies native Arrow tables without loading Arrow in the core entry point. */
88
- export function isNativeArrowTable(value: unknown): value is arrow.Table {
62
+ export function isArrowTable(value: unknown): value is arrow.Table {
89
63
  return Boolean(
90
64
  value &&
91
65
  typeof value === 'object' &&
@@ -100,7 +74,7 @@ export function isNativeArrowTable(value: unknown): value is arrow.Table {
100
74
  }
101
75
 
102
76
  /** Identifies native record batches across Arrow package instances. */
103
- export function isNativeArrowRecordBatch(value: unknown): value is arrow.RecordBatch {
77
+ export function isArrowRecordBatch(value: unknown): value is arrow.RecordBatch {
104
78
  return Boolean(
105
79
  value &&
106
80
  typeof value === 'object' &&
@@ -345,7 +345,6 @@ export {executeScanTasks} from './lib/scan-utils/scan-executor';
345
345
  export {
346
346
  executeTableScanBatches,
347
347
  filterTableBatch,
348
- makeTableScanBatch,
349
348
  projectTableBatch,
350
349
  projectTableSchema,
351
350
  truncateTableBatch
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {SQLQuery} from '@math.gl/expressions/sql';
5
+ import type {SQLQuery} from '@math.gl/sql/parser';
6
6
  import type {DataType, FieldMetadata, Schema} from '@loaders.gl/core/schema';
7
7
  import type {ColumnarPredicate, ColumnarPredicateProperty} from './columnar-predicate';
8
8
  import type {
@@ -148,6 +148,8 @@ export type ScanQueryMetadata = Readonly<{
148
148
  statistics?: ScanSourceStatistics;
149
149
  /** Optional multiscale raster levels. */
150
150
  levels?: readonly ScanRasterLevel[];
151
+ /** The source or a child applies a configured row window to direct reads by default. */
152
+ hasDefaultRowWindow?: boolean;
151
153
  }>;
152
154
 
153
155
  /** Options accepted by query metadata discovery methods. */
@@ -341,6 +343,8 @@ export type CreateScanQueryMetadataOptions = Readonly<{
341
343
  statistics?: ScanSourceStatistics;
342
344
  /** Optional multiscale raster levels. */
343
345
  levels?: readonly ScanRasterLevel[];
346
+ /** The source or a child applies a configured row window to direct reads by default. */
347
+ hasDefaultRowWindow?: boolean;
344
348
  }>;
345
349
 
346
350
  /**
@@ -381,6 +385,7 @@ export function createScanQueryMetadata(options: CreateScanQueryMetadataOptions)
381
385
  columns: Object.freeze(columns),
382
386
  capabilities: queryCapabilities,
383
387
  queryCapabilities,
388
+ ...(options.hasDefaultRowWindow ? {hasDefaultRowWindow: true} : {}),
384
389
  spatial: options.spatial
385
390
  ? Object.freeze({
386
391
  ...options.spatial,
@@ -454,11 +459,7 @@ export type TableQueryPushdownPlan = Readonly<{
454
459
  /** Exact output schema, including aliases, CAST types, and nullability. */
455
460
  schema: Schema;
456
461
  /** Executes on demand with equivalent order, error semantics, and cancellation. */
457
- read: (
458
- options?: ScanQueryMetadataOptions
459
- ) => AsyncIterable<
460
- import('apache-arrow').RecordBatch | import('@loaders.gl/core/schema').ArrowTableBatch
461
- >;
462
+ read: (options?: ScanQueryMetadataOptions) => AsyncIterable<import('apache-arrow').RecordBatch>;
462
463
  }>;
463
464
 
464
465
  /** Preferred name for source discovery metadata. */
@@ -2,51 +2,51 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {ArrowTable, ArrowTableBatch, TableBatch} from '@loaders.gl/core/schema';
5
+ import type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow';
6
+ import type {TableBatch} from '@loaders.gl/core/schema';
6
7
  import type {TableScanReadOptions, TableQueryExecutionSummary} from './scan-query-metadata';
7
8
  import {emitQueryComplete} from './scan-query-metadata';
8
9
  import {filterColumnarRowIndices, validateColumnarPredicate} from './columnar-predicate';
9
10
  import {validateTableQueryLimit, validateTableQueryOffset} from './table-query';
10
11
 
12
+ /** Physical batches handled by the shared scan executor. */
13
+ type ScanBatch = TableBatch | ApacheArrowTable | RecordBatch;
14
+
11
15
  /** Reads source batches while allowing the shared executor to observe fetched bytes. */
12
- export type TableScanBatchReader = (
16
+ export type TableScanBatchReader<BatchT = TableBatch> = (
13
17
  signal?: AbortSignal,
14
18
  onByteLength?: (byteLength: number) => void
15
- ) => AsyncIterable<TableBatch>;
19
+ ) => AsyncIterable<BatchT>;
16
20
 
17
21
  /** Optional batch kernels for formats with a native vectorized predicate implementation. */
18
- export type TableScanBatchOperators = Readonly<{
22
+ export type TableScanBatchOperators<BatchT = TableBatch> = Readonly<{
19
23
  /** Applies a residual predicate locally or on a worker; async kernels must observe the signal. */
20
24
  filter?: (
21
- batch: TableBatch,
25
+ batch: BatchT,
22
26
  predicate: TableScanReadOptions['predicate'],
23
27
  signal?: AbortSignal
24
- ) => TableBatch | Promise<TableBatch>;
28
+ ) => BatchT | Promise<BatchT>;
25
29
  /** Applies a projection while preserving the source batch shape. */
26
- project?: (batch: TableBatch, columns?: readonly string[]) => TableBatch;
30
+ project?: (batch: BatchT, columns?: readonly string[]) => BatchT;
27
31
  }>;
28
32
 
29
- /** Wraps an Arrow table in the standard single-result scan batch envelope. */
30
- export function makeTableScanBatch(table: ArrowTable): ArrowTableBatch {
31
- return {...table, batchType: 'data', length: table.data.numRows} as ArrowTableBatch;
32
- }
33
-
34
33
  /**
35
- * Executes the common residual table-scan stages for row and columnar batches.
34
+ * Executes the common residual table-scan stages for row, columnar, and native Arrow chunks.
35
+ * Native Arrow predicates require a format-supplied filter kernel.
36
36
  *
37
37
  * Format adapters provide only their parser-specific batch reader. Keeping filtering, projection,
38
38
  * limits, cancellation, and telemetry here avoids copying the same executor into every format
39
39
  * package while preserving each format's native batch shape.
40
40
  */
41
- export async function* executeTableScanBatches(
42
- readBatches: TableScanBatchReader,
41
+ export async function* executeTableScanBatches<BatchT extends ScanBatch>(
42
+ readBatches: TableScanBatchReader<BatchT>,
43
43
  options: TableScanReadOptions &
44
44
  Readonly<{
45
45
  /** Omits empty batches from the output stream. */
46
46
  skipEmptyBatches?: boolean;
47
47
  }> = {},
48
- operators: TableScanBatchOperators = {}
49
- ): AsyncIterable<TableBatch> {
48
+ operators: TableScanBatchOperators<NoInfer<BatchT>> = {}
49
+ ): AsyncIterable<BatchT> {
50
50
  validateTableQueryLimit(options.limit);
51
51
  validateTableQueryOffset(options.offset);
52
52
  let skip = options.offset ?? 0;
@@ -80,30 +80,37 @@ export async function* executeTableScanBatches(
80
80
  }
81
81
  options.signal?.throwIfAborted();
82
82
  batchesRead++;
83
- rowsRead += batch.length;
84
- const filteredBatch = await (operators.filter || filterTableBatch)(
85
- batch,
86
- options.predicate,
87
- options.signal
88
- );
83
+ const rowCount = getScanBatchRowCount(batch);
84
+ rowsRead += rowCount;
85
+ if (options.predicate && !operators.filter && !('shape' in batch)) {
86
+ throw new Error('Native Arrow scans require a filter kernel for residual predicates.');
87
+ }
88
+ const filteredBatch = operators.filter
89
+ ? await operators.filter(batch, options.predicate, options.signal)
90
+ : (('shape' in batch ? filterTableBatch(batch, options.predicate) : batch) as BatchT);
89
91
  options.signal?.throwIfAborted();
92
+ const filteredRowCount = getScanBatchRowCount(filteredBatch);
90
93
  if (options.predicate) {
91
- rowsTested += batch.length;
92
- rowsRetained += filteredBatch.length;
94
+ rowsTested += rowCount;
95
+ rowsRetained += filteredRowCount;
93
96
  }
94
- if (skip >= filteredBatch.length && (skip > 0 || options.skipEmptyBatches)) {
95
- skip -= filteredBatch.length;
97
+ if (skip >= filteredRowCount && (skip > 0 || options.skipEmptyBatches)) {
98
+ skip -= filteredRowCount;
96
99
  continue;
97
100
  }
98
- const end = Math.min(filteredBatch.length, skip + remaining);
101
+ const end = Math.min(filteredRowCount, skip + remaining);
99
102
  const window =
100
- skip || end < filteredBatch.length
101
- ? sliceTableBatch(filteredBatch, skip, end)
103
+ skip || end < filteredRowCount
104
+ ? (('shape' in filteredBatch
105
+ ? sliceTableBatch(filteredBatch, skip, end)
106
+ : filteredBatch.slice(skip, end)) as BatchT)
102
107
  : filteredBatch;
103
108
  skip = 0;
104
- const output = (operators.project || projectTableBatch)(window, options.columns);
105
- remaining -= window.length;
106
- rowsReturned += output.length;
109
+ const output = operators.project
110
+ ? operators.project(window, options.columns)
111
+ : projectTableBatch(window, options.columns);
112
+ remaining -= getScanBatchRowCount(window);
113
+ rowsReturned += getScanBatchRowCount(output);
107
114
  if (remaining === 0) earlyTerminationReason = 'limit';
108
115
  yield output;
109
116
  if (remaining === 0) return;
@@ -142,9 +149,19 @@ export async function* executeTableScanBatches(
142
149
  }
143
150
  }
144
151
 
152
+ /** Reads the row count from native Arrow chunks and portable batch envelopes. */
153
+ function getScanBatchRowCount(batch: ScanBatch): number {
154
+ return 'shape' in batch ? batch.length : batch.numRows;
155
+ }
156
+
145
157
  /** Truncates a batch without changing its native representation. */
146
- export function truncateTableBatch(batch: TableBatch, length: number): TableBatch {
147
- return sliceTableBatch(batch, 0, length);
158
+ export function truncateTableBatch<BatchType extends ScanBatch>(
159
+ batch: BatchType,
160
+ length: number
161
+ ): BatchType {
162
+ return (
163
+ 'shape' in batch ? sliceTableBatch(batch, 0, length) : batch.slice(0, length)
164
+ ) as BatchType;
148
165
  }
149
166
 
150
167
  /** Slices rows in a batch, preserving Arrow buffers and the batch shape. */
@@ -165,30 +182,36 @@ function sliceTableBatch(batch: TableBatch, start: number, end: number): TableBa
165
182
  length
166
183
  };
167
184
  }
168
- if (batch.shape === 'arrow-table') return {...batch, data: batch.data.slice(start, end), length};
169
185
  return {...batch, features: batch.features.slice(start, end), length};
170
186
  }
171
187
 
172
188
  /** Projects a batch in the caller-requested order while preserving its shape. */
173
- export function projectTableBatch(batch: TableBatch, columns?: readonly string[]): TableBatch {
189
+ export function projectTableBatch<BatchType extends ScanBatch>(
190
+ batch: BatchType,
191
+ columns?: readonly string[]
192
+ ): BatchType {
174
193
  if (columns === undefined) return batch;
194
+ if (!('shape' in batch)) {
195
+ const indices = columns
196
+ .map(column => batch.schema.fields.findIndex(field => field.name === column))
197
+ .filter(index => index >= 0);
198
+ return batch.selectAt(indices) as BatchType;
199
+ }
175
200
  const schema = projectTableSchema(batch, columns);
176
201
  if (batch.shape === 'object-row-table') {
177
202
  return {
178
203
  ...batch,
179
204
  schema,
180
205
  data: batch.data.map(row => Object.fromEntries(columns.map(column => [column, row[column]])))
181
- } as TableBatch;
206
+ } as BatchType;
182
207
  }
183
208
  if (batch.shape === 'columnar-table') {
184
209
  return {
185
210
  ...batch,
186
211
  schema,
187
212
  data: Object.fromEntries(columns.map(column => [column, batch.data[column]]))
188
- };
213
+ } as BatchType;
189
214
  }
190
- if (batch.shape === 'arrow-table')
191
- return {...batch, schema, data: batch.data.select([...columns])};
192
215
  return batch;
193
216
  }
194
217
 
@@ -2,7 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {ArrowTable, Schema} from '@loaders.gl/core/schema';
5
+ import type {Table as ArrowTable} from 'apache-arrow';
6
+ import type {Schema} from '@loaders.gl/core/schema';
6
7
  import type {TableScanSource} from '../scan-utils/scan-query-metadata';
7
8
 
8
9
  /** Source exposing named tables. Returned handles remain owned by the source or caller. */
@@ -3,17 +3,11 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import type {Table} from 'apache-arrow';
6
- import type {
7
- Schema,
8
- Feature,
9
- GeoJSONTable,
10
- BinaryFeatureCollection,
11
- ArrowTable
12
- } from '@loaders.gl/core/schema';
6
+ import type {Schema, Feature, GeoJSONTable, BinaryFeatureCollection} from '@loaders.gl/core/schema';
13
7
  import {TileSource, TileSourceProps, GetTileParameters} from './tile-source';
14
8
  import type {GetTileDataParameters} from './tile-source';
15
9
 
16
- export type VectorTile = Feature[] | GeoJSONTable | BinaryFeatureCollection | ArrowTable | Table;
10
+ export type VectorTile = Feature[] | GeoJSONTable | BinaryFeatureCollection | Table;
17
11
 
18
12
  export type VectorTileSourceProps = TileSourceProps;
19
13
 
@@ -26,5 +20,5 @@ export interface VectorTileSource extends TileSource {
26
20
  getVectorTile(parameters: GetTileParameters): Promise<VectorTile | null>;
27
21
  getTileData(
28
22
  parameters: GetTileDataParameters
29
- ): Promise<Feature[] | GeoJSONTable | BinaryFeatureCollection | ArrowTable | Table | null>;
23
+ ): Promise<Feature[] | GeoJSONTable | BinaryFeatureCollection | Table | null>;
30
24
  }
@@ -492,9 +492,9 @@ type NativeArrowOutput<T, Options, Wrapped, Native> = [Options] extends [never]
492
492
  : never;
493
493
 
494
494
  /** Selects native output when certain and a union when shape selection is dynamic. */
495
- type NativeArrowOutputForOption<T, Options, Wrapped, Native> = [
496
- Extract<Wrapped, {shape: 'arrow-table'} | Native>
497
- ] extends [never]
495
+ type NativeArrowOutputForOption<T, Options, Wrapped, Native> = [Extract<Wrapped, Native>] extends [
496
+ never
497
+ ]
498
498
  ? Wrapped
499
499
  : [RequiredOutputShape<T, Options>] extends [never]
500
500
  ? [
@@ -3,12 +3,12 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import * as arrow from 'apache-arrow';
6
- import {compileArrowArray, compileArrowExpression} from '@math.gl/expressions/arrow';
7
- import type {TableSelection} from '@math.gl/expressions/sql';
8
- import {getExpressionColumns} from '@math.gl/expressions';
6
+ import {compileArrowArray, compileArrowExpression} from '@math.gl/sql/arrow';
7
+ import type {TableSelection} from '@math.gl/sql/parser';
8
+ import {getExpressionColumns} from '@math.gl/sql/expressions';
9
9
 
10
- export {compileArrowExpression, compileArrowPredicate} from '@math.gl/expressions/arrow';
11
- export {getExpressionColumns} from '@math.gl/expressions';
10
+ export {compileArrowExpression, compileArrowPredicate} from '@math.gl/sql/arrow';
11
+ export {getExpressionColumns} from '@math.gl/sql/expressions';
12
12
 
13
13
  /** Finds source columns and rejects ambiguous projection shapes before a scan. */
14
14
  export function getProjectionColumns(selections: readonly TableSelection[]): string[] {
@@ -87,8 +87,8 @@ export function compileArrowProjection(
87
87
 
88
88
  /** Converts typed SELECT items into ordinary SQL CAST expressions. */
89
89
  export function normalizeTypedProjection(
90
- query: import('../query').TypedTableQuery | import('@math.gl/expressions/sql').TableQuery
91
- ): import('@math.gl/expressions/sql').TableQuery {
90
+ query: import('../query').TypedTableQuery | import('@math.gl/sql/parser').TableQuery
91
+ ): import('@math.gl/sql/parser').TableQuery {
92
92
  return {
93
93
  ...query,
94
94
  select: query.select?.map(item => {
@@ -0,0 +1,8 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import {initializeTaskWorker} from '@math.gl/tasks';
6
+ import {createArrowQueryTask} from './arrow-query-worker.js';
7
+
8
+ void initializeTaskWorker(createArrowQueryTask());