@loaders.gl/core 5.0.0-beta.10 → 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.
- package/SCAN-README.md +2 -2
- package/SCHEMA-UTILS-README.md +1 -1
- package/dist/arrow-geometry/binary-features.cjs +4 -1
- package/dist/arrow-geometry/binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/binary-features.d.ts.map +1 -1
- package/dist/arrow-geometry/binary-features.js +1 -1
- package/dist/arrow-geometry/binary-features.js.map +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.js +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.js.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs +1 -5
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts +4 -3
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +2 -6
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +2 -10
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts +6 -5
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +5 -13
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/geojson-table.cjs +3 -3
- package/dist/arrow-geometry/geojson-table.cjs.map +3 -3
- package/dist/arrow-geometry/geojson-table.d.ts +1 -1
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +2 -2
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.cjs +6 -6
- package/dist/arrow-geometry/geometry-codecs.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-codecs.js +1 -1
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.cjs +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.js +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.js.map +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.cjs +3 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js +3 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.cjs +1 -5
- package/dist/arrow-geometry/wkb-arrow-utils.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts +7 -7
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.js +4 -8
- package/dist/arrow-geometry/wkb-arrow-utils.js.map +1 -1
- package/dist/arrow-geometry/wkb-builder.cjs +3 -3
- package/dist/arrow-geometry/wkb-builder.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-builder.d.ts +1 -1
- package/dist/arrow-geometry/wkb-builder.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-builder.js +1 -1
- package/dist/arrow-geometry/wkb-builder.js.map +1 -1
- package/dist/arrow-geometry/wkb-statistics.cjs +2 -2
- package/dist/arrow-geometry/wkb-statistics.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-statistics.js +1 -1
- package/dist/arrow-geometry/wkb-statistics.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +8 -76
- package/dist/arrow-worker-transport.cjs.map +1 -1
- package/dist/arrow-worker-transport.d.ts +4 -8
- package/dist/arrow-worker-transport.d.ts.map +1 -1
- package/dist/arrow-worker-transport.js +15 -89
- package/dist/arrow-worker-transport.js.map +1 -1
- package/dist/cluster-source.cjs +47 -45
- package/dist/cluster-source.cjs.map +2 -2
- package/dist/dist.dev.js +71 -60
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +88 -126
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.cjs +12 -12
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts +3 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +12 -14
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +4 -12
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +5 -5
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +6 -14
- package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-bounds.cjs +7 -7
- package/dist/geoarrow/geoarrow-bounds.cjs.map +3 -3
- package/dist/geoarrow/geoarrow-bounds.js +3 -3
- package/dist/geoarrow/geoarrow-bounds.js.map +1 -1
- package/dist/geoarrow/geoarrow-capabilities.cjs +2 -2
- package/dist/geoarrow/geoarrow-capabilities.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-capabilities.js +1 -1
- package/dist/geoarrow/geoarrow-capabilities.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +8 -8
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
- package/dist/geoarrow/geoarrow-inspection.cjs +2 -2
- package/dist/geoarrow/geoarrow-inspection.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-inspection.js +1 -1
- package/dist/geoarrow/geoarrow-inspection.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +10 -11
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-stream.js +9 -12
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.js +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.cjs.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js +3 -3
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +5 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs +4 -4
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -3
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs +3 -3
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +5 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/index.cjs +69 -54
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +2 -4
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/loader-options.d.ts +6 -0
- package/dist/lib/api/loader-options.d.ts.map +1 -1
- package/dist/lib/api/loader-options.js +48 -0
- package/dist/lib/api/loader-options.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +2 -5
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.js +6 -10
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +2 -5
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +2 -5
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +5 -8
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
- package/dist/lib/loader-utils/native-arrow.js +13 -31
- package/dist/lib/loader-utils/native-arrow.js.map +1 -1
- package/dist/loader-utils/index.cjs +48 -31
- package/dist/loader-utils/index.cjs.map +1 -1
- package/dist/loader-utils/index.d.ts +1 -1
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +6 -2
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +15 -12
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +36 -22
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +2 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.d.ts +6 -1
- package/dist/loader-utils/lib/sources/tile-grid.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.js +32 -14
- package/dist/loader-utils/lib/sources/tile-grid.js.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -3
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +3 -5
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/tile-grid.cjs +21 -9
- package/dist/loader-utils/tile-grid.cjs.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +4 -4
- package/dist/scan/arrow-execution/expressions.cjs.map +2 -2
- package/dist/scan/arrow-execution/expressions.d.ts +4 -4
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +4 -4
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/arrow-query-worker-entry.cjs +121 -0
- package/dist/scan/arrow-query-worker-entry.cjs.map +7 -0
- package/dist/scan/arrow-query-worker-entry.d.ts +2 -0
- package/dist/scan/arrow-query-worker-entry.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker-entry.js +7 -0
- package/dist/scan/arrow-query-worker-entry.js.map +1 -0
- package/dist/scan/arrow-query-worker.cjs +197 -0
- package/dist/scan/arrow-query-worker.cjs.map +7 -0
- package/dist/scan/arrow-query-worker.d.ts +47 -0
- package/dist/scan/arrow-query-worker.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker.js +101 -0
- package/dist/scan/arrow-query-worker.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +12 -13
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +14 -15
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +5 -2
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +2 -2
- package/dist/scan/parse-sql-predicate.cjs.map +2 -2
- package/dist/scan/parse-sql-predicate.js +1 -1
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-pushdown.cjs +6 -6
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.d.ts +1 -1
- package/dist/scan/query-pushdown.d.ts.map +1 -1
- package/dist/scan/query-pushdown.js +3 -6
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query-scales.cjs +195 -0
- package/dist/scan/query-scales.cjs.map +7 -0
- package/dist/scan/query-scales.d.ts +47 -0
- package/dist/scan/query-scales.d.ts.map +1 -0
- package/dist/scan/query-scales.js +201 -0
- package/dist/scan/query-scales.js.map +1 -0
- package/dist/scan/query.cjs +49 -45
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts +7 -4
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +35 -52
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +19 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +3 -4
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +11 -12
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/categories/category-mesh.d.ts +3 -10
- package/dist/schema/categories/category-mesh.d.ts.map +1 -1
- package/dist/schema/categories/category-mesh.js.map +1 -1
- package/dist/schema/categories/category-table.d.ts +2 -19
- package/dist/schema/categories/category-table.d.ts.map +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -1
- package/dist/schema/geometry/geoarrow.d.ts +2 -2
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/types/batch.d.ts +0 -4
- package/dist/schema/types/batch.d.ts.map +1 -1
- package/dist/schema-utils/index.cjs +420 -503
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +4 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +4 -5
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +4 -5
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +21 -18
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +6 -11
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +8 -21
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -4
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +13 -15
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +2 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +3 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +5 -8
- package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +2 -6
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +4 -24
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +3 -6
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +8 -58
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +2 -2
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +2 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +2 -2
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +4 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.d.ts +1 -3
- package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.js +0 -4
- package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +17 -11
- package/dist/vector-table-scan-source.cjs.map +2 -2
- package/dist/wkt/index.cjs.map +1 -1
- package/dist/wkt/index.d.ts.map +1 -1
- package/dist/wkt/index.js.map +1 -1
- package/dist/worker-utils/index.cjs +2 -2
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/npm-tag.d.ts.map +1 -1
- package/dist/worker-utils/lib/npm-tag.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js.map +1 -1
- package/dist/worker-utils/null-worker.js.map +1 -1
- package/package.json +22 -8
- package/src/arrow-geometry/binary-features.ts +4 -1
- package/src/arrow-geometry/binary-geometry-to-wkb.ts +1 -1
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -8
- package/src/arrow-geometry/feature-table.ts +8 -21
- package/src/arrow-geometry/geojson-table.ts +2 -2
- package/src/arrow-geometry/geometry-codecs.ts +2 -2
- package/src/arrow-geometry/geometry-to-wkt.ts +2 -2
- package/src/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.ts +3 -1
- package/src/arrow-geometry/wkb-arrow-utils.ts +8 -12
- package/src/arrow-geometry/wkb-builder.ts +2 -2
- package/src/arrow-geometry/wkb-statistics.ts +2 -2
- package/src/arrow-worker-transport.ts +22 -121
- package/src/geoarrow/binary-polygon-to-geoarrow.ts +2 -2
- package/src/geoarrow/clustering/cluster-source.ts +16 -23
- package/src/geoarrow/convert-table-to-geoarrow.ts +11 -23
- package/src/geoarrow/geoarrow-bounds.ts +3 -3
- package/src/geoarrow/geoarrow-capabilities.ts +1 -1
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +3 -7
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +2 -2
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +2 -4
- package/src/geoarrow/geoarrow-inspection.ts +2 -2
- package/src/geoarrow/geoarrow-stream.ts +15 -15
- package/src/geoarrow/get-geoarrow-vertex-count.ts +1 -1
- package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts +3 -3
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +5 -2
- package/src/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +2 -2
- package/src/geoarrow/lib/kernels/encode-geoarrow-box.ts +1 -1
- package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +7 -5
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +1 -1
- package/src/index.ts +1 -1
- package/src/lib/api/load.ts +2 -12
- package/src/lib/api/loader-options.ts +69 -0
- package/src/lib/api/parse-file.ts +2 -11
- package/src/lib/api/parse-in-batches.ts +8 -12
- package/src/lib/api/parse-sync.ts +3 -7
- package/src/lib/api/parse.ts +2 -6
- package/src/lib/loader-utils/native-arrow.ts +12 -38
- package/src/loader-utils/index.ts +0 -1
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +7 -6
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +64 -41
- package/src/loader-utils/lib/sources/table-source-collection.ts +2 -1
- package/src/loader-utils/lib/sources/tile-grid.ts +34 -18
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -9
- package/src/loader-utils/loader-types.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +7 -7
- package/src/scan/arrow-execution/filter-arrow-table.ts +1 -1
- package/src/scan/arrow-query-worker-entry.ts +8 -0
- package/src/scan/arrow-query-worker.ts +158 -0
- package/src/scan/federated-table-scan-source.ts +15 -18
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +1 -1
- package/src/scan/query-pushdown.ts +7 -7
- package/src/scan/query-scales.ts +299 -0
- package/src/scan/query.ts +68 -71
- package/src/scan/vector-table-scan-source.ts +16 -21
- package/src/schema/categories/category-mesh.ts +3 -11
- package/src/schema/categories/category-table.ts +2 -28
- package/src/schema/geometry/arrow-binary-features.ts +1 -1
- package/src/schema/geometry/geoarrow.ts +2 -2
- package/src/schema/index.ts +1 -3
- package/src/schema/types/batch.ts +0 -5
- package/src/schema-utils/index.ts +5 -11
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +33 -30
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +12 -38
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +15 -18
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +4 -13
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +10 -9
- package/src/schema-utils/lib/table/batches/convert-batches.ts +5 -8
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +2 -6
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +5 -27
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +11 -73
- package/src/schema-utils/lib/table/tables/make-table.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +2 -22
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +6 -6
- package/src/schema-utils/lib/table/tables/table-types.ts +1 -7
- package/src/wkt/index.ts +1 -1
- package/src/worker-utils/lib/npm-tag.ts +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +0 -27
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +0 -23
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +0 -1
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +0 -54
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Table, util, type Schema} from 'apache-arrow';
|
|
6
|
-
import type {SQLQuery} from '@math.gl/
|
|
6
|
+
import type {SQLQuery} from '@math.gl/sql/parser';
|
|
7
7
|
import {convertArrowToSchema, convertSchemaToArrow} from '@loaders.gl/core/schema-utils';
|
|
8
8
|
import type {
|
|
9
9
|
TableQueryCapabilities,
|
|
@@ -57,19 +57,19 @@ function validatePushdownPlan(
|
|
|
57
57
|
let rowsReturned = 0;
|
|
58
58
|
for await (const batch of plan.read(options)) {
|
|
59
59
|
options.signal?.throwIfAborted();
|
|
60
|
-
const native = !('shape' in batch);
|
|
61
|
-
const schema = native ? batch.schema : batch.data.schema;
|
|
62
|
-
const rowCount = native ? batch.numRows : batch.data.numRows;
|
|
63
60
|
if (
|
|
64
|
-
!util.compareSchemas(
|
|
61
|
+
!util.compareSchemas(
|
|
62
|
+
outputSchema,
|
|
63
|
+
convertSchemaToArrow(convertArrowToSchema(batch.schema))
|
|
64
|
+
)
|
|
65
65
|
) {
|
|
66
66
|
throw new Error('Query pushdown batch schema does not match the logical output schema.');
|
|
67
67
|
}
|
|
68
|
-
rowsReturned +=
|
|
68
|
+
rowsReturned += batch.numRows;
|
|
69
69
|
if (limit !== undefined && rowsReturned > limit) {
|
|
70
70
|
throw new Error('Query pushdown returned more rows than the requested limit.');
|
|
71
71
|
}
|
|
72
|
-
yield
|
|
72
|
+
yield batch;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
};
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Table, type RecordBatch, type Vector} from 'apache-arrow';
|
|
6
|
+
import {
|
|
7
|
+
bindArrowScale,
|
|
8
|
+
compileArrowScales,
|
|
9
|
+
compileArrowScaleExpression,
|
|
10
|
+
createStreamingDomainAccumulator,
|
|
11
|
+
type CompiledArrowScale,
|
|
12
|
+
parseSQLScaleExpression,
|
|
13
|
+
type ParsedSQLScale,
|
|
14
|
+
type ResolvedScale
|
|
15
|
+
} from '@math.gl/sql/scales';
|
|
16
|
+
import {makeArrowTableFromBatches} from '@loaders.gl/core/schema-utils';
|
|
17
|
+
import {compileArrowExpression, type CompiledArrowExpression} from '@math.gl/sql/arrow';
|
|
18
|
+
import type {Expression} from '@math.gl/sql/expressions';
|
|
19
|
+
import {query, queryInBatches, type Query, type QueryOptions} from './query';
|
|
20
|
+
|
|
21
|
+
/** Named row-preserving scale expressions applied to an input query result. */
|
|
22
|
+
export type ScaleProjections<Name extends string = string> = Readonly<
|
|
23
|
+
Record<Name, string | ParsedSQLScale>
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
/** Filtered input rows and scale outputs in the same row order. */
|
|
27
|
+
export type ScaleQueryResult<Name extends string = string> = Readonly<{
|
|
28
|
+
/** Input rows after applying the table query, including any filter and row window. */
|
|
29
|
+
table: Table;
|
|
30
|
+
/** Arrow vectors keyed by scale projection name. */
|
|
31
|
+
columns: Readonly<Record<Name, Vector>>;
|
|
32
|
+
/** Scale evaluators and serializable descriptors shared with legend consumers. */
|
|
33
|
+
scales: Readonly<Record<Name, ResolvedScale>>;
|
|
34
|
+
}>;
|
|
35
|
+
|
|
36
|
+
/** Resolves data-derived domains jointly, then evaluates each scale over the same rows. */
|
|
37
|
+
export async function queryScales<Name extends string>(
|
|
38
|
+
input: Query | string,
|
|
39
|
+
projections: ScaleProjections<Name>,
|
|
40
|
+
options: QueryOptions
|
|
41
|
+
): Promise<ScaleQueryResult<Name>> {
|
|
42
|
+
options.signal?.throwIfAborted();
|
|
43
|
+
/** Scale calls validated before reading the source. */
|
|
44
|
+
const parsed = parseScaleProjections(projections);
|
|
45
|
+
/** Selected rows that define all data-derived domains. */
|
|
46
|
+
const table = await query(input, options);
|
|
47
|
+
options.signal?.throwIfAborted();
|
|
48
|
+
return evaluateScaleProjections(table, compileArrowScales(table, parsed), options.signal);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Evaluates pre-bound scales and exposes their authoritative descriptors. */
|
|
52
|
+
function evaluateScaleProjections<Name extends string>(
|
|
53
|
+
table: Table,
|
|
54
|
+
compiled: Record<Name, CompiledArrowScale>,
|
|
55
|
+
signal?: AbortSignal
|
|
56
|
+
): ScaleQueryResult<Name> {
|
|
57
|
+
const names = Object.keys(compiled) as Name[];
|
|
58
|
+
const columns = {} as Record<Name, Vector>;
|
|
59
|
+
const scales = {} as Record<Name, ResolvedScale>;
|
|
60
|
+
for (const name of names) {
|
|
61
|
+
signal?.throwIfAborted();
|
|
62
|
+
const scale = compiled[name];
|
|
63
|
+
Object.defineProperty(columns, name, {value: scale.evaluate(table), enumerable: true});
|
|
64
|
+
Object.defineProperty(scales, name, {value: scale.scale, enumerable: true});
|
|
65
|
+
}
|
|
66
|
+
return {table, columns, scales};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Parses scale expressions before starting a read and preserves projection names. */
|
|
70
|
+
function parseScaleProjections<Name extends string>(
|
|
71
|
+
projections: ScaleProjections<Name>
|
|
72
|
+
): Record<Name, ParsedSQLScale> {
|
|
73
|
+
return Object.fromEntries(
|
|
74
|
+
Object.entries<string | ParsedSQLScale>(projections).map(([name, expression]) => [
|
|
75
|
+
name,
|
|
76
|
+
typeof expression === 'string' ? parseSQLScaleExpression(expression) : expression
|
|
77
|
+
])
|
|
78
|
+
) as Record<Name, ParsedSQLScale>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Emits append-only scale projections using caller-supplied fixed domains. */
|
|
82
|
+
export async function* queryScalesInBatches<Name extends string>(
|
|
83
|
+
input: Query | string,
|
|
84
|
+
projections: ScaleProjections<Name>,
|
|
85
|
+
options: QueryOptions
|
|
86
|
+
): AsyncIterable<ScaleQueryResult<Name>> {
|
|
87
|
+
options.signal?.throwIfAborted();
|
|
88
|
+
/** Scale calls validated before reading the source. */
|
|
89
|
+
const parsed = parseScaleProjections(projections);
|
|
90
|
+
if (Object.values<ParsedSQLScale>(parsed).some(({scale}) => scale.domain.type !== 'fixed')) {
|
|
91
|
+
throw new Error('Append-only scale projections require fixed domains.');
|
|
92
|
+
}
|
|
93
|
+
/** Scales compiled once, using the schema from the first batch. */
|
|
94
|
+
let compiled: Record<Name, CompiledArrowScale> | undefined;
|
|
95
|
+
for await (const batch of queryInBatches(input, {...options, queryOutput: 'batches'})) {
|
|
96
|
+
options.signal?.throwIfAborted();
|
|
97
|
+
compiled ??= compileArrowScales(new Table(batch.schema), parsed);
|
|
98
|
+
yield evaluateScaleProjections(new Table(batch.schema, [batch]), compiled, options.signal);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Controls the cadence and retained row count of complete scale snapshots. */
|
|
103
|
+
export type ProgressiveScaleQueryOptions = QueryOptions &
|
|
104
|
+
Readonly<{
|
|
105
|
+
/** Emit a provisional snapshot after this many nonempty batches. Defaults to 16. */
|
|
106
|
+
emitEveryBatches?: number;
|
|
107
|
+
/** Maximum retained input rows for recoloring. Defaults to 100,000. */
|
|
108
|
+
maxRetainedRows?: number;
|
|
109
|
+
/** Retained samples per percentile column in the upstream quantile sketch. */
|
|
110
|
+
quantileCapacity?: number;
|
|
111
|
+
}>;
|
|
112
|
+
|
|
113
|
+
/** Complete scale outputs that replace the previous snapshot. */
|
|
114
|
+
export type ProgressiveScaleSnapshot<Name extends string = string> = ScaleQueryResult<Name> &
|
|
115
|
+
Readonly<{
|
|
116
|
+
/** Whether the source finished and the resolved domains are final. */
|
|
117
|
+
final: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
|
|
120
|
+
/** Resolves progressive domains from one source pass and recolors retained rows on publication. */
|
|
121
|
+
export async function* queryScalesProgressive<Name extends string>(
|
|
122
|
+
input: Query | string,
|
|
123
|
+
projections: ScaleProjections<Name>,
|
|
124
|
+
options: ProgressiveScaleQueryOptions
|
|
125
|
+
): AsyncIterable<ProgressiveScaleSnapshot<Name>> {
|
|
126
|
+
const {emitEveryBatches = 16, maxRetainedRows = 100_000, quantileCapacity, signal} = options;
|
|
127
|
+
signal?.throwIfAborted();
|
|
128
|
+
if (
|
|
129
|
+
!Number.isSafeInteger(emitEveryBatches) ||
|
|
130
|
+
emitEveryBatches < 1 ||
|
|
131
|
+
!Number.isSafeInteger(maxRetainedRows) ||
|
|
132
|
+
maxRetainedRows < 1
|
|
133
|
+
) {
|
|
134
|
+
throw new Error('Scale snapshot interval and row limit must be positive integers.');
|
|
135
|
+
}
|
|
136
|
+
/** Scale calls validated before reading the source. */
|
|
137
|
+
const parsed = parseScaleProjections(projections);
|
|
138
|
+
/** Projection order shared by domain results and output descriptors. */
|
|
139
|
+
const entries = Object.entries<ParsedSQLScale>(parsed) as [Name, ParsedSQLScale][];
|
|
140
|
+
/** Expressions evaluated once per incoming batch for computed domain statistics. */
|
|
141
|
+
const domainExpressions = new Map<string, CompiledArrowExpression>();
|
|
142
|
+
/** Domain dependencies use private column names for computed values. */
|
|
143
|
+
const domains = entries.map(([, {scale}], index) =>
|
|
144
|
+
scale.domain.type === 'expression-extent'
|
|
145
|
+
? {type: 'extent' as const, column: `expression:${index}`}
|
|
146
|
+
: {
|
|
147
|
+
...scale.domain,
|
|
148
|
+
...(scale.domain.type === 'fixed' ? {} : {column: `column:${scale.domain.column}`})
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
/** Columns whose sketches supply classification breaks. */
|
|
152
|
+
const quantileColumns = entries.flatMap(([, {scale}], index) =>
|
|
153
|
+
scale.type === 'quantile' && scale.domain.type !== 'fixed'
|
|
154
|
+
? [
|
|
155
|
+
scale.domain.type === 'expression-extent'
|
|
156
|
+
? `expression:${index}`
|
|
157
|
+
: `column:${scale.domain.column}`
|
|
158
|
+
]
|
|
159
|
+
: []
|
|
160
|
+
);
|
|
161
|
+
/** Shared domain accumulator over projected scalar values. */
|
|
162
|
+
const accumulator = createStreamingDomainAccumulator(domains, {
|
|
163
|
+
quantileCapacity,
|
|
164
|
+
quantileColumns
|
|
165
|
+
});
|
|
166
|
+
const batches: RecordBatch[] = [];
|
|
167
|
+
let retainedRows = 0;
|
|
168
|
+
let batchesSinceEmission = 0;
|
|
169
|
+
let last: ScaleQueryResult<Name> | undefined;
|
|
170
|
+
|
|
171
|
+
/** Binds the current statistics and evaluates the selected snapshot. */
|
|
172
|
+
async function snapshot(): Promise<ScaleQueryResult<Name> | undefined> {
|
|
173
|
+
/** Current domain values in projection order. */
|
|
174
|
+
const domains = accumulator.result();
|
|
175
|
+
if (domains.some(domain => domain.length === 0)) return undefined;
|
|
176
|
+
const table = await makeArrowTableFromBatches(batches);
|
|
177
|
+
signal?.throwIfAborted();
|
|
178
|
+
if (!table) return undefined;
|
|
179
|
+
const compiled = Object.fromEntries(
|
|
180
|
+
entries.map(([name, expression], index) => [
|
|
181
|
+
name,
|
|
182
|
+
bindArrowScale(table.schema, expression, {
|
|
183
|
+
domain: domains[index],
|
|
184
|
+
...(expression.scale.type === 'quantile'
|
|
185
|
+
? {
|
|
186
|
+
quantileBreaks: accumulator.quantileBreaks(
|
|
187
|
+
expression.scale.domain.type === 'expression-extent'
|
|
188
|
+
? `expression:${index}`
|
|
189
|
+
: expression.scale.domain.type !== 'fixed'
|
|
190
|
+
? `column:${expression.scale.domain.column}`
|
|
191
|
+
: String(index),
|
|
192
|
+
expression.scale.range.type === 'palette'
|
|
193
|
+
? expression.scale.range.count!
|
|
194
|
+
: expression.scale.range.values.length
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
: {})
|
|
198
|
+
})
|
|
199
|
+
])
|
|
200
|
+
) as Record<Name, CompiledArrowScale>;
|
|
201
|
+
return evaluateScaleProjections(table, compiled, signal);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
for await (const batch of queryInBatches(input, {...options, queryOutput: 'batches'})) {
|
|
205
|
+
signal?.throwIfAborted();
|
|
206
|
+
retainedRows += batch.numRows;
|
|
207
|
+
if (retainedRows > maxRetainedRows) {
|
|
208
|
+
throw new Error(
|
|
209
|
+
`Progressive scale query exceeded its retained row limit (${maxRetainedRows}).`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
batches.push(batch);
|
|
213
|
+
if (batch.numRows === 0) continue;
|
|
214
|
+
/** Scalar columns visited by the shared accumulator. */
|
|
215
|
+
const domainColumns: Record<string, Vector> = {};
|
|
216
|
+
entries.forEach(([, {scale}], index) => {
|
|
217
|
+
if (scale.domain.type === 'fixed') return;
|
|
218
|
+
/** Namespaced accumulator column, independent of source column spelling. */
|
|
219
|
+
const name =
|
|
220
|
+
scale.domain.type === 'expression-extent'
|
|
221
|
+
? `expression:${index}`
|
|
222
|
+
: `column:${scale.domain.column}`;
|
|
223
|
+
if (scale.domain.type === 'expression-extent') {
|
|
224
|
+
/** Reusable evaluator for the domain value expression. */
|
|
225
|
+
let compiled = domainExpressions.get(name);
|
|
226
|
+
if (!compiled) {
|
|
227
|
+
compiled = compileArrowExpression(scale.domain.expression as Expression, {
|
|
228
|
+
inputSchema: batch.schema
|
|
229
|
+
});
|
|
230
|
+
domainExpressions.set(name, compiled);
|
|
231
|
+
}
|
|
232
|
+
domainColumns[name] = compiled.evaluate(batch, {signal});
|
|
233
|
+
} else {
|
|
234
|
+
/** Source vector reused without copying. */
|
|
235
|
+
const column = batch.getChild(scale.domain.column);
|
|
236
|
+
if (!column) throw new Error(`Missing scale column: ${scale.domain.column}`);
|
|
237
|
+
domainColumns[name] = column;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
if (Object.keys(domainColumns).length) {
|
|
241
|
+
for (const domainBatch of new Table(domainColumns).batches) accumulator.update(domainBatch);
|
|
242
|
+
}
|
|
243
|
+
if (++batchesSinceEmission < emitEveryBatches) continue;
|
|
244
|
+
last = await snapshot();
|
|
245
|
+
if (last) {
|
|
246
|
+
batchesSinceEmission = 0;
|
|
247
|
+
yield {...last, final: false};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
signal?.throwIfAborted();
|
|
251
|
+
const final = last && batchesSinceEmission === 0 ? last : await snapshot();
|
|
252
|
+
if (!final) throw new Error('Progressive scale query could not resolve its domain.');
|
|
253
|
+
yield {...final, final: true};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Row-preserving expression output and the resolved scales used by each expression. */
|
|
257
|
+
export type ScaleExpressionQueryResult<Name extends string = string> = Readonly<{
|
|
258
|
+
/** Rows selected by the input table query. */
|
|
259
|
+
table: Table;
|
|
260
|
+
/** Computed Arrow vectors in the selected row order. */
|
|
261
|
+
columns: Readonly<Record<Name, Vector>>;
|
|
262
|
+
/** Resolved samplers in expression traversal order, including conditional branches. */
|
|
263
|
+
scales: Readonly<Record<Name, readonly ResolvedScale[]>>;
|
|
264
|
+
}>;
|
|
265
|
+
|
|
266
|
+
/** Evaluates scale calls inside CASE, COALESCE, and nested expressions over selected rows. */
|
|
267
|
+
export async function queryScaleExpressions<Name extends string>(
|
|
268
|
+
input: Query | string,
|
|
269
|
+
expressions: Readonly<Record<Name, string | Expression>>,
|
|
270
|
+
options: QueryOptions
|
|
271
|
+
): Promise<ScaleExpressionQueryResult<Name>> {
|
|
272
|
+
options.signal?.throwIfAborted();
|
|
273
|
+
/** Selected rows that define all data-derived domains. */
|
|
274
|
+
const table = await query(input, options);
|
|
275
|
+
/** Named expression outputs and their matching resolved scales. */
|
|
276
|
+
const results = (Object.entries(expressions) as [Name, string | Expression][]).map(
|
|
277
|
+
([name, expression]) => {
|
|
278
|
+
options.signal?.throwIfAborted();
|
|
279
|
+
/** Upstream expression evaluator with resolved scale samplers. */
|
|
280
|
+
const compiled = compileArrowScaleExpression(table, expression);
|
|
281
|
+
return {
|
|
282
|
+
name,
|
|
283
|
+
column: compiled.evaluateTable(table, {signal: options.signal}),
|
|
284
|
+
scales: compiled.scales
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
return {
|
|
289
|
+
table,
|
|
290
|
+
columns: Object.fromEntries(results.map(result => [result.name, result.column])) as Record<
|
|
291
|
+
Name,
|
|
292
|
+
Vector
|
|
293
|
+
>,
|
|
294
|
+
scales: Object.fromEntries(results.map(result => [result.name, result.scales])) as Record<
|
|
295
|
+
Name,
|
|
296
|
+
readonly ResolvedScale[]
|
|
297
|
+
>
|
|
298
|
+
};
|
|
299
|
+
}
|
package/src/scan/query.ts
CHANGED
|
@@ -8,8 +8,8 @@ import type {
|
|
|
8
8
|
ProgressiveQueryOptions,
|
|
9
9
|
ProgressiveQuerySnapshot
|
|
10
10
|
} from './query-progressive';
|
|
11
|
-
import type {SQLQuery} from '@math.gl/
|
|
12
|
-
import type {
|
|
11
|
+
import type {SQLQuery} from '@math.gl/sql/parser';
|
|
12
|
+
import type {TableBatch, Schema} from '@loaders.gl/core/schema';
|
|
13
13
|
import {
|
|
14
14
|
normalizeTableQuery,
|
|
15
15
|
getColumnarPredicateColumns,
|
|
@@ -85,6 +85,10 @@ export type QueryOptions = TableQueryExecutionOptions &
|
|
|
85
85
|
core?: DataSourceOptions['core'];
|
|
86
86
|
/** Named caller-owned data sources used by FROM and metadata commands. */
|
|
87
87
|
sources?: readonly DataSource<unknown, DataSourceOptions>[];
|
|
88
|
+
/** Row offset belongs on the logical query. */
|
|
89
|
+
offset?: never;
|
|
90
|
+
/** Row limit belongs on the logical query. */
|
|
91
|
+
limit?: never;
|
|
88
92
|
/** Parser or lazy parser promise, required only for SQL string input. */
|
|
89
93
|
sqlParser?: SQLQueryParser | Promise<SQLQueryParser>;
|
|
90
94
|
/** Append-only batches (default), or complete progressive replacement snapshots. */
|
|
@@ -93,7 +97,7 @@ export type QueryOptions = TableQueryExecutionOptions &
|
|
|
93
97
|
Readonly<
|
|
94
98
|
| {
|
|
95
99
|
/** Already loaded Arrow table or caller-owned table scan source. */
|
|
96
|
-
source: arrow.Table |
|
|
100
|
+
source: arrow.Table | TableScanSource;
|
|
97
101
|
/** URL loader selection is only used with URL sources. */
|
|
98
102
|
loaders?: never;
|
|
99
103
|
}
|
|
@@ -148,9 +152,9 @@ export async function* queryInBatches(
|
|
|
148
152
|
if (typeof tableQuery === 'object' && tableQuery && 'aggregates' in tableQuery) {
|
|
149
153
|
throw new Error('Aggregates require snapshots.');
|
|
150
154
|
}
|
|
151
|
-
for await (const
|
|
152
|
-
if (
|
|
153
|
-
else yield makeArrowMetadataBatch(
|
|
155
|
+
for await (const table of queryAppendBatches(tableQuery as Query | string, options)) {
|
|
156
|
+
if (table.batches.length) yield* table.batches;
|
|
157
|
+
else yield makeArrowMetadataBatch(table.schema);
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
|
|
@@ -167,7 +171,7 @@ export async function* queryProgressive(
|
|
|
167
171
|
async function* queryAppendBatches(
|
|
168
172
|
tableQuery: Query | string,
|
|
169
173
|
options: QueryOptions
|
|
170
|
-
): AsyncIterable<
|
|
174
|
+
): AsyncIterable<arrow.Table> {
|
|
171
175
|
const startedAt = Date.now();
|
|
172
176
|
let status: TableQueryExecutionSummary['status'] = 'early-terminated';
|
|
173
177
|
let rowsRead = 0;
|
|
@@ -179,6 +183,15 @@ async function* queryAppendBatches(
|
|
|
179
183
|
let earlyTerminationReason: TableQueryExecutionSummary['earlyTerminationReason'];
|
|
180
184
|
try {
|
|
181
185
|
options.signal?.throwIfAborted();
|
|
186
|
+
const scan = options._scan;
|
|
187
|
+
if (
|
|
188
|
+
options.offset !== undefined ||
|
|
189
|
+
options.limit !== undefined ||
|
|
190
|
+
scan?.limit !== undefined ||
|
|
191
|
+
(scan && 'offset' in scan && scan.offset !== undefined)
|
|
192
|
+
) {
|
|
193
|
+
throw new Error('Put offset and limit in the logical query, not the execution options.');
|
|
194
|
+
}
|
|
182
195
|
let parsedQuery: Query;
|
|
183
196
|
if (typeof tableQuery === 'string') {
|
|
184
197
|
const parser = await options.sqlParser;
|
|
@@ -225,12 +238,7 @@ async function* queryAppendBatches(
|
|
|
225
238
|
options.signal?.throwIfAborted();
|
|
226
239
|
if (!source || typeof source !== 'object')
|
|
227
240
|
throw new Error('Expected an Arrow table or table scan source.');
|
|
228
|
-
const inMemory =
|
|
229
|
-
'batches' in source
|
|
230
|
-
? (source as arrow.Table)
|
|
231
|
-
: 'shape' in source && source.shape === 'arrow-table'
|
|
232
|
-
? (source as ArrowTable).data
|
|
233
|
-
: null;
|
|
241
|
+
const inMemory = 'batches' in source ? (source as arrow.Table) : null;
|
|
234
242
|
if (
|
|
235
243
|
!inMemory &&
|
|
236
244
|
(!('read' in source) ||
|
|
@@ -252,6 +260,11 @@ async function* queryAppendBatches(
|
|
|
252
260
|
) {
|
|
253
261
|
throw new Error('Query source must support table reads.');
|
|
254
262
|
}
|
|
263
|
+
if (metadata?.hasDefaultRowWindow) {
|
|
264
|
+
throw new Error(
|
|
265
|
+
'Query source has a default offset or limit. Remove the source defaults and put offset and limit in the logical query.'
|
|
266
|
+
);
|
|
267
|
+
}
|
|
255
268
|
const sourceSchema = inMemory ? inMemory.schema : convertSchemaToArrow(metadata!.schema);
|
|
256
269
|
const names = sourceSchema.fields.map(field => field.name);
|
|
257
270
|
const {select, where, ...controls} = logicalQuery;
|
|
@@ -356,7 +369,7 @@ async function* queryAppendBatches(
|
|
|
356
369
|
options.signal?.throwIfAborted();
|
|
357
370
|
let emitted = false;
|
|
358
371
|
/** Adapts physical batches without pulling ahead of the query consumer. */
|
|
359
|
-
async function* inputs(): AsyncIterable<
|
|
372
|
+
async function* inputs(): AsyncIterable<arrow.Table> {
|
|
360
373
|
sourcesRead = 1;
|
|
361
374
|
const batches: AsyncIterable<unknown> = pushedPlan
|
|
362
375
|
? pushedPlan.read({signal: options.signal})
|
|
@@ -369,22 +382,27 @@ async function* queryAppendBatches(
|
|
|
369
382
|
if (
|
|
370
383
|
!pushedPlan &&
|
|
371
384
|
comparisonInputSchema &&
|
|
372
|
-
!arrow.util.compareSchemas(
|
|
385
|
+
!arrow.util.compareSchemas(
|
|
386
|
+
comparisonInputSchema,
|
|
387
|
+
convertSchemaToArrow(convertArrowToSchema(batch.schema))
|
|
388
|
+
)
|
|
373
389
|
) {
|
|
374
390
|
// A source may return a wider or differently ordered projection than requested.
|
|
375
|
-
|
|
376
|
-
batch = {...batch, ...wrapBatch(data)};
|
|
391
|
+
batch = batch.select(inputSchema.names);
|
|
377
392
|
if (
|
|
378
|
-
!arrow.util.compareSchemas(
|
|
393
|
+
!arrow.util.compareSchemas(
|
|
394
|
+
comparisonInputSchema,
|
|
395
|
+
convertSchemaToArrow(convertArrowToSchema(batch.schema))
|
|
396
|
+
)
|
|
379
397
|
)
|
|
380
398
|
throw new Error('Query input schema does not match source metadata.');
|
|
381
399
|
}
|
|
382
400
|
batchesRead++;
|
|
383
|
-
rowsRead += batch.
|
|
401
|
+
rowsRead += batch.numRows;
|
|
384
402
|
yield batch;
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
|
-
for await (const value of executeTableScanBatches(
|
|
405
|
+
for await (const value of executeTableScanBatches<arrow.Table>(
|
|
388
406
|
() => inputs(),
|
|
389
407
|
{
|
|
390
408
|
predicate: pushedPlan ? undefined : residual,
|
|
@@ -396,46 +414,40 @@ async function* queryAppendBatches(
|
|
|
396
414
|
{
|
|
397
415
|
filter: (batch, predicate, signal) => {
|
|
398
416
|
if (pushedPlan) return batch;
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
? filterArrowTable(input.data, predicate, {signal})
|
|
411
|
-
: input.data;
|
|
412
|
-
return {...input, ...wrapBatch(data)};
|
|
417
|
+
if (compiledFilter) {
|
|
418
|
+
return filterArrowRows(
|
|
419
|
+
batch,
|
|
420
|
+
recordBatch => {
|
|
421
|
+
const matches = compiledFilter.evaluate(recordBatch, {signal});
|
|
422
|
+
return index => matches.get(index) === true;
|
|
423
|
+
},
|
|
424
|
+
{signal}
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
return predicate ? filterArrowTable(batch, predicate, {signal}) : batch;
|
|
413
428
|
},
|
|
414
|
-
project: batch =>
|
|
415
|
-
const input = batch as ArrowTableBatch;
|
|
416
|
-
return pushedPlan || computedProjection
|
|
417
|
-
? input
|
|
418
|
-
: {...input, ...wrapBatch(project(input.data))};
|
|
419
|
-
}
|
|
429
|
+
project: batch => (pushedPlan || computedProjection ? batch : project(batch))
|
|
420
430
|
}
|
|
421
431
|
)) {
|
|
422
|
-
const input = value as ArrowTableBatch;
|
|
423
432
|
const finishProjection = pushedPlan
|
|
424
433
|
? pushedPlan.project
|
|
425
434
|
: computedProjection
|
|
426
435
|
? project
|
|
427
436
|
: undefined;
|
|
428
|
-
const batch = finishProjection
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
437
|
+
const batch = finishProjection ? finishProjection(value) : value;
|
|
438
|
+
if (
|
|
439
|
+
!arrow.util.compareSchemas(
|
|
440
|
+
comparisonSchema,
|
|
441
|
+
convertSchemaToArrow(convertArrowToSchema(batch.schema))
|
|
442
|
+
)
|
|
443
|
+
)
|
|
432
444
|
throw new Error('Query output schema does not match source metadata.');
|
|
433
445
|
emitted = true;
|
|
434
|
-
rowsReturned += batch.
|
|
446
|
+
rowsReturned += batch.numRows;
|
|
435
447
|
yield batch;
|
|
436
448
|
}
|
|
437
449
|
// An empty schema-bearing batch makes collected and streaming empty results identical.
|
|
438
|
-
if (!emitted) yield
|
|
450
|
+
if (!emitted) yield empty;
|
|
439
451
|
if (normalized.limit !== undefined && rowsReturned >= normalized.limit)
|
|
440
452
|
earlyTerminationReason = 'limit';
|
|
441
453
|
status = earlyTerminationReason ? 'early-terminated' : 'completed';
|
|
@@ -487,40 +499,25 @@ async function normalizeTypedQuery(query: Query): Promise<SQLQuery | TableQuery>
|
|
|
487
499
|
}
|
|
488
500
|
|
|
489
501
|
/** Emits original Arrow RecordBatches without copying their buffers. */
|
|
490
|
-
async function* memoryBatches(data: arrow.Table): AsyncIterable<
|
|
491
|
-
for (const batch of data.batches) yield
|
|
502
|
+
async function* memoryBatches(data: arrow.Table): AsyncIterable<arrow.Table> {
|
|
503
|
+
for (const batch of data.batches) yield new arrow.Table(data.schema, [batch]);
|
|
492
504
|
}
|
|
493
505
|
|
|
494
506
|
/** Converts supported native table batches to Arrow while preserving their declared schema. */
|
|
495
|
-
function normalizeBatch(value: unknown, fallbackSchema: Schema):
|
|
507
|
+
function normalizeBatch(value: unknown, fallbackSchema: Schema): arrow.Table {
|
|
496
508
|
if (!value || typeof value !== 'object') throw new Error('Unsupported query batch.');
|
|
497
509
|
if ('numRows' in value) {
|
|
498
510
|
const batch = value as arrow.RecordBatch;
|
|
499
|
-
return
|
|
511
|
+
return new arrow.Table(batch.schema, [batch]);
|
|
500
512
|
}
|
|
501
513
|
if (!('shape' in value)) throw new Error('Unsupported query batch.');
|
|
502
514
|
const input = value as TableBatch;
|
|
503
515
|
const batch = {...input, schema: input.schema ?? fallbackSchema} as TableBatch;
|
|
504
|
-
if (
|
|
505
|
-
!['arrow-table', 'object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape)
|
|
506
|
-
)
|
|
516
|
+
if (!['object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape))
|
|
507
517
|
throw new Error(`Unsupported query batch shape: ${batch.shape}`);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
: convertTableToArrow(batch);
|
|
512
|
-
return {...batch, ...wrapBatch(data)} as ArrowTableBatch;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/** Wraps Arrow data in the standard batch envelope. */
|
|
516
|
-
function wrapBatch(data: arrow.Table): ArrowTableBatch {
|
|
517
|
-
return {
|
|
518
|
-
shape: 'arrow-table',
|
|
519
|
-
data,
|
|
520
|
-
schema: convertArrowToSchema(data.schema),
|
|
521
|
-
batchType: 'data',
|
|
522
|
-
length: data.numRows
|
|
523
|
-
} as ArrowTableBatch;
|
|
518
|
+
return batch.length === 0 && batch.schema
|
|
519
|
+
? new arrow.Table(convertSchemaToArrow(batch.schema))
|
|
520
|
+
: convertTableToArrow(batch);
|
|
524
521
|
}
|
|
525
522
|
|
|
526
523
|
/** Checks predicate tree bounds and detects casts that require Arrow execution. */
|
|
@@ -591,7 +588,7 @@ function isUnsupportedQueryExpression(value: unknown): boolean {
|
|
|
591
588
|
);
|
|
592
589
|
}
|
|
593
590
|
|
|
594
|
-
export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/
|
|
591
|
+
export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/sql/parser';
|
|
595
592
|
|
|
596
593
|
export {createSQLCatalog} from './sql-catalog';
|
|
597
594
|
export type {SQLCatalog, SQLCatalogQuery, SQLCatalogSource, SQLCatalogTable} from './sql-catalog';
|