@loaders.gl/core 5.0.0-beta.1 → 5.0.0-beta.10
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/GEOARROW-README.md +1 -1
- package/README.md +4 -2
- package/SCAN-README.md +1 -1
- package/SCHEMA-UTILS-README.md +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 +5 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +5 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +6 -2
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +6 -2
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/geojson-table.cjs +295 -18
- package/dist/arrow-geometry/geojson-table.cjs.map +3 -3
- package/dist/arrow-geometry/geojson-table.d.ts +10 -3
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +23 -13
- 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/index.cjs +0 -11
- package/dist/arrow-geometry/index.cjs.map +2 -2
- package/dist/arrow-geometry/index.d.ts +0 -1
- package/dist/arrow-geometry/index.d.ts.map +1 -1
- package/dist/arrow-geometry/index.js +0 -1
- package/dist/arrow-geometry/index.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 +173 -0
- package/dist/arrow-worker-transport.cjs.map +6 -0
- package/dist/arrow-worker-transport.d.ts +15 -0
- package/dist/arrow-worker-transport.d.ts.map +1 -0
- package/dist/arrow-worker-transport.js +151 -0
- package/dist/arrow-worker-transport.js.map +1 -0
- package/dist/cluster-source.cjs +6874 -0
- package/dist/cluster-source.cjs.map +6 -0
- package/dist/cluster-source.d.ts +2 -0
- package/dist/cluster-source.d.ts.map +1 -0
- package/dist/cluster-source.js +2 -0
- package/dist/cluster-source.js.map +1 -0
- package/dist/dist.dev.js +3035 -823
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +2447 -0
- package/dist/federated-table-scan-source.cjs.map +6 -0
- package/dist/federated-table-scan-source.d.ts +2 -0
- package/dist/federated-table-scan-source.d.ts.map +1 -0
- package/dist/federated-table-scan-source.js +2 -0
- package/dist/federated-table-scan-source.js.map +1 -0
- 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 +4 -7
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +1 -4
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +1 -0
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +2 -0
- 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 +2 -2
- 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 +2 -2
- 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 +6 -4
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +9 -4
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +6 -4
- 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 +6 -4
- 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 +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.js +1 -1
- 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-geometry-column-to-binary-feature-collection.cjs +4 -8
- 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.d.ts.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
- 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 +0 -6
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +2 -3
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js +0 -6
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
- package/dist/index.cjs +738 -1372
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/api/create-data-source.d.ts +20 -9
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +55 -45
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +11 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +3 -2
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +3 -3
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +15 -19
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +7 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +17 -67
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +5 -3
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +12 -7
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +5 -3
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +61 -6
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +5 -3
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +8 -6
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +5 -3
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +26 -15
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts +4 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +47 -53
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +1 -1
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +2 -2
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +2 -37
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +2 -63
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +16 -0
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
- package/dist/lib/loader-utils/native-arrow.js +84 -0
- package/dist/lib/loader-utils/native-arrow.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.d.ts +3 -2
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-defaults.js +9 -10
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts +0 -6
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +31 -114
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/loader-utils/format-types.d.ts +3 -0
- package/dist/loader-utils/format-types.d.ts.map +1 -1
- package/dist/loader-utils/index.cjs +838 -1284
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +16 -7
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +8 -4
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/json-loader.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.d.ts +4 -0
- package/dist/loader-utils/lib/files/http-file-transport.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.js +45 -1
- package/dist/loader-utils/lib/files/http-file-transport.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-types.d.ts +2 -0
- package/dist/loader-utils/lib/files/http-file-types.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/read-range-response.d.ts +3 -0
- package/dist/loader-utils/lib/files/read-range-response.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/read-range-response.js +62 -0
- package/dist/loader-utils/lib/files/read-range-response.js.map +1 -0
- package/dist/loader-utils/lib/log-utils/log.d.ts +23 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +32 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/pace-batch-iterator.d.ts +14 -0
- package/dist/loader-utils/lib/pace-batch-iterator.d.ts.map +1 -0
- package/dist/loader-utils/lib/pace-batch-iterator.js +51 -0
- package/dist/loader-utils/lib/pace-batch-iterator.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-credentials.js +1 -1
- package/dist/loader-utils/lib/request-utils/request-credentials.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +43 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +104 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/{experimental-scan-options.d.ts → query-options.d.ts} +5 -8
- package/dist/loader-utils/lib/scan-utils/query-options.d.ts.map +1 -0
- package/dist/{schema-utils/lib/table/batch-builder/table-batch-aggregator.js → loader-utils/lib/scan-utils/query-options.js} +1 -1
- package/dist/loader-utils/lib/scan-utils/query-options.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +54 -18
- 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 +16 -6
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +54 -3
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -3
- 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 +33 -18
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts +4 -0
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +53 -14
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/sources/image-source.d.ts +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +30 -0
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -0
- package/dist/loader-utils/lib/{scan-utils/experimental-scan-options.js → sources/table-source-collection.js} +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.js.map +1 -0
- package/dist/loader-utils/lib/sources/utils/utils.js +1 -1
- package/dist/loader-utils/lib/sources/utils/utils.js.map +1 -1
- package/dist/loader-utils/lib/sources/vector-source.d.ts +4 -3
- package/dist/loader-utils/lib/sources/vector-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -2
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js +2 -5
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +40 -21
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +120 -91
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/source-types.d.ts +7 -5
- package/dist/loader-utils/source-types.d.ts.map +1 -1
- package/dist/loader-utils/source-types.js +9 -1
- package/dist/loader-utils/source-types.js.map +1 -1
- package/dist/null-loader.d.ts +0 -18
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +1 -19
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +771 -82
- package/dist/null-worker.js +742 -81
- package/dist/polyfills/images/encode-image-node.d.ts +18 -15
- package/dist/polyfills/images/encode-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/encode-image-node.js +19 -33
- package/dist/polyfills/images/encode-image-node.js.map +1 -1
- package/dist/polyfills/images/image-codecs-node.d.ts +2 -6
- package/dist/polyfills/images/image-codecs-node.d.ts.map +1 -1
- package/dist/polyfills/images/image-codecs-node.js +2 -24
- package/dist/polyfills/images/image-codecs-node.js.map +1 -1
- package/dist/polyfills/images/load-sharp.d.ts +3 -0
- package/dist/polyfills/images/load-sharp.d.ts.map +1 -0
- package/dist/polyfills/images/load-sharp.js +11 -0
- package/dist/polyfills/images/load-sharp.js.map +1 -0
- package/dist/polyfills/images/node-image-bitmap.d.ts +1 -1
- package/dist/polyfills/images/node-image-bitmap.js +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts.map +1 -1
- package/dist/polyfills/images/node-image-formats.js +10 -4
- package/dist/polyfills/images/node-image-formats.js.map +1 -1
- package/dist/polyfills/images/parse-image-node.d.ts +10 -2
- package/dist/polyfills/images/parse-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/parse-image-node.js +20 -32
- package/dist/polyfills/images/parse-image-node.js.map +1 -1
- package/dist/polyfills/index.cjs +76 -151
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +2 -2
- package/dist/polyfills/index.js.map +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +134 -0
- package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
- package/dist/scan/arrow-execution/expressions.d.ts +11 -0
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
- package/dist/scan/arrow-execution/expressions.js +86 -0
- package/dist/scan/arrow-execution/expressions.js.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +255 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +18 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js +224 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs +70 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +8 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.js +39 -0
- package/dist/scan/arrow-execution/project-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution.cjs +34 -0
- package/dist/scan/arrow-execution.cjs.map +7 -0
- package/dist/scan/arrow-execution.d.ts +4 -0
- package/dist/scan/arrow-execution.d.ts.map +1 -0
- package/dist/scan/arrow-execution.js +6 -0
- package/dist/scan/arrow-execution.js.map +1 -0
- package/dist/scan/arrow-query.cjs.map +1 -1
- package/dist/scan/arrow-query.d.ts +1 -1
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/catalog-query-source.cjs +122 -0
- package/dist/scan/catalog-query-source.cjs.map +7 -0
- package/dist/scan/catalog-query-source.d.ts +6 -0
- package/dist/scan/catalog-query-source.d.ts.map +1 -0
- package/dist/scan/catalog-query-source.js +115 -0
- package/dist/scan/catalog-query-source.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +38 -38
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts +6 -10
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +35 -35
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +208 -4
- package/dist/scan/index.cjs.map +4 -4
- package/dist/scan/index.d.ts +13 -3
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +6 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +6 -9
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -314
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.cjs +75 -0
- package/dist/scan/query-arrow-table-in-batches.cjs.map +7 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts +8 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.js +54 -0
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -0
- package/dist/scan/query-arrow-table.cjs +65 -202
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +7 -40
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +51 -211
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query-open-source.cjs +52 -0
- package/dist/scan/query-open-source.cjs.map +7 -0
- package/dist/scan/query-open-source.d.ts +4 -0
- package/dist/scan/query-open-source.d.ts.map +1 -0
- package/dist/scan/query-open-source.js +26 -0
- package/dist/scan/query-open-source.js.map +1 -0
- package/dist/scan/query-progressive.cjs +190 -0
- package/dist/scan/query-progressive.cjs.map +7 -0
- package/dist/scan/query-progressive.d.ts +39 -0
- package/dist/scan/query-progressive.d.ts.map +1 -0
- package/dist/scan/query-progressive.js +173 -0
- package/dist/scan/query-progressive.js.map +1 -0
- package/dist/scan/query-pushdown.cjs +140 -0
- package/dist/scan/query-pushdown.cjs.map +7 -0
- package/dist/scan/query-pushdown.d.ts +14 -0
- package/dist/scan/query-pushdown.d.ts.map +1 -0
- package/dist/scan/query-pushdown.js +136 -0
- package/dist/scan/query-pushdown.js.map +1 -0
- package/dist/scan/query.cjs +381 -0
- package/dist/scan/query.cjs.map +7 -0
- package/dist/scan/query.d.ts +64 -0
- package/dist/scan/query.d.ts.map +1 -0
- package/dist/scan/query.js +419 -0
- package/dist/scan/query.js.map +1 -0
- package/dist/scan/resolve-query-source.cjs +59 -0
- package/dist/scan/resolve-query-source.cjs.map +7 -0
- package/dist/scan/resolve-query-source.d.ts +6 -0
- package/dist/scan/resolve-query-source.d.ts.map +1 -0
- package/dist/scan/resolve-query-source.js +37 -0
- package/dist/scan/resolve-query-source.js.map +1 -0
- package/dist/scan/rows-to-arrow.cjs +1 -28
- package/dist/scan/rows-to-arrow.cjs.map +2 -2
- package/dist/scan/rows-to-arrow.d.ts +3 -3
- package/dist/scan/rows-to-arrow.d.ts.map +1 -1
- package/dist/scan/rows-to-arrow.js +2 -32
- package/dist/scan/rows-to-arrow.js.map +1 -1
- package/dist/scan/scan-engine.cjs.map +2 -2
- package/dist/scan/scan-engine.d.ts +5 -5
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js.map +1 -1
- package/dist/scan/sql-catalog.cjs +110 -0
- package/dist/scan/sql-catalog.cjs.map +7 -0
- package/dist/scan/sql-catalog.d.ts +47 -0
- package/dist/scan/sql-catalog.d.ts.map +1 -0
- package/dist/scan/sql-catalog.js +97 -0
- package/dist/scan/sql-catalog.js.map +1 -0
- package/dist/scan/table-query.cjs.map +2 -2
- package/dist/scan/table-query.d.ts +4 -1
- package/dist/scan/table-query.d.ts.map +1 -1
- package/dist/scan/table-query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +14 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +6 -5
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +17 -14
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/geometry/geoarrow.d.ts +3 -6
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -1
- package/dist/schema/index.cjs +11 -7
- package/dist/schema/index.cjs.map +2 -2
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/schema/index.js.map +1 -1
- package/dist/schema-utils/index.cjs +690 -823
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +6 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +6 -4
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +17 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +106 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -0
- package/dist/schema-utils/lib/converters/convert.js +9 -2
- package/dist/schema-utils/lib/converters/convert.js.map +1 -1
- package/dist/schema-utils/lib/converters/types.d.ts +2 -0
- package/dist/schema-utils/lib/converters/types.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +4 -3
- 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 +4 -4
- 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 -3
- 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 +9 -2
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.d.ts +14 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.js +39 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.js.map +1 -0
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts +2 -14
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/mesh-utils.js +1 -35
- package/dist/schema-utils/lib/mesh/mesh-utils.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 +6 -5
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts +9 -9
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js +13 -46
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts +9 -20
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js +61 -73
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts +4 -3
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +30 -9
- 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 +6 -9
- 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 +26 -15
- 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 +4 -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 +33 -9
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts +3 -3
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/query-arrow-table.js +9 -23
- package/dist/schema-utils/lib/table/query-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +27 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +23 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +12 -10
- 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 +15 -26
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts +6 -36
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-table.js +5 -42
- package/dist/schema-utils/lib/table/tables/convert-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.d.ts +3 -55
- package/dist/schema-utils/lib/table/tables/make-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +3 -59
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts +18 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +42 -31
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts +6 -5
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js +2 -2
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +3 -3
- 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 +7 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +1760 -0
- package/dist/vector-table-scan-source.cjs.map +6 -0
- package/dist/vector-table-scan-source.d.ts +2 -0
- package/dist/vector-table-scan-source.d.ts.map +1 -0
- package/dist/vector-table-scan-source.js +2 -0
- package/dist/vector-table-scan-source.js.map +1 -0
- package/dist/worker-utils/index.cjs +407 -1184
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/index.d.ts +2 -8
- package/dist/worker-utils/index.d.ts.map +1 -1
- package/dist/worker-utils/index.js +1 -10
- package/dist/worker-utils/index.js.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/env-utils/version.js.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +3 -2
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts +5 -7
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.js +76 -146
- package/dist/worker-utils/lib/worker-api/create-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +17 -45
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +214 -312
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts +36 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.js +23 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.js.map +1 -0
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts +1 -0
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js +3 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js +836 -147
- package/dist/worker-utils/null-worker-node.js.map +4 -4
- package/dist/worker-utils/null-worker.js +804 -143
- package/dist/worker-utils/null-worker.js.map +4 -4
- package/dist/worker-utils/types.d.ts +55 -72
- package/dist/worker-utils/types.d.ts.map +1 -1
- package/package.json +126 -35
- package/src/arrow-geometry/binary-geometry-to-wkb.ts +1 -1
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -1
- package/src/arrow-geometry/feature-table.ts +6 -2
- package/src/arrow-geometry/geojson-table.ts +32 -21
- package/src/arrow-geometry/geometry-codecs.ts +2 -2
- package/src/arrow-geometry/geometry-to-wkt.ts +2 -2
- package/src/arrow-geometry/index.ts +0 -9
- package/src/arrow-geometry/wkb-builder.ts +2 -2
- package/src/arrow-geometry/wkb-statistics.ts +2 -2
- package/src/arrow-worker-transport.ts +225 -0
- package/src/cluster-source.ts +1 -0
- package/src/federated-table-scan-source.ts +1 -0
- package/src/geoarrow/binary-polygon-to-geoarrow.ts +2 -2
- package/src/geoarrow/clustering/cluster-source.ts +4 -7
- package/src/geoarrow/convert-table-to-geoarrow.ts +3 -1
- 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 -3
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +14 -9
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +9 -6
- package/src/geoarrow/geoarrow-inspection.ts +2 -2
- package/src/geoarrow/geoarrow-stream.ts +1 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +1 -1
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
- 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 +8 -10
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
- package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
- package/src/index.ts +1 -5
- package/src/lib/api/create-data-source.ts +148 -58
- package/src/lib/api/encode.ts +14 -3
- package/src/lib/api/load-in-batches.ts +15 -7
- package/src/lib/api/load-loader.ts +22 -21
- package/src/lib/api/load.ts +61 -127
- package/src/lib/api/parse-file.ts +42 -23
- package/src/lib/api/parse-in-batches.ts +122 -17
- package/src/lib/api/parse-sync.ts +37 -19
- package/src/lib/api/parse.ts +51 -30
- package/src/lib/api/select-loader.ts +54 -69
- package/src/lib/api/select-source.ts +7 -1
- package/src/lib/loader-utils/get-fetch-function.ts +2 -2
- package/src/lib/loader-utils/loggers.ts +2 -70
- package/src/lib/loader-utils/native-arrow.ts +109 -0
- package/src/lib/loader-utils/option-defaults.ts +9 -10
- package/src/lib/loader-utils/option-utils.ts +33 -122
- package/src/loader-utils/format-types.ts +4 -0
- package/src/loader-utils/index.ts +50 -9
- package/src/loader-utils/lib/files/http-file-transport.ts +65 -1
- package/src/loader-utils/lib/files/http-file-types.ts +2 -0
- package/src/loader-utils/lib/files/read-range-response.ts +66 -0
- package/src/loader-utils/lib/log-utils/log.ts +36 -1
- package/src/loader-utils/lib/pace-batch-iterator.ts +66 -0
- package/src/loader-utils/lib/request-utils/request-credentials.ts +1 -1
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +174 -0
- package/src/loader-utils/lib/scan-utils/query-options.ts +44 -0
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +80 -28
- package/src/loader-utils/lib/scan-utils/table-query.ts +76 -8
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +54 -29
- package/src/loader-utils/lib/sources/data-source.ts +57 -16
- package/src/loader-utils/lib/sources/image-source.ts +1 -1
- package/src/loader-utils/lib/sources/table-source-collection.ts +38 -0
- package/src/loader-utils/lib/sources/utils/utils.ts +1 -1
- package/src/loader-utils/lib/sources/vector-source.ts +3 -3
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -2
- package/src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts +5 -6
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +41 -24
- package/src/loader-utils/loader-types.ts +190 -111
- package/src/loader-utils/source-types.ts +17 -6
- package/src/null-loader.ts +1 -20
- package/src/polyfills/README.md +2 -2
- package/src/polyfills/images/encode-image-node.ts +44 -37
- package/src/polyfills/images/image-codecs-node.ts +2 -37
- package/src/polyfills/images/load-sharp.ts +13 -0
- package/src/polyfills/images/node-image-bitmap.ts +1 -1
- package/src/polyfills/images/node-image-formats.ts +10 -4
- package/src/polyfills/images/parse-image-node.ts +31 -40
- package/src/polyfills/index.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +116 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +298 -0
- package/src/scan/arrow-execution/project-arrow-table.ts +53 -0
- package/src/scan/arrow-execution.ts +7 -0
- package/src/scan/arrow-query.ts +3 -0
- package/src/scan/catalog-query-source.ts +132 -0
- package/src/scan/federated-table-scan-source.ts +64 -72
- package/src/scan/index.ts +57 -5
- package/src/scan/parse-sql-predicate.ts +14 -367
- package/src/scan/query-arrow-table-in-batches.ts +55 -0
- package/src/scan/query-arrow-table.ts +81 -271
- package/src/scan/query-open-source.ts +39 -0
- package/src/scan/query-progressive.ts +229 -0
- package/src/scan/query-pushdown.ts +184 -0
- package/src/scan/query.ts +597 -0
- package/src/scan/resolve-query-source.ts +47 -0
- package/src/scan/rows-to-arrow.ts +3 -39
- package/src/scan/scan-engine.ts +6 -6
- package/src/scan/sql-catalog.ts +167 -0
- package/src/scan/table-query.ts +6 -1
- package/src/scan/vector-table-scan-source.ts +22 -18
- package/src/schema/geometry/geoarrow.ts +8 -19
- package/src/schema/index.ts +3 -2
- package/src/schema-utils/index.ts +23 -8
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +136 -0
- package/src/schema-utils/lib/converters/convert.ts +7 -2
- package/src/schema-utils/lib/converters/types.ts +2 -0
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +7 -9
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +10 -4
- package/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts +52 -0
- package/src/schema-utils/lib/mesh/mesh-utils.ts +3 -49
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +18 -8
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts +21 -51
- package/src/schema-utils/lib/table/batch-builder/table-batch-builder.ts +68 -83
- package/src/schema-utils/lib/table/batches/convert-batches.ts +41 -21
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +33 -19
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +48 -7
- package/src/schema-utils/lib/table/query-arrow-table.ts +14 -32
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +54 -0
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +30 -35
- package/src/schema-utils/lib/table/tables/convert-table.ts +11 -57
- package/src/schema-utils/lib/table/tables/make-table.ts +6 -70
- package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +66 -49
- package/src/schema-utils/lib/table/tables/table-converter/convert-tables.ts +12 -14
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +13 -10
- package/src/vector-table-scan-source.ts +1 -0
- package/src/worker-utils/index.ts +2 -18
- package/src/worker-utils/lib/library-utils/library-utils.ts +3 -2
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
- package/src/worker-utils/lib/worker-api/create-worker.ts +89 -188
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +246 -402
- package/src/worker-utils/lib/worker-api/task-runtime.ts +66 -0
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
- package/src/worker-utils/lib/worker-utils/get-transfer-list.ts +2 -0
- package/src/worker-utils/types.ts +74 -109
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs +0 -477
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts +0 -29
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js +0 -434
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs +0 -39
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts +0 -2
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js +0 -5
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts +0 -40
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/data-view-file.js +0 -68
- package/dist/loader-utils/lib/file-provider/data-view-file.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts +0 -54
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-handle-file.js +0 -102
- package/dist/loader-utils/lib/file-provider/file-handle-file.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts +0 -45
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js +0 -13
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts +0 -57
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider.js +0 -114
- package/dist/loader-utils/lib/file-provider/file-provider.js.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.d.ts.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.js.map +0 -1
- package/dist/schema/deprecated/mesh-utils.d.ts +0 -12
- package/dist/schema/deprecated/mesh-utils.d.ts.map +0 -1
- package/dist/schema/deprecated/mesh-utils.js +0 -37
- package/dist/schema/deprecated/mesh-utils.js.map +0 -1
- package/dist/schema-utils/arrow-transport.cjs +0 -691
- package/dist/schema-utils/arrow-transport.cjs.map +0 -6
- package/dist/schema-utils/arrow-transport.d.ts +0 -4
- package/dist/schema-utils/arrow-transport.d.ts.map +0 -1
- package/dist/schema-utils/arrow-transport.js +0 -7
- package/dist/schema-utils/arrow-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts +0 -76
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js +0 -182
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts +0 -33
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js +0 -134
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts +0 -10
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js +0 -71
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts +0 -19
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js +0 -64
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts +0 -20
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js +0 -83
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts +0 -21
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js +0 -86
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts +0 -24
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.js.map +0 -1
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts +0 -32
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts.map +0 -1
- package/dist/worker-utils/lib/async-queue/async-queue.js +0 -91
- package/dist/worker-utils/lib/async-queue/async-queue.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts +0 -20
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.js +0 -131
- package/dist/worker-utils/lib/worker-farm/worker-body.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts +0 -58
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.js +0 -116
- package/dist/worker-utils/lib/worker-farm/worker-farm.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts +0 -34
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.js +0 -74
- package/dist/worker-utils/lib/worker-farm/worker-job.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts +0 -94
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.js +0 -246
- package/dist/worker-utils/lib/worker-farm/worker-pool.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts +0 -67
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.js +0 -175
- package/dist/worker-utils/lib/worker-farm/worker-thread.js.map +0 -1
- package/src/arrow-geometry/arrow-geoarrow-adapter.ts +0 -568
- package/src/geoarrow/lib/arrow-geoarrow-adapter.ts +0 -12
- package/src/loader-utils/lib/file-provider/data-view-file.ts +0 -83
- package/src/loader-utils/lib/file-provider/file-handle-file.ts +0 -114
- package/src/loader-utils/lib/file-provider/file-provider-interface.ts +0 -60
- package/src/loader-utils/lib/file-provider/file-provider.ts +0 -130
- package/src/loader-utils/lib/scan-utils/experimental-scan-options.ts +0 -46
- package/src/polyfills/images/encode-image.node.ts.disabled +0 -41
- package/src/polyfills/images/parse-image.node.ts.disabled +0 -55
- package/src/schema/deprecated/mesh-utils.ts +0 -46
- package/src/schema-utils/arrow-transport.ts +0 -7
- package/src/schema-utils/lib/arrow/arrow-table-transport.ts +0 -282
- package/src/schema-utils/lib/arrow/split-arrow-buffers.ts +0 -247
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator-builders.ts.disabled +0 -190
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.ts +0 -85
- package/src/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.ts +0 -82
- package/src/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.ts +0 -103
- package/src/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.ts +0 -108
- package/src/schema-utils/lib/table/batch-builder/table-batch-aggregator.ts +0 -28
- package/src/worker-utils/lib/async-queue/async-queue.ts +0 -100
- package/src/worker-utils/lib/worker-farm/worker-body.ts +0 -145
- package/src/worker-utils/lib/worker-farm/worker-farm.ts +0 -144
- package/src/worker-utils/lib/worker-farm/worker-job.ts +0 -85
- package/src/worker-utils/lib/worker-farm/worker-pool.ts +0 -316
- package/src/worker-utils/lib/worker-farm/worker-thread.ts +0 -206
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/scan/query-pushdown.ts"],
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Table, util, type Schema} from 'apache-arrow';\nimport type {SQLQuery} from '@math.gl/expressions/sql';\nimport {convertArrowToSchema, convertSchemaToArrow} from '@loaders.gl/core/schema-utils';\nimport type {\n TableQueryCapabilities,\n TableScanSource,\n TableQueryPushdownPlan\n} from '@loaders.gl/core/loader-utils';\n\n/** Source plan with an optional final Arrow projection. */\ntype NegotiatedQueryPlan = TableQueryPushdownPlan & {\n /** Completes the original SELECT list using the source's intermediate columns. */\n project?: (table: Table) => Table;\n};\n\n/** Negotiates exact whole-query execution only for sources that opt in, without reading rows. */\nexport async function planQueryPushdown(\n source: TableScanSource,\n query: Exclude<SQLQuery, {command: unknown}>,\n capabilities: TableQueryCapabilities | undefined,\n outputSchema: Schema,\n computed: boolean,\n inputSchema: Schema,\n signal?: AbortSignal\n): Promise<NegotiatedQueryPlan | null> {\n const request = {...query};\n delete request.from;\n const plan = canPushdownQuery(request, capabilities, computed)\n ? await source.planQueryPushdown!(request, {signal})\n : null;\n if (!plan && computed && source.supportsQueryProjectionPushdown) {\n return planPartialProjection(source, request, capabilities, inputSchema, outputSchema, signal);\n }\n return validatePushdownPlan(plan, outputSchema, query.limit, signal);\n}\n\n/** Validates the schema before execution and on every physical batch. */\nfunction validatePushdownPlan(\n plan: TableQueryPushdownPlan | null,\n outputSchema: Schema,\n limit?: number,\n signal?: AbortSignal\n): TableQueryPushdownPlan | null {\n signal?.throwIfAborted();\n if (plan && !util.compareSchemas(outputSchema, convertSchemaToArrow(plan.schema))) {\n throw new Error('Query pushdown schema does not match the logical output schema.');\n }\n if (!plan) return null;\n return {\n schema: plan.schema,\n /** Validates native output lazily and closes its iterator on failure or consumer return. */\n async *read(options = {}) {\n let rowsReturned = 0;\n for await (const batch of plan.read(options)) {\n options.signal?.throwIfAborted();\n const native = !('shape' in batch);\n const schema = native ? batch.schema : batch.data.schema;\n const rowCount = native ? batch.numRows : batch.data.numRows;\n if (\n !util.compareSchemas(outputSchema, convertSchemaToArrow(convertArrowToSchema(schema)))\n ) {\n throw new Error('Query pushdown batch schema does not match the logical output schema.');\n }\n rowsReturned += rowCount;\n if (limit !== undefined && rowsReturned > limit) {\n throw new Error('Query pushdown returned more rows than the requested limit.');\n }\n yield native ? batch : {...batch, length: rowCount};\n }\n }\n };\n}\n\n/**\n * Splits SELECT items after filtering and windowing. The source must accept the entire\n * rewritten query so residual expressions see the original row set and order.\n */\nasync function planPartialProjection(\n source: TableScanSource,\n query: import('@loaders.gl/core/loader-utils').TableQueryPushdownRequest,\n capabilities: TableQueryCapabilities | undefined,\n inputSchema: Schema,\n outputSchema: Schema,\n signal?: AbortSignal\n): Promise<NegotiatedQueryPlan | null> {\n if (!query.select) return null;\n const accepted = query.select.map(\n selection =>\n typeof selection !== 'string' &&\n ('expression' in selection || 'array' in selection) &&\n source.supportsQueryProjectionPushdown!(selection)\n );\n if (!accepted.some(Boolean) || accepted.every(Boolean)) return null;\n const {compileArrowProjection, getProjectionColumns} = await import(\n './arrow-execution/expressions'\n );\n const nativeSelections: NonNullable<typeof query.select>[number][] = [];\n const dependencies = new Set<string>();\n const occupied = new Set(inputSchema.fields.map(field => field.name.toLowerCase()));\n const residual = query.select.map((selection, index) => {\n const name = outputSchema.fields[index].name;\n if (accepted[index] && typeof selection !== 'string') {\n let alias = `__query_projection_${index}`;\n while (occupied.has(alias)) alias += '_';\n occupied.add(alias);\n nativeSelections.push({...selection, as: alias});\n return {column: alias, as: name};\n }\n for (const dependency of getProjectionColumns([selection])) dependencies.add(dependency);\n return typeof selection === 'string' ? selection : {...selection, as: name};\n });\n const request = {...query, select: [...dependencies, ...nativeSelections]};\n if (!canPushdownQuery(request, capabilities, true)) return null;\n const empty = new Table(inputSchema);\n const intermediate = compileArrowProjection(inputSchema, request.select, signal)(empty);\n const project = compileArrowProjection(intermediate.schema, residual, signal);\n const plan = await source.planQueryPushdown!(request, {signal});\n const checked = validatePushdownPlan(\n plan,\n convertSchemaToArrow(convertArrowToSchema(intermediate.schema)),\n query.limit,\n signal\n );\n return checked && {...checked, project};\n}\n\n/** Uses effective source capabilities as a ceiling before asking for exact query acceptance. */\nfunction canPushdownQuery(\n query: Exclude<SQLQuery, {command: unknown}>,\n capabilities: TableQueryCapabilities | undefined,\n computed: boolean\n): boolean {\n if (!capabilities) return false;\n const supports = (support: string | undefined): boolean =>\n support === 'pushdown' || support === 'pushdown+residual';\n return (\n (!query.select || supports(capabilities.projection)) &&\n (!query.where || supports(capabilities.predicate)) &&\n (!computed || !containsNonCastExpression(query) || supports(capabilities.expressions)) &&\n (!containsQueryCast(query) || supports(capabilities.cast)) &&\n (query.offset === undefined || supports(capabilities.offset)) &&\n (query.limit === undefined || supports(capabilities.limit))\n );\n}\n\n/** Recognizes both parsed expression CAST calls and portable predicate cast annotations. */\nfunction containsQueryCast(value: unknown): boolean {\n if (!value || typeof value !== 'object') return false;\n if (Array.isArray(value)) return value.some(containsQueryCast);\n const node = value as Record<string, unknown>;\n if (Array.isArray(node.casts) && node.casts.length) return true;\n if (\n node.type === 'CallExpression' &&\n node.callee &&\n typeof node.callee === 'object' &&\n 'name' in node.callee &&\n String(node.callee.name).toLowerCase() === 'cast'\n )\n return true;\n return Object.values(node).some(containsQueryCast);\n}\n\n/** CAST-only expressions use the independent cast capability; other computation needs expressions. */\nfunction containsNonCastExpression(value: unknown): boolean {\n if (!value || typeof value !== 'object') return false;\n if (Array.isArray(value)) return value.some(containsNonCastExpression);\n const node = value as Record<string, unknown>;\n if (Array.isArray(node.array)) return true;\n if (typeof node.type === 'string' && !['Identifier', 'Literal'].includes(node.type)) {\n if (\n node.type !== 'CallExpression' ||\n !node.callee ||\n typeof node.callee !== 'object' ||\n !('name' in node.callee) ||\n String(node.callee.name).toLowerCase() !== 'cast'\n )\n return true;\n }\n return Object.values(node).some(containsNonCastExpression);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAuC;AAEvC,0BAAyD;AAczD,eAAsB,kBACpB,QACA,OACA,cACA,cACA,UACA,aACA,QACqC;AACrC,QAAM,UAAU,EAAC,GAAG,MAAK;AACzB,SAAO,QAAQ;AACf,QAAM,OAAO,iBAAiB,SAAS,cAAc,QAAQ,IACzD,MAAM,OAAO,kBAAmB,SAAS,EAAC,OAAM,CAAC,IACjD;AACJ,MAAI,CAAC,QAAQ,YAAY,OAAO,iCAAiC;AAC/D,WAAO,sBAAsB,QAAQ,SAAS,cAAc,aAAa,cAAc,MAAM;AAAA,EAC/F;AACA,SAAO,qBAAqB,MAAM,cAAc,MAAM,OAAO,MAAM;AACrE;AAGA,SAAS,qBACP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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Table, type Schema } from 'apache-arrow';
|
|
2
|
+
import type { SQLQuery } from '@math.gl/expressions/sql';
|
|
3
|
+
import type { TableQueryCapabilities, TableScanSource, TableQueryPushdownPlan } from '@loaders.gl/core/loader-utils';
|
|
4
|
+
/** Source plan with an optional final Arrow projection. */
|
|
5
|
+
type NegotiatedQueryPlan = TableQueryPushdownPlan & {
|
|
6
|
+
/** Completes the original SELECT list using the source's intermediate columns. */
|
|
7
|
+
project?: (table: Table) => Table;
|
|
8
|
+
};
|
|
9
|
+
/** Negotiates exact whole-query execution only for sources that opt in, without reading rows. */
|
|
10
|
+
export declare function planQueryPushdown(source: TableScanSource, query: Exclude<SQLQuery, {
|
|
11
|
+
command: unknown;
|
|
12
|
+
}>, capabilities: TableQueryCapabilities | undefined, outputSchema: Schema, computed: boolean, inputSchema: Schema, signal?: AbortSignal): Promise<NegotiatedQueryPlan | null>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=query-pushdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-pushdown.d.ts","sourceRoot":"","sources":["../../src/scan/query-pushdown.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,EAAQ,KAAK,MAAM,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,2DAA2D;AAC3D,KAAK,mBAAmB,GAAG,sBAAsB,GAAG;IAClD,kFAAkF;IAClF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC;CACnC,CAAC;AAEF,iGAAiG;AACjG,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CAAC,EAC5C,YAAY,EAAE,sBAAsB,GAAG,SAAS,EAChD,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAUrC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Table, util } from 'apache-arrow';
|
|
5
|
+
import { convertArrowToSchema, convertSchemaToArrow } from '@loaders.gl/core/schema-utils';
|
|
6
|
+
/** Negotiates exact whole-query execution only for sources that opt in, without reading rows. */
|
|
7
|
+
export async function planQueryPushdown(source, query, capabilities, outputSchema, computed, inputSchema, signal) {
|
|
8
|
+
const request = { ...query };
|
|
9
|
+
delete request.from;
|
|
10
|
+
const plan = canPushdownQuery(request, capabilities, computed)
|
|
11
|
+
? await source.planQueryPushdown(request, { signal })
|
|
12
|
+
: null;
|
|
13
|
+
if (!plan && computed && source.supportsQueryProjectionPushdown) {
|
|
14
|
+
return planPartialProjection(source, request, capabilities, inputSchema, outputSchema, signal);
|
|
15
|
+
}
|
|
16
|
+
return validatePushdownPlan(plan, outputSchema, query.limit, signal);
|
|
17
|
+
}
|
|
18
|
+
/** Validates the schema before execution and on every physical batch. */
|
|
19
|
+
function validatePushdownPlan(plan, outputSchema, limit, signal) {
|
|
20
|
+
signal?.throwIfAborted();
|
|
21
|
+
if (plan && !util.compareSchemas(outputSchema, convertSchemaToArrow(plan.schema))) {
|
|
22
|
+
throw new Error('Query pushdown schema does not match the logical output schema.');
|
|
23
|
+
}
|
|
24
|
+
if (!plan)
|
|
25
|
+
return null;
|
|
26
|
+
return {
|
|
27
|
+
schema: plan.schema,
|
|
28
|
+
/** Validates native output lazily and closes its iterator on failure or consumer return. */
|
|
29
|
+
async *read(options = {}) {
|
|
30
|
+
let rowsReturned = 0;
|
|
31
|
+
for await (const batch of plan.read(options)) {
|
|
32
|
+
options.signal?.throwIfAborted();
|
|
33
|
+
const native = !('shape' in batch);
|
|
34
|
+
const schema = native ? batch.schema : batch.data.schema;
|
|
35
|
+
const rowCount = native ? batch.numRows : batch.data.numRows;
|
|
36
|
+
if (!util.compareSchemas(outputSchema, convertSchemaToArrow(convertArrowToSchema(schema)))) {
|
|
37
|
+
throw new Error('Query pushdown batch schema does not match the logical output schema.');
|
|
38
|
+
}
|
|
39
|
+
rowsReturned += rowCount;
|
|
40
|
+
if (limit !== undefined && rowsReturned > limit) {
|
|
41
|
+
throw new Error('Query pushdown returned more rows than the requested limit.');
|
|
42
|
+
}
|
|
43
|
+
yield native ? batch : { ...batch, length: rowCount };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Splits SELECT items after filtering and windowing. The source must accept the entire
|
|
50
|
+
* rewritten query so residual expressions see the original row set and order.
|
|
51
|
+
*/
|
|
52
|
+
async function planPartialProjection(source, query, capabilities, inputSchema, outputSchema, signal) {
|
|
53
|
+
if (!query.select)
|
|
54
|
+
return null;
|
|
55
|
+
const accepted = query.select.map(selection => typeof selection !== 'string' &&
|
|
56
|
+
('expression' in selection || 'array' in selection) &&
|
|
57
|
+
source.supportsQueryProjectionPushdown(selection));
|
|
58
|
+
if (!accepted.some(Boolean) || accepted.every(Boolean))
|
|
59
|
+
return null;
|
|
60
|
+
const { compileArrowProjection, getProjectionColumns } = await import("./arrow-execution/expressions.js");
|
|
61
|
+
const nativeSelections = [];
|
|
62
|
+
const dependencies = new Set();
|
|
63
|
+
const occupied = new Set(inputSchema.fields.map(field => field.name.toLowerCase()));
|
|
64
|
+
const residual = query.select.map((selection, index) => {
|
|
65
|
+
const name = outputSchema.fields[index].name;
|
|
66
|
+
if (accepted[index] && typeof selection !== 'string') {
|
|
67
|
+
let alias = `__query_projection_${index}`;
|
|
68
|
+
while (occupied.has(alias))
|
|
69
|
+
alias += '_';
|
|
70
|
+
occupied.add(alias);
|
|
71
|
+
nativeSelections.push({ ...selection, as: alias });
|
|
72
|
+
return { column: alias, as: name };
|
|
73
|
+
}
|
|
74
|
+
for (const dependency of getProjectionColumns([selection]))
|
|
75
|
+
dependencies.add(dependency);
|
|
76
|
+
return typeof selection === 'string' ? selection : { ...selection, as: name };
|
|
77
|
+
});
|
|
78
|
+
const request = { ...query, select: [...dependencies, ...nativeSelections] };
|
|
79
|
+
if (!canPushdownQuery(request, capabilities, true))
|
|
80
|
+
return null;
|
|
81
|
+
const empty = new Table(inputSchema);
|
|
82
|
+
const intermediate = compileArrowProjection(inputSchema, request.select, signal)(empty);
|
|
83
|
+
const project = compileArrowProjection(intermediate.schema, residual, signal);
|
|
84
|
+
const plan = await source.planQueryPushdown(request, { signal });
|
|
85
|
+
const checked = validatePushdownPlan(plan, convertSchemaToArrow(convertArrowToSchema(intermediate.schema)), query.limit, signal);
|
|
86
|
+
return checked && { ...checked, project };
|
|
87
|
+
}
|
|
88
|
+
/** Uses effective source capabilities as a ceiling before asking for exact query acceptance. */
|
|
89
|
+
function canPushdownQuery(query, capabilities, computed) {
|
|
90
|
+
if (!capabilities)
|
|
91
|
+
return false;
|
|
92
|
+
const supports = (support) => support === 'pushdown' || support === 'pushdown+residual';
|
|
93
|
+
return ((!query.select || supports(capabilities.projection)) &&
|
|
94
|
+
(!query.where || supports(capabilities.predicate)) &&
|
|
95
|
+
(!computed || !containsNonCastExpression(query) || supports(capabilities.expressions)) &&
|
|
96
|
+
(!containsQueryCast(query) || supports(capabilities.cast)) &&
|
|
97
|
+
(query.offset === undefined || supports(capabilities.offset)) &&
|
|
98
|
+
(query.limit === undefined || supports(capabilities.limit)));
|
|
99
|
+
}
|
|
100
|
+
/** Recognizes both parsed expression CAST calls and portable predicate cast annotations. */
|
|
101
|
+
function containsQueryCast(value) {
|
|
102
|
+
if (!value || typeof value !== 'object')
|
|
103
|
+
return false;
|
|
104
|
+
if (Array.isArray(value))
|
|
105
|
+
return value.some(containsQueryCast);
|
|
106
|
+
const node = value;
|
|
107
|
+
if (Array.isArray(node.casts) && node.casts.length)
|
|
108
|
+
return true;
|
|
109
|
+
if (node.type === 'CallExpression' &&
|
|
110
|
+
node.callee &&
|
|
111
|
+
typeof node.callee === 'object' &&
|
|
112
|
+
'name' in node.callee &&
|
|
113
|
+
String(node.callee.name).toLowerCase() === 'cast')
|
|
114
|
+
return true;
|
|
115
|
+
return Object.values(node).some(containsQueryCast);
|
|
116
|
+
}
|
|
117
|
+
/** CAST-only expressions use the independent cast capability; other computation needs expressions. */
|
|
118
|
+
function containsNonCastExpression(value) {
|
|
119
|
+
if (!value || typeof value !== 'object')
|
|
120
|
+
return false;
|
|
121
|
+
if (Array.isArray(value))
|
|
122
|
+
return value.some(containsNonCastExpression);
|
|
123
|
+
const node = value;
|
|
124
|
+
if (Array.isArray(node.array))
|
|
125
|
+
return true;
|
|
126
|
+
if (typeof node.type === 'string' && !['Identifier', 'Literal'].includes(node.type)) {
|
|
127
|
+
if (node.type !== 'CallExpression' ||
|
|
128
|
+
!node.callee ||
|
|
129
|
+
typeof node.callee !== 'object' ||
|
|
130
|
+
!('name' in node.callee) ||
|
|
131
|
+
String(node.callee.name).toLowerCase() !== 'cast')
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return Object.values(node).some(containsNonCastExpression);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=query-pushdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-pushdown.js","sourceRoot":"","sources":["../../src/scan/query-pushdown.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,KAAK,EAAE,IAAI,EAAc,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,+BAA+B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
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/scan/query.ts
|
|
31
|
+
var query_exports = {};
|
|
32
|
+
__export(query_exports, {
|
|
33
|
+
createSQLCatalog: () => import_sql_catalog.createSQLCatalog,
|
|
34
|
+
parseSQLQuery: () => import_sql.parseSQLQuery,
|
|
35
|
+
parseSQLSelect: () => import_sql.parseSQLSelect,
|
|
36
|
+
query: () => query,
|
|
37
|
+
queryInBatches: () => queryInBatches,
|
|
38
|
+
queryProgressive: () => queryProgressive
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(query_exports);
|
|
41
|
+
var arrow = __toESM(require("apache-arrow"), 1);
|
|
42
|
+
var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
43
|
+
var import_schema_utils = require("@loaders.gl/core/schema-utils");
|
|
44
|
+
var import_arrow_execution = require("./arrow-execution.cjs");
|
|
45
|
+
var import_filter_arrow_table = require("./arrow-execution/filter-arrow-table.cjs");
|
|
46
|
+
var import_sql = require("@math.gl/expressions/sql");
|
|
47
|
+
var import_sql_catalog = require("./sql-catalog.cjs");
|
|
48
|
+
async function query(tableQuery, options) {
|
|
49
|
+
return await (0, import_schema_utils.makeArrowTableFromBatches)(
|
|
50
|
+
queryInBatches(tableQuery, { ...options, queryOutput: "batches" })
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
async function* queryInBatches(tableQuery, options) {
|
|
54
|
+
if (options.queryOutput === "snapshots") {
|
|
55
|
+
if (!tableQuery || typeof tableQuery !== "object" || !("aggregates" in tableQuery) || !Array.isArray(tableQuery.aggregates)) {
|
|
56
|
+
throw new Error("Snapshots require a structured aggregate query.");
|
|
57
|
+
}
|
|
58
|
+
for await (const snapshot of queryProgressive(tableQuery, options)) {
|
|
59
|
+
yield* snapshot.table.batches;
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (options.queryOutput !== void 0 && options.queryOutput !== "batches") {
|
|
64
|
+
throw new Error("Unsupported queryOutput.");
|
|
65
|
+
}
|
|
66
|
+
if (typeof tableQuery === "object" && tableQuery && "aggregates" in tableQuery) {
|
|
67
|
+
throw new Error("Aggregates require snapshots.");
|
|
68
|
+
}
|
|
69
|
+
for await (const batch of queryAppendBatches(tableQuery, options)) {
|
|
70
|
+
if (batch.data.batches.length) yield* batch.data.batches;
|
|
71
|
+
else yield (0, import_schema_utils.makeArrowMetadataBatch)(batch.data.schema);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function* queryProgressive(query2, options) {
|
|
75
|
+
const { executeProgressiveQuery } = await import("./query-progressive.cjs");
|
|
76
|
+
yield* executeProgressiveQuery(query2, options);
|
|
77
|
+
}
|
|
78
|
+
async function* queryAppendBatches(tableQuery, options) {
|
|
79
|
+
const startedAt = Date.now();
|
|
80
|
+
let status = "early-terminated";
|
|
81
|
+
let rowsRead = 0;
|
|
82
|
+
let rowsReturned = 0;
|
|
83
|
+
let batchesRead = 0;
|
|
84
|
+
let sourcesRead = 0;
|
|
85
|
+
let error;
|
|
86
|
+
let ownedSource;
|
|
87
|
+
let earlyTerminationReason;
|
|
88
|
+
try {
|
|
89
|
+
options.signal?.throwIfAborted();
|
|
90
|
+
let parsedQuery;
|
|
91
|
+
if (typeof tableQuery === "string") {
|
|
92
|
+
const parser = await options.sqlParser;
|
|
93
|
+
options.signal?.throwIfAborted();
|
|
94
|
+
if (typeof parser !== "function") throw new Error("SQL queries require sqlParser.");
|
|
95
|
+
parsedQuery = await parser(tableQuery);
|
|
96
|
+
options.signal?.throwIfAborted();
|
|
97
|
+
} else parsedQuery = tableQuery;
|
|
98
|
+
if (!parsedQuery || typeof parsedQuery !== "object" || Array.isArray(parsedQuery))
|
|
99
|
+
throw new Error("Table query must be an object.");
|
|
100
|
+
const normalizedQuery = await normalizeTypedQuery(parsedQuery);
|
|
101
|
+
const castPredicate = "command" in normalizedQuery ? false : validatePredicateOperands(normalizedQuery.where);
|
|
102
|
+
let logicalQuery;
|
|
103
|
+
let source;
|
|
104
|
+
if ("command" in parsedQuery) {
|
|
105
|
+
logicalQuery = {};
|
|
106
|
+
source = (await import("./catalog-query-source.cjs")).createCatalogQuerySource(
|
|
107
|
+
parsedQuery,
|
|
108
|
+
options.sources
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
logicalQuery = normalizedQuery;
|
|
112
|
+
source = logicalQuery.from === void 0 ? options.source : await (await import("./resolve-query-source.cjs")).resolveQuerySource(
|
|
113
|
+
logicalQuery.from,
|
|
114
|
+
options.sources,
|
|
115
|
+
options.signal
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
if (logicalQuery.from === void 0 && typeof source === "string") {
|
|
119
|
+
const opened = await (await import("./query-open-source.cjs")).openQuerySource(options);
|
|
120
|
+
if (opened && typeof opened === "object" && "close" in opened && typeof opened.close === "function")
|
|
121
|
+
ownedSource = opened;
|
|
122
|
+
source = opened;
|
|
123
|
+
}
|
|
124
|
+
options.signal?.throwIfAborted();
|
|
125
|
+
if (!source || typeof source !== "object")
|
|
126
|
+
throw new Error("Expected an Arrow table or table scan source.");
|
|
127
|
+
const inMemory = "batches" in source ? source : "shape" in source && source.shape === "arrow-table" ? source.data : null;
|
|
128
|
+
if (!inMemory && (!("read" in source) || typeof source.read !== "function" || !("getQueryMetadata" in source) || typeof source.getQueryMetadata !== "function")) {
|
|
129
|
+
throw new Error("Expected an Arrow table or table scan source.");
|
|
130
|
+
}
|
|
131
|
+
const metadata = inMemory ? void 0 : await source.getQueryMetadata({ signal: options.signal });
|
|
132
|
+
options.signal?.throwIfAborted();
|
|
133
|
+
if (metadata && (metadata.queryType !== "table" || metadata.execution.status !== "supported" || metadata.execution.method !== "read")) {
|
|
134
|
+
throw new Error("Query source must support table reads.");
|
|
135
|
+
}
|
|
136
|
+
const sourceSchema = inMemory ? inMemory.schema : (0, import_schema_utils.convertSchemaToArrow)(metadata.schema);
|
|
137
|
+
const names = sourceSchema.fields.map((field) => field.name);
|
|
138
|
+
const { select, where, ...controls } = logicalQuery;
|
|
139
|
+
const computedProjection = Array.isArray(select) && select.some(
|
|
140
|
+
(selection) => selection && typeof selection === "object" && ("expression" in selection || "array" in selection)
|
|
141
|
+
);
|
|
142
|
+
const expressionFilter = where && typeof where === "object" && "expression" in where ? where : void 0;
|
|
143
|
+
const portablePredicate = expressionFilter ? void 0 : where;
|
|
144
|
+
const normalized = (0, import_loader_utils.normalizeTableQuery)(names, {
|
|
145
|
+
...controls,
|
|
146
|
+
select: computedProjection ? void 0 : select,
|
|
147
|
+
where: castPredicate ? void 0 : portablePredicate
|
|
148
|
+
});
|
|
149
|
+
const expressionTools = computedProjection || expressionFilter || castPredicate ? await import("./arrow-execution/expressions.cjs") : void 0;
|
|
150
|
+
const outputColumns = computedProjection ? expressionTools.getProjectionColumns(select) : normalized.select.map((selection) => selection.column);
|
|
151
|
+
const expressionColumns = expressionFilter ? expressionTools.getExpressionColumns(expressionFilter.expression) : castPredicate && portablePredicate ? (0, import_loader_utils.getColumnarPredicateColumns)(portablePredicate) : [];
|
|
152
|
+
const required = [.../* @__PURE__ */ new Set([...outputColumns, ...expressionColumns])];
|
|
153
|
+
const plan = (0, import_loader_utils.planTableQuery)(names, {
|
|
154
|
+
// A literal-only projection still needs a physical column to retain row counts.
|
|
155
|
+
columns: required.length ? required : names.slice(0, 1),
|
|
156
|
+
predicate: normalized.where
|
|
157
|
+
});
|
|
158
|
+
const requiredColumns = plan[0].kind === "scan" ? plan[0].columns : names;
|
|
159
|
+
const capabilities = (metadata?.queryCapabilities ?? metadata?.capabilities)?.table;
|
|
160
|
+
const delegatePredicate = Boolean(
|
|
161
|
+
normalized.where && capabilities && ["pushdown", "pushdown+residual"].includes(capabilities.predicate)
|
|
162
|
+
);
|
|
163
|
+
const residual = delegatePredicate ? void 0 : normalized.where;
|
|
164
|
+
const canDelegateWindow = !residual && !expressionFilter && !castPredicate;
|
|
165
|
+
const delegateOffset = Boolean(
|
|
166
|
+
canDelegateWindow && normalized.offset !== void 0 && capabilities && ["pushdown", "pushdown+residual"].includes(capabilities.offset ?? "unsupported")
|
|
167
|
+
);
|
|
168
|
+
const requestedRows = normalized.limit === void 0 ? void 0 : (delegateOffset ? 0 : normalized.offset ?? 0) + normalized.limit;
|
|
169
|
+
const readOptions = {
|
|
170
|
+
signal: options.signal,
|
|
171
|
+
...capabilities && capabilities.projection !== "unsupported" ? { columns: requiredColumns } : {},
|
|
172
|
+
...delegatePredicate ? { predicate: normalized.where } : {},
|
|
173
|
+
...delegateOffset ? { offset: normalized.offset } : {},
|
|
174
|
+
...canDelegateWindow && requestedRows !== void 0 && Number.isSafeInteger(requestedRows) && capabilities && ["pushdown", "pushdown+residual"].includes(capabilities.limit) ? { limit: requestedRows } : {}
|
|
175
|
+
};
|
|
176
|
+
const inputSchema = readOptions.columns ? sourceSchema.select([...readOptions.columns]) : sourceSchema;
|
|
177
|
+
const readSchema = (0, import_schema_utils.convertArrowToSchema)(inputSchema);
|
|
178
|
+
const comparisonInputSchema = expressionTools ? (0, import_schema_utils.convertSchemaToArrow)(readSchema) : void 0;
|
|
179
|
+
const compiledFilter = expressionFilter ? expressionTools.compileArrowExpression(expressionFilter.expression, { inputSchema }) : castPredicate && portablePredicate ? expressionTools.compileArrowPredicate(portablePredicate, { inputSchema }) : void 0;
|
|
180
|
+
if (compiledFilter && !arrow.DataType.isBool(compiledFilter.outputField.type))
|
|
181
|
+
throw new Error("SQL WHERE expression must return Boolean.");
|
|
182
|
+
const project = computedProjection ? expressionTools.compileArrowProjection(inputSchema, select, options.signal) : (data) => (0, import_arrow_execution.projectArrowTable)(data, normalized.select);
|
|
183
|
+
const empty = project(new arrow.Table(inputSchema));
|
|
184
|
+
const comparisonSchema = (0, import_schema_utils.convertSchemaToArrow)((0, import_schema_utils.convertArrowToSchema)(empty.schema));
|
|
185
|
+
const pushedPlan = !inMemory && !("command" in parsedQuery) && source.planQueryPushdown ? await (await import("./query-pushdown.cjs")).planQueryPushdown(
|
|
186
|
+
source,
|
|
187
|
+
logicalQuery,
|
|
188
|
+
capabilities,
|
|
189
|
+
comparisonSchema,
|
|
190
|
+
Boolean(computedProjection || expressionFilter),
|
|
191
|
+
inputSchema,
|
|
192
|
+
options.signal
|
|
193
|
+
) : null;
|
|
194
|
+
options.signal?.throwIfAborted();
|
|
195
|
+
let emitted = false;
|
|
196
|
+
async function* inputs() {
|
|
197
|
+
sourcesRead = 1;
|
|
198
|
+
const batches = pushedPlan ? pushedPlan.read({ signal: options.signal }) : inMemory ? memoryBatches(inMemory) : source.read(readOptions);
|
|
199
|
+
for await (const value of batches) {
|
|
200
|
+
options.signal?.throwIfAborted();
|
|
201
|
+
let batch = normalizeBatch(value, pushedPlan?.schema ?? readSchema);
|
|
202
|
+
if (!pushedPlan && comparisonInputSchema && !arrow.util.compareSchemas(comparisonInputSchema, (0, import_schema_utils.convertSchemaToArrow)(batch.schema))) {
|
|
203
|
+
const data = batch.data.select(inputSchema.names);
|
|
204
|
+
batch = { ...batch, ...wrapBatch(data) };
|
|
205
|
+
if (!arrow.util.compareSchemas(comparisonInputSchema, (0, import_schema_utils.convertSchemaToArrow)(batch.schema)))
|
|
206
|
+
throw new Error("Query input schema does not match source metadata.");
|
|
207
|
+
}
|
|
208
|
+
batchesRead++;
|
|
209
|
+
rowsRead += batch.length;
|
|
210
|
+
yield batch;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for await (const value of (0, import_loader_utils.executeTableScanBatches)(
|
|
214
|
+
() => inputs(),
|
|
215
|
+
{
|
|
216
|
+
predicate: pushedPlan ? void 0 : residual,
|
|
217
|
+
offset: pushedPlan || delegateOffset ? void 0 : normalized.offset,
|
|
218
|
+
limit: normalized.limit,
|
|
219
|
+
skipEmptyBatches: true,
|
|
220
|
+
signal: options.signal
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
filter: (batch, predicate, signal) => {
|
|
224
|
+
if (pushedPlan) return batch;
|
|
225
|
+
const input = batch;
|
|
226
|
+
const data = compiledFilter ? (0, import_filter_arrow_table.filterArrowRows)(
|
|
227
|
+
input.data,
|
|
228
|
+
(batch2) => {
|
|
229
|
+
const matches = compiledFilter.evaluate(batch2, { signal });
|
|
230
|
+
return (index) => matches.get(index) === true;
|
|
231
|
+
},
|
|
232
|
+
{ signal }
|
|
233
|
+
) : predicate ? (0, import_arrow_execution.filterArrowTable)(input.data, predicate, { signal }) : input.data;
|
|
234
|
+
return { ...input, ...wrapBatch(data) };
|
|
235
|
+
},
|
|
236
|
+
project: (batch) => {
|
|
237
|
+
const input = batch;
|
|
238
|
+
return pushedPlan || computedProjection ? input : { ...input, ...wrapBatch(project(input.data)) };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
)) {
|
|
242
|
+
const input = value;
|
|
243
|
+
const finishProjection = pushedPlan ? pushedPlan.project : computedProjection ? project : void 0;
|
|
244
|
+
const batch = finishProjection ? { ...input, ...wrapBatch(finishProjection(input.data)) } : input;
|
|
245
|
+
if (!arrow.util.compareSchemas(comparisonSchema, (0, import_schema_utils.convertSchemaToArrow)(batch.schema)))
|
|
246
|
+
throw new Error("Query output schema does not match source metadata.");
|
|
247
|
+
emitted = true;
|
|
248
|
+
rowsReturned += batch.length;
|
|
249
|
+
yield batch;
|
|
250
|
+
}
|
|
251
|
+
if (!emitted) yield wrapBatch(empty);
|
|
252
|
+
if (normalized.limit !== void 0 && rowsReturned >= normalized.limit)
|
|
253
|
+
earlyTerminationReason = "limit";
|
|
254
|
+
status = earlyTerminationReason ? "early-terminated" : "completed";
|
|
255
|
+
} catch (failure) {
|
|
256
|
+
error = failure;
|
|
257
|
+
status = options.signal?.aborted ? "cancelled" : "failed";
|
|
258
|
+
throw failure;
|
|
259
|
+
} finally {
|
|
260
|
+
if (status === "early-terminated" && !earlyTerminationReason)
|
|
261
|
+
earlyTerminationReason = "consumer-return";
|
|
262
|
+
try {
|
|
263
|
+
await ownedSource?.close?.();
|
|
264
|
+
} catch (failure) {
|
|
265
|
+
if (error === void 0) {
|
|
266
|
+
error = failure;
|
|
267
|
+
status = options.signal?.aborted ? "cancelled" : "failed";
|
|
268
|
+
earlyTerminationReason = void 0;
|
|
269
|
+
throw failure;
|
|
270
|
+
}
|
|
271
|
+
} finally {
|
|
272
|
+
(0, import_loader_utils.emitQueryComplete)(
|
|
273
|
+
options.onQueryComplete,
|
|
274
|
+
Object.freeze({
|
|
275
|
+
status,
|
|
276
|
+
sourcesPlanned: 1,
|
|
277
|
+
sourcesRead,
|
|
278
|
+
batchesRead,
|
|
279
|
+
rowsRead,
|
|
280
|
+
rowsReturned,
|
|
281
|
+
durationMilliseconds: Date.now() - startedAt,
|
|
282
|
+
...earlyTerminationReason ? { earlyTerminationReason } : {},
|
|
283
|
+
...error === void 0 ? {} : { error }
|
|
284
|
+
})
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async function normalizeTypedQuery(query2) {
|
|
290
|
+
if ("command" in query2 || !Array.isArray(query2.select) || !query2.select.some((item) => item && typeof item === "object" && "cast" in item)) {
|
|
291
|
+
return query2;
|
|
292
|
+
}
|
|
293
|
+
return (await import("./arrow-execution/expressions.cjs")).normalizeTypedProjection(query2);
|
|
294
|
+
}
|
|
295
|
+
async function* memoryBatches(data) {
|
|
296
|
+
for (const batch of data.batches) yield wrapBatch(new arrow.Table(data.schema, [batch]));
|
|
297
|
+
}
|
|
298
|
+
function normalizeBatch(value, fallbackSchema) {
|
|
299
|
+
if (!value || typeof value !== "object") throw new Error("Unsupported query batch.");
|
|
300
|
+
if ("numRows" in value) {
|
|
301
|
+
const batch2 = value;
|
|
302
|
+
return wrapBatch(new arrow.Table(batch2.schema, [batch2]));
|
|
303
|
+
}
|
|
304
|
+
if (!("shape" in value)) throw new Error("Unsupported query batch.");
|
|
305
|
+
const input = value;
|
|
306
|
+
const batch = { ...input, schema: input.schema ?? fallbackSchema };
|
|
307
|
+
if (!["arrow-table", "object-row-table", "array-row-table", "columnar-table"].includes(batch.shape))
|
|
308
|
+
throw new Error(`Unsupported query batch shape: ${batch.shape}`);
|
|
309
|
+
const data = batch.length === 0 && batch.schema ? new arrow.Table((0, import_schema_utils.convertSchemaToArrow)(batch.schema)) : (0, import_schema_utils.convertTableToArrow)(batch);
|
|
310
|
+
return { ...batch, ...wrapBatch(data) };
|
|
311
|
+
}
|
|
312
|
+
function wrapBatch(data) {
|
|
313
|
+
return {
|
|
314
|
+
shape: "arrow-table",
|
|
315
|
+
data,
|
|
316
|
+
schema: (0, import_schema_utils.convertArrowToSchema)(data.schema),
|
|
317
|
+
batchType: "data",
|
|
318
|
+
length: data.numRows
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function validatePredicateOperands(where) {
|
|
322
|
+
if (where && typeof where === "object" && "expression" in where) {
|
|
323
|
+
if (Object.keys(where).some((key) => key !== "expression"))
|
|
324
|
+
throw new Error("Unsupported computed WHERE field.");
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
let castPredicate = false;
|
|
328
|
+
const pending = where ? [{ value: where }] : [];
|
|
329
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
330
|
+
let nodes = 0;
|
|
331
|
+
while (pending.length) {
|
|
332
|
+
const frame = pending.pop();
|
|
333
|
+
const candidate = frame.value;
|
|
334
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) continue;
|
|
335
|
+
if (frame.exit) {
|
|
336
|
+
visited.delete(candidate);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (visited.has(candidate) || ++nodes > 4096)
|
|
340
|
+
throw new Error("Query predicate must be an acyclic tree of at most 4096 nodes.");
|
|
341
|
+
visited.add(candidate);
|
|
342
|
+
if (isUnsupportedQueryExpression(candidate))
|
|
343
|
+
throw new Error("CAST and computed WHERE operands are not supported by this query executor.");
|
|
344
|
+
const predicate = candidate;
|
|
345
|
+
if (!Array.isArray(predicate.args)) continue;
|
|
346
|
+
if (predicate.op === "and" || predicate.op === "or" || predicate.op === "not") {
|
|
347
|
+
if (predicate.args.length > 4096 - nodes)
|
|
348
|
+
throw new Error("Query predicate exceeds 4096 nodes.");
|
|
349
|
+
pending.push({ value: candidate, exit: true });
|
|
350
|
+
pending.push(...predicate.args.map((value) => ({ value })));
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
visited.delete(candidate);
|
|
354
|
+
for (const [index, operand] of predicate.args.entries()) {
|
|
355
|
+
if (index === 0 && operand && typeof operand === "object" && typeof operand.property === "string" && "casts" in operand) {
|
|
356
|
+
castPredicate = true;
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
if (isUnsupportedQueryExpression(operand) || Array.isArray(operand) && operand.some(isUnsupportedQueryExpression))
|
|
360
|
+
throw new Error(
|
|
361
|
+
"CAST and computed WHERE operands are not supported by this query executor."
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
return castPredicate;
|
|
366
|
+
}
|
|
367
|
+
function isUnsupportedQueryExpression(value) {
|
|
368
|
+
if (!value || typeof value !== "object") return false;
|
|
369
|
+
if ("casts" in value || "expression" in value) return true;
|
|
370
|
+
return "type" in value && typeof value.type === "string" && /Expression$|^(Identifier|Literal|Compound)$/.test(value.type);
|
|
371
|
+
}
|
|
372
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
373
|
+
0 && (module.exports = {
|
|
374
|
+
createSQLCatalog,
|
|
375
|
+
parseSQLQuery,
|
|
376
|
+
parseSQLSelect,
|
|
377
|
+
query,
|
|
378
|
+
queryInBatches,
|
|
379
|
+
queryProgressive
|
|
380
|
+
});
|
|
381
|
+
//# sourceMappingURL=query.cjs.map
|