@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,2447 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
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
|
+
// dist/federated-table-scan-source.js
|
|
31
|
+
var federated_table_scan_source_exports = {};
|
|
32
|
+
__export(federated_table_scan_source_exports, {
|
|
33
|
+
FEDERATED_TABLE_QUERY_CAPABILITIES: () => FEDERATED_TABLE_QUERY_CAPABILITIES,
|
|
34
|
+
FederatedTableScanSource: () => FederatedTableScanSource,
|
|
35
|
+
getFederatedTableBatchProvenance: () => getFederatedTableBatchProvenance
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(federated_table_scan_source_exports);
|
|
38
|
+
|
|
39
|
+
// dist/scan/federated-table-scan-source.js
|
|
40
|
+
var arrow8 = __toESM(require("apache-arrow"), 1);
|
|
41
|
+
|
|
42
|
+
// src/loader-utils/lib/scan-utils/columnar-predicate.ts
|
|
43
|
+
function getColumnarPredicateColumns(predicate) {
|
|
44
|
+
return [...new Set(getColumnarPredicatePaths(predicate).map((path) => path[0]))];
|
|
45
|
+
}
|
|
46
|
+
function getColumnarPredicatePath(property) {
|
|
47
|
+
return typeof property.property === "string" ? [property.property] : [...property.property];
|
|
48
|
+
}
|
|
49
|
+
function getColumnarPredicatePaths(predicate) {
|
|
50
|
+
const paths = /* @__PURE__ */ new Map();
|
|
51
|
+
visitColumnarPredicate(predicate, (child) => {
|
|
52
|
+
if ("property" in child.args[0]) {
|
|
53
|
+
const path = getColumnarPredicatePath(child.args[0]);
|
|
54
|
+
paths.set(path.join("\0"), path);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return [...paths.values()];
|
|
58
|
+
}
|
|
59
|
+
function validateColumnarPredicate(predicate, availableColumns) {
|
|
60
|
+
visitColumnarPredicate(predicate, (child) => {
|
|
61
|
+
if (child.op === "and" || child.op === "or") {
|
|
62
|
+
if (child.args.length < 2)
|
|
63
|
+
throw new Error(`Columnar predicate ${child.op} requires at least two child predicates`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (child.op === "not") return;
|
|
67
|
+
const leaf = child;
|
|
68
|
+
const path = getColumnarPredicatePath(leaf.args[0]);
|
|
69
|
+
if (!path.length || path.some((component) => !component)) {
|
|
70
|
+
throw new Error("Columnar predicate property path must contain non-empty strings");
|
|
71
|
+
}
|
|
72
|
+
if (!availableColumns.has(path[0]))
|
|
73
|
+
throw new Error(`Columnar predicate column not found: ${path.join(".")}`);
|
|
74
|
+
if (leaf.op === "in" && leaf.args[1].length === 0) {
|
|
75
|
+
throw new Error("Columnar predicate in requires at least one value");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function isColumnarPredicateParameter(value) {
|
|
80
|
+
const parameterValue = value;
|
|
81
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && Object.hasOwn(value, "parameter") && typeof parameterValue.parameter === "string" && parameterValue.parameter.length > 0;
|
|
82
|
+
}
|
|
83
|
+
function visitColumnarPredicate(predicate, visitor) {
|
|
84
|
+
visitor(predicate);
|
|
85
|
+
if (predicate.op === "and" || predicate.op === "or")
|
|
86
|
+
predicate.args.forEach((child) => visitColumnarPredicate(child, visitor));
|
|
87
|
+
else if (predicate.op === "not") visitColumnarPredicate(predicate.args[0], visitor);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/loader-utils/lib/scan-utils/scan-query-metadata.ts
|
|
91
|
+
var import_crs = require("@math.gl/geospatial/crs");
|
|
92
|
+
function emitQueryComplete(callback, summary) {
|
|
93
|
+
if (!callback) return;
|
|
94
|
+
try {
|
|
95
|
+
callback(summary);
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function createScanQueryMetadata(options) {
|
|
100
|
+
validateScanExecutionSupport(options.queryType, options.execution);
|
|
101
|
+
const schema = Object.freeze({
|
|
102
|
+
fields: Object.freeze(
|
|
103
|
+
options.schema.fields.map(
|
|
104
|
+
(field) => Object.freeze({ ...field, metadata: Object.freeze({ ...field.metadata }) })
|
|
105
|
+
)
|
|
106
|
+
),
|
|
107
|
+
metadata: Object.freeze({ ...options.schema.metadata })
|
|
108
|
+
});
|
|
109
|
+
const columns = schema.fields.map(
|
|
110
|
+
(field) => {
|
|
111
|
+
var _a;
|
|
112
|
+
return Object.freeze({
|
|
113
|
+
name: field.name,
|
|
114
|
+
type: field.type,
|
|
115
|
+
nullable: field.nullable !== false,
|
|
116
|
+
role: ((_a = options.columnRoles) == null ? void 0 : _a[field.name]) || "attribute",
|
|
117
|
+
title: getNonEmptyMetadataValue(field.metadata, "title"),
|
|
118
|
+
description: getNonEmptyMetadataValue(field.metadata, "description"),
|
|
119
|
+
metadata: field.metadata || Object.freeze({})
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
const queryCapabilities = Object.freeze({ ...options.capabilities });
|
|
124
|
+
return Object.freeze({
|
|
125
|
+
sourceType: options.sourceType,
|
|
126
|
+
queryType: options.queryType,
|
|
127
|
+
execution: Object.freeze({ ...options.execution }),
|
|
128
|
+
name: options.name,
|
|
129
|
+
description: options.description,
|
|
130
|
+
schema,
|
|
131
|
+
columns: Object.freeze(columns),
|
|
132
|
+
capabilities: queryCapabilities,
|
|
133
|
+
queryCapabilities,
|
|
134
|
+
spatial: options.spatial ? Object.freeze({
|
|
135
|
+
...options.spatial,
|
|
136
|
+
bounds: options.spatial.bounds ? Object.freeze({
|
|
137
|
+
minimum: Object.freeze([...options.spatial.bounds.minimum]),
|
|
138
|
+
maximum: Object.freeze([...options.spatial.bounds.maximum])
|
|
139
|
+
}) : void 0,
|
|
140
|
+
coordinateReferenceSystems: options.spatial.coordinateReferenceSystems ? Object.freeze([...options.spatial.coordinateReferenceSystems]) : void 0,
|
|
141
|
+
spatialReference: options.spatial.spatialReference ? (0, import_crs.createSpatialReference)(options.spatial.spatialReference) : void 0
|
|
142
|
+
}) : void 0,
|
|
143
|
+
statistics: options.statistics ? Object.freeze({ ...options.statistics }) : void 0,
|
|
144
|
+
levels: options.levels ? Object.freeze(
|
|
145
|
+
options.levels.map(
|
|
146
|
+
(level) => Object.freeze({
|
|
147
|
+
...level,
|
|
148
|
+
scale: level.scale ? Object.freeze([...level.scale]) : void 0
|
|
149
|
+
})
|
|
150
|
+
)
|
|
151
|
+
) : void 0
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function validateScanExecutionSupport(queryType, execution) {
|
|
155
|
+
if (execution.status === "metadata-only") {
|
|
156
|
+
if (!execution.reason.trim()) {
|
|
157
|
+
throw new Error("Metadata-only scan support requires a concrete reason");
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const validMethods = {
|
|
162
|
+
table: ["read", "query"],
|
|
163
|
+
raster: ["getRaster"],
|
|
164
|
+
"point-cloud": ["scan"]
|
|
165
|
+
};
|
|
166
|
+
if (!validMethods[queryType].includes(execution.method)) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`Scan execution method "${execution.method}" is not valid for ${queryType} queries`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function getNonEmptyMetadataValue(metadata, key) {
|
|
173
|
+
const value = metadata == null ? void 0 : metadata[key];
|
|
174
|
+
return value || void 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/loader-utils/lib/scan-utils/table-query.ts
|
|
178
|
+
function planTableQuery(sourceColumnNames, options = {}) {
|
|
179
|
+
validateTableQueryOptions(sourceColumnNames, options);
|
|
180
|
+
const outputColumnNames = options.columns ? [...options.columns] : [...sourceColumnNames];
|
|
181
|
+
const predicateColumnNames = options.predicate ? getColumnarPredicateColumns(options.predicate) : [];
|
|
182
|
+
const requiredColumnNames = /* @__PURE__ */ new Set([...outputColumnNames, ...predicateColumnNames]);
|
|
183
|
+
const scanColumnNames = sourceColumnNames.filter(
|
|
184
|
+
(columnName) => requiredColumnNames.has(columnName)
|
|
185
|
+
);
|
|
186
|
+
const steps = [
|
|
187
|
+
Object.freeze({ kind: "scan", columns: Object.freeze(scanColumnNames) })
|
|
188
|
+
];
|
|
189
|
+
if (options.predicate) {
|
|
190
|
+
steps.push(Object.freeze({ kind: "filter", predicate: options.predicate }));
|
|
191
|
+
}
|
|
192
|
+
steps.push(Object.freeze({ kind: "project", columns: Object.freeze(outputColumnNames) }));
|
|
193
|
+
if (options.limit !== void 0) {
|
|
194
|
+
steps.push(Object.freeze({ kind: "limit", limit: options.limit }));
|
|
195
|
+
}
|
|
196
|
+
return Object.freeze(steps);
|
|
197
|
+
}
|
|
198
|
+
function validateTableQueryOptions(sourceColumnNames, options) {
|
|
199
|
+
const availableColumnNames = new Set(sourceColumnNames);
|
|
200
|
+
const outputColumnNames = options.columns ?? sourceColumnNames;
|
|
201
|
+
const seenColumnNames = /* @__PURE__ */ new Set();
|
|
202
|
+
for (const columnName of outputColumnNames) {
|
|
203
|
+
if (!availableColumnNames.has(columnName)) {
|
|
204
|
+
throw new Error(`Table query column not found: ${columnName}`);
|
|
205
|
+
}
|
|
206
|
+
if (seenColumnNames.has(columnName)) {
|
|
207
|
+
throw new Error(`Table query column was selected more than once: ${columnName}`);
|
|
208
|
+
}
|
|
209
|
+
seenColumnNames.add(columnName);
|
|
210
|
+
}
|
|
211
|
+
validateTableQueryLimit(options.limit);
|
|
212
|
+
if (options.predicate) {
|
|
213
|
+
validateColumnarPredicate(options.predicate, availableColumnNames);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function validateTableQueryLimit(limit) {
|
|
217
|
+
if (limit !== void 0 && (!Number.isSafeInteger(limit) || limit < 0)) {
|
|
218
|
+
throw new Error("Table query limit must be a non-negative safe integer.");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/loader-utils/lib/scan-utils/table-scan-batch.ts
|
|
223
|
+
function makeTableScanBatch(table) {
|
|
224
|
+
return { ...table, batchType: "data", length: table.data.numRows };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/loader-utils/lib/scan-utils/relational-query.ts
|
|
228
|
+
function planRelationalQuery(sourceColumnNames, options = {}) {
|
|
229
|
+
var _a, _b, _c, _d, _e, _f;
|
|
230
|
+
const available = new Set(sourceColumnNames);
|
|
231
|
+
const expressionNames = /* @__PURE__ */ new Set();
|
|
232
|
+
for (const expression of options.expressions || []) {
|
|
233
|
+
if (!expression.name) throw new Error("Relational expression names must be non-empty.");
|
|
234
|
+
if (available.has(expression.name) || expressionNames.has(expression.name)) {
|
|
235
|
+
throw new Error(`Relational expression duplicates column: ${expression.name}`);
|
|
236
|
+
}
|
|
237
|
+
expressionNames.add(expression.name);
|
|
238
|
+
}
|
|
239
|
+
const aggregateNames = new Set((options.aggregates || []).map((aggregate) => aggregate.name));
|
|
240
|
+
const requiredColumns = /* @__PURE__ */ new Set();
|
|
241
|
+
const availableColumns = new Set(sourceColumnNames);
|
|
242
|
+
for (const expression of options.expressions || []) {
|
|
243
|
+
const definition = expression.expression;
|
|
244
|
+
if (definition.op === "column") {
|
|
245
|
+
validateRelationalColumnReference(definition.column, availableColumns);
|
|
246
|
+
if (available.has(definition.column)) requiredColumns.add(definition.column);
|
|
247
|
+
}
|
|
248
|
+
if ("left" in definition) {
|
|
249
|
+
validateRelationalColumnReference(definition.left, availableColumns);
|
|
250
|
+
validateRelationalColumnReference(definition.right, availableColumns);
|
|
251
|
+
if (available.has(definition.left)) requiredColumns.add(definition.left);
|
|
252
|
+
if (available.has(definition.right)) requiredColumns.add(definition.right);
|
|
253
|
+
}
|
|
254
|
+
availableColumns.add(expression.name);
|
|
255
|
+
}
|
|
256
|
+
for (const key of options.orderBy || []) requiredColumns.add(key.column);
|
|
257
|
+
for (const key of options.groupBy || []) requiredColumns.add(key);
|
|
258
|
+
for (const aggregate of options.aggregates || []) {
|
|
259
|
+
if (aggregate.column) requiredColumns.add(aggregate.column);
|
|
260
|
+
}
|
|
261
|
+
const outputColumns = (_a = options.columns) == null ? void 0 : _a.filter(
|
|
262
|
+
(column) => !expressionNames.has(column) && !aggregateNames.has(column)
|
|
263
|
+
);
|
|
264
|
+
const tablePlan = [
|
|
265
|
+
...planTableQuery(sourceColumnNames, {
|
|
266
|
+
...options,
|
|
267
|
+
columns: outputColumns,
|
|
268
|
+
predicate: options.predicate
|
|
269
|
+
})
|
|
270
|
+
];
|
|
271
|
+
const scanStep = tablePlan[0];
|
|
272
|
+
if ((scanStep == null ? void 0 : scanStep.kind) === "scan") {
|
|
273
|
+
const scanColumns = new Set(scanStep.columns);
|
|
274
|
+
for (const column of requiredColumns) {
|
|
275
|
+
if (available.has(column)) scanColumns.add(column);
|
|
276
|
+
}
|
|
277
|
+
tablePlan[0] = Object.freeze({ kind: "scan", columns: Object.freeze([...scanColumns]) });
|
|
278
|
+
}
|
|
279
|
+
for (const expression of expressionNames) available.add(expression);
|
|
280
|
+
for (const aggregate of aggregateNames) available.add(aggregate);
|
|
281
|
+
for (const key of options.orderBy || []) {
|
|
282
|
+
if (!available.has(key.column))
|
|
283
|
+
throw new Error(`Relational order column not found: ${key.column}`);
|
|
284
|
+
}
|
|
285
|
+
for (const key of options.groupBy || []) {
|
|
286
|
+
if (!available.has(key)) throw new Error(`Relational group column not found: ${key}`);
|
|
287
|
+
}
|
|
288
|
+
for (const aggregate of options.aggregates || []) {
|
|
289
|
+
if (!aggregate.name) throw new Error("Relational aggregate names must be non-empty.");
|
|
290
|
+
if (aggregate.function !== "count" && !aggregate.column) {
|
|
291
|
+
throw new Error(`Relational aggregate ${aggregate.function} requires a column.`);
|
|
292
|
+
}
|
|
293
|
+
if (aggregate.column && !available.has(aggregate.column)) {
|
|
294
|
+
throw new Error(`Relational aggregate column not found: ${aggregate.column}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const relationalSteps = [];
|
|
298
|
+
if ((_b = options.expressions) == null ? void 0 : _b.length)
|
|
299
|
+
relationalSteps.push({ kind: "expression", detail: options.expressions });
|
|
300
|
+
if ((_c = options.orderBy) == null ? void 0 : _c.length) relationalSteps.push({ kind: "order", detail: options.orderBy });
|
|
301
|
+
if (((_d = options.aggregates) == null ? void 0 : _d.length) || ((_e = options.groupBy) == null ? void 0 : _e.length)) {
|
|
302
|
+
relationalSteps.push({
|
|
303
|
+
kind: "aggregate",
|
|
304
|
+
detail: { groupBy: options.groupBy, aggregates: options.aggregates }
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if ((_f = options.union) == null ? void 0 : _f.length) relationalSteps.push({ kind: "union", detail: options.union });
|
|
308
|
+
if (options.join) relationalSteps.push({ kind: "join", detail: options.join });
|
|
309
|
+
return { tablePlan, relationalSteps: Object.freeze(relationalSteps) };
|
|
310
|
+
}
|
|
311
|
+
function validateRelationalColumnReference(columnName, availableColumns) {
|
|
312
|
+
if (!availableColumns.has(columnName)) {
|
|
313
|
+
throw new Error(`Relational expression column not found: ${columnName}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// src/loader-utils/lib/scan-utils/table-query-explain.ts
|
|
318
|
+
function explainTableQuery(sourceColumnNames, options, capabilities) {
|
|
319
|
+
const plan = planTableQuery(sourceColumnNames, options);
|
|
320
|
+
const outputColumns = options.columns ? [...options.columns] : [...sourceColumnNames];
|
|
321
|
+
const predicateColumns = options.predicate ? getColumnarPredicateColumns(options.predicate) : [];
|
|
322
|
+
const requiredColumns = [...plan[0].kind === "scan" ? plan[0].columns : []];
|
|
323
|
+
return Object.freeze({
|
|
324
|
+
sourceColumns: Object.freeze([...sourceColumnNames]),
|
|
325
|
+
outputColumns: Object.freeze(outputColumns),
|
|
326
|
+
requiredColumns: Object.freeze(requiredColumns),
|
|
327
|
+
predicateColumns: Object.freeze(predicateColumns),
|
|
328
|
+
plan,
|
|
329
|
+
capabilities: Object.freeze({ ...capabilities }),
|
|
330
|
+
operators: Object.freeze({
|
|
331
|
+
projection: createOperatorExplanation(options.columns !== void 0, capabilities.projection),
|
|
332
|
+
predicate: createOperatorExplanation(options.predicate !== void 0, capabilities.predicate),
|
|
333
|
+
limit: createOperatorExplanation(options.limit !== void 0, capabilities.limit)
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function createOperatorExplanation(enabled, support) {
|
|
338
|
+
return Object.freeze({ enabled, support });
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/schema-utils/lib/schema/data-type.ts
|
|
342
|
+
var import_core = require("@math.gl/core");
|
|
343
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
344
|
+
if (value instanceof Date) {
|
|
345
|
+
return "date-millisecond";
|
|
346
|
+
}
|
|
347
|
+
if (typeof value === "number") {
|
|
348
|
+
return defaultNumberType;
|
|
349
|
+
}
|
|
350
|
+
if (typeof value === "boolean") {
|
|
351
|
+
return "bool";
|
|
352
|
+
}
|
|
353
|
+
if (typeof value === "string") {
|
|
354
|
+
return "utf8";
|
|
355
|
+
}
|
|
356
|
+
if (value === null || value === "undefined") {
|
|
357
|
+
return "null";
|
|
358
|
+
}
|
|
359
|
+
return "null";
|
|
360
|
+
}
|
|
361
|
+
function getDataTypeFromArray(array) {
|
|
362
|
+
let type = getDataTypeFromTypedArray(array);
|
|
363
|
+
if (type !== "null") {
|
|
364
|
+
return { type, nullable: false };
|
|
365
|
+
}
|
|
366
|
+
if (array.length > 0) {
|
|
367
|
+
type = getDataTypeFromValue(array[0]);
|
|
368
|
+
return { type, nullable: true };
|
|
369
|
+
}
|
|
370
|
+
return { type: "null", nullable: true };
|
|
371
|
+
}
|
|
372
|
+
function getDataTypeFromTypedArray(array) {
|
|
373
|
+
if (typeof Float16Array !== "undefined" && array instanceof Float16Array) {
|
|
374
|
+
return "float16";
|
|
375
|
+
}
|
|
376
|
+
switch (array.constructor) {
|
|
377
|
+
case Int8Array:
|
|
378
|
+
return "int8";
|
|
379
|
+
case Uint8Array:
|
|
380
|
+
case Uint8ClampedArray:
|
|
381
|
+
return "uint8";
|
|
382
|
+
case Int16Array:
|
|
383
|
+
return "int16";
|
|
384
|
+
case Uint16Array:
|
|
385
|
+
return "uint16";
|
|
386
|
+
case Int32Array:
|
|
387
|
+
return "int32";
|
|
388
|
+
case Uint32Array:
|
|
389
|
+
return "uint32";
|
|
390
|
+
case BigInt64Array:
|
|
391
|
+
return "int64";
|
|
392
|
+
case BigUint64Array:
|
|
393
|
+
return "uint64";
|
|
394
|
+
case Float32Array:
|
|
395
|
+
return "float32";
|
|
396
|
+
case Float64Array:
|
|
397
|
+
return "float64";
|
|
398
|
+
default:
|
|
399
|
+
return "null";
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/schema-utils/lib/schema/convert-arrow-schema.ts
|
|
404
|
+
var arrow = __toESM(require("apache-arrow"), 1);
|
|
405
|
+
function convertArrowToSchema(arrowSchema) {
|
|
406
|
+
return serializeArrowSchema(arrowSchema);
|
|
407
|
+
}
|
|
408
|
+
function convertSchemaToArrow(schema, options) {
|
|
409
|
+
return deserializeArrowSchema(schema, options);
|
|
410
|
+
}
|
|
411
|
+
function serializeArrowSchema(arrowSchema) {
|
|
412
|
+
return {
|
|
413
|
+
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
414
|
+
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function deserializeArrowSchema(schema, options) {
|
|
418
|
+
return new arrow.Schema(
|
|
419
|
+
schema.fields.map((field) => deserializeArrowField(field, options)),
|
|
420
|
+
deserializeArrowMetadata(schema.metadata)
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
function serializeArrowMetadata(arrowMetadata) {
|
|
424
|
+
return Object.fromEntries(arrowMetadata);
|
|
425
|
+
}
|
|
426
|
+
function deserializeArrowMetadata(metadata) {
|
|
427
|
+
return metadata ? new Map(Object.entries(metadata)) : /* @__PURE__ */ new Map();
|
|
428
|
+
}
|
|
429
|
+
function serializeArrowField(field) {
|
|
430
|
+
return {
|
|
431
|
+
name: field.name,
|
|
432
|
+
type: serializeArrowType(field.type),
|
|
433
|
+
nullable: field.nullable,
|
|
434
|
+
metadata: serializeArrowMetadata(field.metadata)
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function deserializeArrowField(field, options) {
|
|
438
|
+
return new arrow.Field(
|
|
439
|
+
field.name,
|
|
440
|
+
deserializeArrowType(field.type, options),
|
|
441
|
+
field.nullable,
|
|
442
|
+
deserializeArrowMetadata(field.metadata)
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
function serializeArrowType(arrowType) {
|
|
446
|
+
if (isArrowViewType(arrowType, "BinaryView")) {
|
|
447
|
+
return "binary-view";
|
|
448
|
+
}
|
|
449
|
+
if (isArrowViewType(arrowType, "Utf8View")) {
|
|
450
|
+
return "utf8-view";
|
|
451
|
+
}
|
|
452
|
+
if (isOptionalArrowType(arrowType, "LargeList")) {
|
|
453
|
+
const largeListType = arrowType;
|
|
454
|
+
return {
|
|
455
|
+
type: "large-list",
|
|
456
|
+
children: [serializeArrowField(largeListType.valueField)]
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
switch (arrowType.constructor) {
|
|
460
|
+
case arrow.Null:
|
|
461
|
+
return "null";
|
|
462
|
+
case arrow.Binary:
|
|
463
|
+
return "binary";
|
|
464
|
+
case arrow.FixedSizeBinary:
|
|
465
|
+
return {
|
|
466
|
+
type: "fixed-size-binary",
|
|
467
|
+
byteWidth: arrowType.byteWidth
|
|
468
|
+
};
|
|
469
|
+
case arrow.Bool:
|
|
470
|
+
return "bool";
|
|
471
|
+
case arrow.Int:
|
|
472
|
+
const intType = arrowType;
|
|
473
|
+
return `${intType.isSigned ? "" : "u"}int${intType.bitWidth}`;
|
|
474
|
+
case arrow.Int8:
|
|
475
|
+
return "int8";
|
|
476
|
+
case arrow.Int16:
|
|
477
|
+
return "int16";
|
|
478
|
+
case arrow.Int32:
|
|
479
|
+
return "int32";
|
|
480
|
+
case arrow.Int64:
|
|
481
|
+
return "int64";
|
|
482
|
+
case arrow.Uint8:
|
|
483
|
+
return "uint8";
|
|
484
|
+
case arrow.Uint16:
|
|
485
|
+
return "uint16";
|
|
486
|
+
case arrow.Uint32:
|
|
487
|
+
return "uint32";
|
|
488
|
+
case arrow.Uint64:
|
|
489
|
+
return "uint64";
|
|
490
|
+
case arrow.Float:
|
|
491
|
+
const precision = arrowType.precision;
|
|
492
|
+
switch (precision) {
|
|
493
|
+
case arrow.Precision.HALF:
|
|
494
|
+
return "float16";
|
|
495
|
+
case arrow.Precision.SINGLE:
|
|
496
|
+
return "float32";
|
|
497
|
+
case arrow.Precision.DOUBLE:
|
|
498
|
+
return "float64";
|
|
499
|
+
default:
|
|
500
|
+
return "float16";
|
|
501
|
+
}
|
|
502
|
+
case arrow.Float16:
|
|
503
|
+
return "float16";
|
|
504
|
+
case arrow.Float32:
|
|
505
|
+
return "float32";
|
|
506
|
+
case arrow.Float64:
|
|
507
|
+
return "float64";
|
|
508
|
+
case arrow.Utf8:
|
|
509
|
+
return "utf8";
|
|
510
|
+
case arrow.Decimal:
|
|
511
|
+
const decimal = arrowType;
|
|
512
|
+
return {
|
|
513
|
+
type: "decimal",
|
|
514
|
+
bitWidth: decimal.bitWidth,
|
|
515
|
+
precision: decimal.precision,
|
|
516
|
+
scale: decimal.scale
|
|
517
|
+
};
|
|
518
|
+
case arrow.Date_:
|
|
519
|
+
const dateUnit = arrowType.unit;
|
|
520
|
+
return dateUnit === arrow.DateUnit.DAY ? "date-day" : "date-millisecond";
|
|
521
|
+
case arrow.DateDay:
|
|
522
|
+
return "date-day";
|
|
523
|
+
case arrow.DateMillisecond:
|
|
524
|
+
return "date-millisecond";
|
|
525
|
+
case arrow.Time:
|
|
526
|
+
const timeUnit = arrowType.unit;
|
|
527
|
+
switch (timeUnit) {
|
|
528
|
+
case arrow.TimeUnit.SECOND:
|
|
529
|
+
return "time-second";
|
|
530
|
+
case arrow.TimeUnit.MILLISECOND:
|
|
531
|
+
return "time-millisecond";
|
|
532
|
+
case arrow.TimeUnit.MICROSECOND:
|
|
533
|
+
return "time-microsecond";
|
|
534
|
+
case arrow.TimeUnit.NANOSECOND:
|
|
535
|
+
return "time-nanosecond";
|
|
536
|
+
default:
|
|
537
|
+
return "time-second";
|
|
538
|
+
}
|
|
539
|
+
case arrow.TimeMillisecond:
|
|
540
|
+
return "time-millisecond";
|
|
541
|
+
case arrow.TimeSecond:
|
|
542
|
+
return "time-second";
|
|
543
|
+
case arrow.TimeMicrosecond:
|
|
544
|
+
return "time-microsecond";
|
|
545
|
+
case arrow.TimeNanosecond:
|
|
546
|
+
return "time-nanosecond";
|
|
547
|
+
case arrow.Timestamp:
|
|
548
|
+
const timeStampUnit = arrowType.unit;
|
|
549
|
+
switch (timeStampUnit) {
|
|
550
|
+
case arrow.TimeUnit.SECOND:
|
|
551
|
+
return "timestamp-second";
|
|
552
|
+
case arrow.TimeUnit.MILLISECOND:
|
|
553
|
+
return "timestamp-millisecond";
|
|
554
|
+
case arrow.TimeUnit.MICROSECOND:
|
|
555
|
+
return "timestamp-microsecond";
|
|
556
|
+
case arrow.TimeUnit.NANOSECOND:
|
|
557
|
+
return "timestamp-nanosecond";
|
|
558
|
+
default:
|
|
559
|
+
return "timestamp-second";
|
|
560
|
+
}
|
|
561
|
+
case arrow.TimestampSecond:
|
|
562
|
+
return "timestamp-second";
|
|
563
|
+
case arrow.TimestampMillisecond:
|
|
564
|
+
return "timestamp-millisecond";
|
|
565
|
+
case arrow.TimestampMicrosecond:
|
|
566
|
+
return "timestamp-microsecond";
|
|
567
|
+
case arrow.TimestampNanosecond:
|
|
568
|
+
return "timestamp-nanosecond";
|
|
569
|
+
case arrow.Interval:
|
|
570
|
+
const intervalUnit = arrowType.unit;
|
|
571
|
+
switch (intervalUnit) {
|
|
572
|
+
case arrow.IntervalUnit.DAY_TIME:
|
|
573
|
+
return "interval-daytime";
|
|
574
|
+
case arrow.IntervalUnit.YEAR_MONTH:
|
|
575
|
+
return "interval-yearmonth";
|
|
576
|
+
default:
|
|
577
|
+
return "interval-daytime";
|
|
578
|
+
}
|
|
579
|
+
case arrow.IntervalDayTime:
|
|
580
|
+
return "interval-daytime";
|
|
581
|
+
case arrow.IntervalYearMonth:
|
|
582
|
+
return "interval-yearmonth";
|
|
583
|
+
case arrow.Map_:
|
|
584
|
+
const mapType = arrowType;
|
|
585
|
+
return {
|
|
586
|
+
type: "map",
|
|
587
|
+
keysSorted: mapType.keysSorted,
|
|
588
|
+
children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
589
|
+
};
|
|
590
|
+
case arrow.List:
|
|
591
|
+
const listType = arrowType;
|
|
592
|
+
const listField = listType.valueField;
|
|
593
|
+
return {
|
|
594
|
+
type: "list",
|
|
595
|
+
children: [serializeArrowField(listField)]
|
|
596
|
+
};
|
|
597
|
+
case arrow.FixedSizeList:
|
|
598
|
+
const fixedSizeList = arrowType;
|
|
599
|
+
return {
|
|
600
|
+
type: "fixed-size-list",
|
|
601
|
+
listSize: fixedSizeList.listSize,
|
|
602
|
+
children: [serializeArrowField(fixedSizeList.children[0])]
|
|
603
|
+
};
|
|
604
|
+
case arrow.Struct:
|
|
605
|
+
const structType = arrowType;
|
|
606
|
+
return {
|
|
607
|
+
type: "struct",
|
|
608
|
+
children: structType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
609
|
+
};
|
|
610
|
+
case arrow.SparseUnion:
|
|
611
|
+
case arrow.DenseUnion:
|
|
612
|
+
const unionType = arrowType;
|
|
613
|
+
return {
|
|
614
|
+
type: unionType instanceof arrow.DenseUnion ? "dense-union" : "sparse-union",
|
|
615
|
+
typeIds: unionType.typeIds,
|
|
616
|
+
children: unionType.children.map((arrowField) => serializeArrowField(arrowField)),
|
|
617
|
+
typeIdToChildIndex: { ...unionType.typeIdToChildIndex }
|
|
618
|
+
};
|
|
619
|
+
case arrow.Dictionary:
|
|
620
|
+
const dictionaryType = arrowType;
|
|
621
|
+
return {
|
|
622
|
+
type: "dictionary",
|
|
623
|
+
id: dictionaryType.id,
|
|
624
|
+
indices: serializeArrowDictionaryKeyType(dictionaryType.indices),
|
|
625
|
+
dictionary: serializeArrowType(dictionaryType.dictionary),
|
|
626
|
+
isOrdered: dictionaryType.isOrdered
|
|
627
|
+
};
|
|
628
|
+
default:
|
|
629
|
+
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
function deserializeArrowType(dataType, options) {
|
|
633
|
+
if (typeof dataType === "object") {
|
|
634
|
+
switch (dataType.type) {
|
|
635
|
+
case "decimal":
|
|
636
|
+
return new arrow.Decimal(dataType.scale, dataType.precision, dataType.bitWidth);
|
|
637
|
+
case "map": {
|
|
638
|
+
const children = dataType.children.map(
|
|
639
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
640
|
+
);
|
|
641
|
+
return new arrow.Map_(children[0], dataType.keysSorted);
|
|
642
|
+
}
|
|
643
|
+
case "list": {
|
|
644
|
+
const field = deserializeArrowField(dataType.children[0], options);
|
|
645
|
+
return new arrow.List(field);
|
|
646
|
+
}
|
|
647
|
+
case "large-list": {
|
|
648
|
+
const field = deserializeArrowField(dataType.children[0], options);
|
|
649
|
+
const LargeList = getOptionalArrowConstructor("LargeList");
|
|
650
|
+
if (!LargeList) {
|
|
651
|
+
throw new Error(
|
|
652
|
+
"LargeList requires an Apache Arrow runtime that exports the LargeList constructor"
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
return new LargeList(field);
|
|
656
|
+
}
|
|
657
|
+
case "fixed-size-list": {
|
|
658
|
+
const child = deserializeArrowField(dataType.children[0], options);
|
|
659
|
+
return new arrow.FixedSizeList(dataType.listSize, child);
|
|
660
|
+
}
|
|
661
|
+
case "fixed-size-binary":
|
|
662
|
+
return new arrow.FixedSizeBinary(dataType.byteWidth);
|
|
663
|
+
case "struct": {
|
|
664
|
+
const children = dataType.children.map(
|
|
665
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
666
|
+
);
|
|
667
|
+
return new arrow.Struct(children);
|
|
668
|
+
}
|
|
669
|
+
case "sparse-union":
|
|
670
|
+
case "dense-union": {
|
|
671
|
+
const children = dataType.children.map(
|
|
672
|
+
(arrowField) => deserializeArrowField(arrowField, options)
|
|
673
|
+
);
|
|
674
|
+
return dataType.type === "dense-union" ? new arrow.DenseUnion(dataType.typeIds, children) : new arrow.SparseUnion(dataType.typeIds, children);
|
|
675
|
+
}
|
|
676
|
+
case "dictionary": {
|
|
677
|
+
return new arrow.Dictionary(
|
|
678
|
+
deserializeArrowType(dataType.dictionary, options),
|
|
679
|
+
deserializeArrowDictionaryKeyType(dataType.indices),
|
|
680
|
+
dataType.id,
|
|
681
|
+
dataType.isOrdered
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
default:
|
|
685
|
+
throw new Error("array type not supported");
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
switch (dataType) {
|
|
689
|
+
case "null":
|
|
690
|
+
return new arrow.Null();
|
|
691
|
+
case "binary":
|
|
692
|
+
return makeVariableWidthArrowType("BinaryView", new arrow.Binary(), options);
|
|
693
|
+
case "binary-view":
|
|
694
|
+
return makeRequiredArrowViewType("BinaryView");
|
|
695
|
+
case "bool":
|
|
696
|
+
return new arrow.Bool();
|
|
697
|
+
case "int8":
|
|
698
|
+
return new arrow.Int8();
|
|
699
|
+
case "int16":
|
|
700
|
+
return new arrow.Int16();
|
|
701
|
+
case "int32":
|
|
702
|
+
return new arrow.Int32();
|
|
703
|
+
case "int64":
|
|
704
|
+
return new arrow.Int64();
|
|
705
|
+
case "uint8":
|
|
706
|
+
return new arrow.Uint8();
|
|
707
|
+
case "uint16":
|
|
708
|
+
return new arrow.Uint16();
|
|
709
|
+
case "uint32":
|
|
710
|
+
return new arrow.Uint32();
|
|
711
|
+
case "uint64":
|
|
712
|
+
return new arrow.Uint64();
|
|
713
|
+
case "float16":
|
|
714
|
+
return new arrow.Float16();
|
|
715
|
+
case "float32":
|
|
716
|
+
return new arrow.Float32();
|
|
717
|
+
case "float64":
|
|
718
|
+
return new arrow.Float64();
|
|
719
|
+
case "utf8":
|
|
720
|
+
return makeVariableWidthArrowType("Utf8View", new arrow.Utf8(), options);
|
|
721
|
+
case "utf8-view":
|
|
722
|
+
return makeRequiredArrowViewType("Utf8View");
|
|
723
|
+
case "date-day":
|
|
724
|
+
return new arrow.DateDay();
|
|
725
|
+
case "date-millisecond":
|
|
726
|
+
return new arrow.DateMillisecond();
|
|
727
|
+
case "time-second":
|
|
728
|
+
return new arrow.TimeSecond();
|
|
729
|
+
case "time-millisecond":
|
|
730
|
+
return new arrow.TimeMillisecond();
|
|
731
|
+
case "time-microsecond":
|
|
732
|
+
return new arrow.TimeMicrosecond();
|
|
733
|
+
case "time-nanosecond":
|
|
734
|
+
return new arrow.TimeNanosecond();
|
|
735
|
+
case "timestamp-second":
|
|
736
|
+
return new arrow.TimestampSecond();
|
|
737
|
+
case "timestamp-millisecond":
|
|
738
|
+
return new arrow.TimestampMillisecond();
|
|
739
|
+
case "timestamp-microsecond":
|
|
740
|
+
return new arrow.TimestampMicrosecond();
|
|
741
|
+
case "timestamp-nanosecond":
|
|
742
|
+
return new arrow.TimestampNanosecond();
|
|
743
|
+
case "interval-daytime":
|
|
744
|
+
return new arrow.IntervalDayTime();
|
|
745
|
+
case "interval-yearmonth":
|
|
746
|
+
return new arrow.IntervalYearMonth();
|
|
747
|
+
default:
|
|
748
|
+
throw new Error("array type not supported");
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
function getOptionalArrowConstructor(typeName) {
|
|
752
|
+
return arrow[typeName];
|
|
753
|
+
}
|
|
754
|
+
function isArrowViewType(arrowType, viewTypeName) {
|
|
755
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
756
|
+
if (constructor && arrowType instanceof constructor) {
|
|
757
|
+
return true;
|
|
758
|
+
}
|
|
759
|
+
const guards = arrow.DataType;
|
|
760
|
+
const guard = viewTypeName === "BinaryView" ? guards.isBinaryView : guards.isUtf8View;
|
|
761
|
+
return Boolean(guard == null ? void 0 : guard(arrowType));
|
|
762
|
+
}
|
|
763
|
+
function isOptionalArrowType(arrowType, typeName) {
|
|
764
|
+
const constructor = getOptionalArrowConstructor(typeName);
|
|
765
|
+
return Boolean(constructor && arrowType instanceof constructor);
|
|
766
|
+
}
|
|
767
|
+
function makeVariableWidthArrowType(viewTypeName, fallbackType, options) {
|
|
768
|
+
const viewTypeMode = (options == null ? void 0 : options.viewTypes) || "never";
|
|
769
|
+
if (viewTypeMode === "never") {
|
|
770
|
+
return fallbackType;
|
|
771
|
+
}
|
|
772
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
773
|
+
if (constructor) {
|
|
774
|
+
return new constructor();
|
|
775
|
+
}
|
|
776
|
+
if (viewTypeMode === "require") {
|
|
777
|
+
throw new Error(
|
|
778
|
+
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
return fallbackType;
|
|
782
|
+
}
|
|
783
|
+
function makeRequiredArrowViewType(viewTypeName) {
|
|
784
|
+
const constructor = getOptionalArrowConstructor(viewTypeName);
|
|
785
|
+
if (!constructor) {
|
|
786
|
+
throw new Error(
|
|
787
|
+
`${viewTypeName} requires apache-arrow 21.2.0 or later; the installed runtime does not support it`
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
return new constructor();
|
|
791
|
+
}
|
|
792
|
+
function serializeArrowDictionaryKeyType(arrowType) {
|
|
793
|
+
if (arrowType instanceof arrow.Int) {
|
|
794
|
+
const prefix = arrowType.isSigned ? "int" : "uint";
|
|
795
|
+
const keyType = `${prefix}${arrowType.bitWidth}`;
|
|
796
|
+
if (isSchemaDictionaryKeyType(keyType)) {
|
|
797
|
+
return keyType;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
switch (arrowType.constructor) {
|
|
801
|
+
case arrow.Int8:
|
|
802
|
+
return "int8";
|
|
803
|
+
case arrow.Int16:
|
|
804
|
+
return "int16";
|
|
805
|
+
case arrow.Int32:
|
|
806
|
+
return "int32";
|
|
807
|
+
case arrow.Uint8:
|
|
808
|
+
return "uint8";
|
|
809
|
+
case arrow.Uint16:
|
|
810
|
+
return "uint16";
|
|
811
|
+
case arrow.Uint32:
|
|
812
|
+
return "uint32";
|
|
813
|
+
default:
|
|
814
|
+
throw new Error(`arrow dictionary index type not supported: ${arrowType.constructor.name}`);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function isSchemaDictionaryKeyType(keyType) {
|
|
818
|
+
return ["int8", "int16", "int32", "uint8", "uint16", "uint32"].includes(keyType);
|
|
819
|
+
}
|
|
820
|
+
function deserializeArrowDictionaryKeyType(keyType) {
|
|
821
|
+
switch (keyType) {
|
|
822
|
+
case "int8":
|
|
823
|
+
return new arrow.Int8();
|
|
824
|
+
case "int16":
|
|
825
|
+
return new arrow.Int16();
|
|
826
|
+
case "int32":
|
|
827
|
+
return new arrow.Int32();
|
|
828
|
+
case "uint8":
|
|
829
|
+
return new arrow.Uint8();
|
|
830
|
+
case "uint16":
|
|
831
|
+
return new arrow.Uint16();
|
|
832
|
+
case "uint32":
|
|
833
|
+
return new arrow.Uint32();
|
|
834
|
+
default:
|
|
835
|
+
throw new Error(`schema dictionary index type not supported: ${keyType}`);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
840
|
+
var arrow3 = __toESM(require("apache-arrow"), 1);
|
|
841
|
+
|
|
842
|
+
// src/schema-utils/lib/table/tables/table-accessors.ts
|
|
843
|
+
function getTableLength(table) {
|
|
844
|
+
if (!("shape" in table)) return table.numRows;
|
|
845
|
+
switch (table.shape) {
|
|
846
|
+
case "array-row-table":
|
|
847
|
+
case "object-row-table":
|
|
848
|
+
return table.data.length;
|
|
849
|
+
case "geojson-table":
|
|
850
|
+
return table.features.length;
|
|
851
|
+
case "arrow-table":
|
|
852
|
+
return getTableLength(table.data);
|
|
853
|
+
case "columnar-table":
|
|
854
|
+
for (const column of Object.values(table.data)) {
|
|
855
|
+
return column.length || 0;
|
|
856
|
+
}
|
|
857
|
+
return 0;
|
|
858
|
+
default:
|
|
859
|
+
throw new Error("table");
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
function getTableNumCols(table) {
|
|
863
|
+
if (!("shape" in table)) return table.numCols;
|
|
864
|
+
if (table.schema) {
|
|
865
|
+
return table.schema.fields.length;
|
|
866
|
+
}
|
|
867
|
+
if (getTableLength(table) === 0) {
|
|
868
|
+
throw new Error("empty table");
|
|
869
|
+
}
|
|
870
|
+
switch (table.shape) {
|
|
871
|
+
case "array-row-table":
|
|
872
|
+
return table.data[0].length;
|
|
873
|
+
case "object-row-table":
|
|
874
|
+
return Object.keys(table.data[0]).length;
|
|
875
|
+
case "geojson-table":
|
|
876
|
+
return Object.keys(table.features[0]).length;
|
|
877
|
+
case "columnar-table":
|
|
878
|
+
return Object.keys(table.data).length;
|
|
879
|
+
case "arrow-table":
|
|
880
|
+
return getTableNumCols(table.data);
|
|
881
|
+
default:
|
|
882
|
+
throw new Error("table");
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function getTableCellAt(table, rowIndex, columnIndex) {
|
|
886
|
+
var _a;
|
|
887
|
+
if (!("shape" in table)) return (_a = table.getChildAt(columnIndex)) == null ? void 0 : _a.get(rowIndex);
|
|
888
|
+
switch (table.shape) {
|
|
889
|
+
case "array-row-table":
|
|
890
|
+
return table.data[rowIndex][columnIndex];
|
|
891
|
+
case "object-row-table":
|
|
892
|
+
const columnName1 = getTableColumnName(table, columnIndex);
|
|
893
|
+
return table.data[rowIndex][columnName1];
|
|
894
|
+
case "geojson-table":
|
|
895
|
+
const columnName2 = getTableColumnName(table, columnIndex);
|
|
896
|
+
return table.features[rowIndex][columnName2];
|
|
897
|
+
case "columnar-table":
|
|
898
|
+
const columnName3 = getTableColumnName(table, columnIndex);
|
|
899
|
+
const column = table.data[columnName3];
|
|
900
|
+
return column[rowIndex];
|
|
901
|
+
case "arrow-table":
|
|
902
|
+
return getTableCellAt(table.data, rowIndex, columnIndex);
|
|
903
|
+
default:
|
|
904
|
+
throw new Error("todo");
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function getTableColumnName(table, columnIndex) {
|
|
908
|
+
var _a, _b;
|
|
909
|
+
const columnName = (_b = (_a = table.schema) == null ? void 0 : _a.fields[columnIndex]) == null ? void 0 : _b.name;
|
|
910
|
+
if (!columnName) {
|
|
911
|
+
throw new Error(`${columnIndex}`);
|
|
912
|
+
}
|
|
913
|
+
return columnName;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// src/schema-utils/lib/schema/deduce-table-schema.ts
|
|
917
|
+
function deduceTableSchema(table) {
|
|
918
|
+
switch (table.shape) {
|
|
919
|
+
case "array-row-table":
|
|
920
|
+
case "object-row-table":
|
|
921
|
+
return deduceSchemaFromRows(table.data);
|
|
922
|
+
case "geojson-table":
|
|
923
|
+
return deduceSchemaFromGeoJSON(table.features);
|
|
924
|
+
case "columnar-table":
|
|
925
|
+
return deduceSchemaFromColumns(table.data);
|
|
926
|
+
case "arrow-table":
|
|
927
|
+
default:
|
|
928
|
+
throw new Error("Deduce schema");
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
932
|
+
const fields = [];
|
|
933
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
934
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
935
|
+
fields.push(field);
|
|
936
|
+
}
|
|
937
|
+
return { fields, metadata: {} };
|
|
938
|
+
}
|
|
939
|
+
function deduceSchemaFromRows(rowTable) {
|
|
940
|
+
if (!rowTable.length) {
|
|
941
|
+
throw new Error("deduce from empty table");
|
|
942
|
+
}
|
|
943
|
+
const fields = [];
|
|
944
|
+
const row0 = rowTable[0];
|
|
945
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
946
|
+
const name = Array.isArray(row0) ? `column${Number(columnName) + 1}` : columnName;
|
|
947
|
+
fields.push(deduceFieldFromValue(value, name));
|
|
948
|
+
}
|
|
949
|
+
return { fields, metadata: {} };
|
|
950
|
+
}
|
|
951
|
+
function deduceSchemaFromGeoJSON(features) {
|
|
952
|
+
if (!features.length) {
|
|
953
|
+
throw new Error("deduce from empty table");
|
|
954
|
+
}
|
|
955
|
+
const fields = [];
|
|
956
|
+
const row0 = features[0].properties || {};
|
|
957
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
958
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
959
|
+
}
|
|
960
|
+
return { fields, metadata: {} };
|
|
961
|
+
}
|
|
962
|
+
function deduceFieldFromColumn(column, name) {
|
|
963
|
+
if (ArrayBuffer.isView(column)) {
|
|
964
|
+
const type = getDataTypeFromArray(column);
|
|
965
|
+
return {
|
|
966
|
+
name,
|
|
967
|
+
type: type.type || "null",
|
|
968
|
+
nullable: type.nullable
|
|
969
|
+
// metadata: {}
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
973
|
+
const value = column[0];
|
|
974
|
+
const type = getDataTypeFromValue(value);
|
|
975
|
+
return {
|
|
976
|
+
name,
|
|
977
|
+
type,
|
|
978
|
+
nullable: true
|
|
979
|
+
// metadata: {},
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
throw new Error("empty table");
|
|
983
|
+
}
|
|
984
|
+
function deduceFieldFromValue(value, name) {
|
|
985
|
+
const type = getDataTypeFromValue(value);
|
|
986
|
+
return {
|
|
987
|
+
name,
|
|
988
|
+
type,
|
|
989
|
+
nullable: true
|
|
990
|
+
// metadata: {}
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts
|
|
995
|
+
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
996
|
+
function* sliceNativeArrowBatches(table, batchSize) {
|
|
997
|
+
if (batchSize !== void 0 && (!Number.isSafeInteger(batchSize) || batchSize < 1)) {
|
|
998
|
+
throw new RangeError("batchSize must be a positive integer");
|
|
999
|
+
}
|
|
1000
|
+
for (const batch of table.batches) {
|
|
1001
|
+
if (batchSize === void 0 || batch.numRows <= batchSize) {
|
|
1002
|
+
yield batch;
|
|
1003
|
+
} else {
|
|
1004
|
+
for (let offset = 0; offset < batch.numRows; offset += batchSize) {
|
|
1005
|
+
yield batch.slice(offset, offset + batchSize);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
function* makeWrappedTableRecordBatchIterator(table, options) {
|
|
1011
|
+
if (table.shape === "arrow-table") {
|
|
1012
|
+
yield* sliceNativeArrowBatches(table.data, options == null ? void 0 : options.batchSize);
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
const arrowSchema = convertSchemaToArrow(table.schema);
|
|
1016
|
+
const length = getTableLength(table);
|
|
1017
|
+
const numColumns = getTableNumCols(table);
|
|
1018
|
+
const batchSize = (options == null ? void 0 : options.batchSize) || length;
|
|
1019
|
+
const builders = arrowSchema == null ? void 0 : arrowSchema.fields.map(
|
|
1020
|
+
(arrowField) => arrow2.makeBuilder({
|
|
1021
|
+
type: arrowField.type,
|
|
1022
|
+
nullValues: [null, void 0]
|
|
1023
|
+
})
|
|
1024
|
+
);
|
|
1025
|
+
const structField = new arrow2.Struct(arrowSchema.fields);
|
|
1026
|
+
let batchLength = 0;
|
|
1027
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1028
|
+
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
1029
|
+
const value = getTableCellAt(table, rowIndex, columnIndex);
|
|
1030
|
+
const builder = builders[columnIndex];
|
|
1031
|
+
builder.append(value);
|
|
1032
|
+
}
|
|
1033
|
+
batchLength++;
|
|
1034
|
+
if (batchLength >= batchSize) {
|
|
1035
|
+
const datas = builders.map((builder) => builder.flush());
|
|
1036
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1037
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
1038
|
+
batchLength = 0;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (batchLength > 0) {
|
|
1042
|
+
const datas = builders.map((builder) => builder.flush());
|
|
1043
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1044
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
1045
|
+
batchLength = 0;
|
|
1046
|
+
}
|
|
1047
|
+
builders.map((builder) => builder.finish());
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
1051
|
+
function convertTableToArrow(table, options) {
|
|
1052
|
+
if (!("shape" in table)) return table;
|
|
1053
|
+
switch (table.shape) {
|
|
1054
|
+
case "arrow-table":
|
|
1055
|
+
return table.data;
|
|
1056
|
+
case "columnar-table":
|
|
1057
|
+
// TODO - optimized implementation is possible
|
|
1058
|
+
// return convertColumnarTableToArrow(table, options);
|
|
1059
|
+
// fall through
|
|
1060
|
+
default:
|
|
1061
|
+
const schema = table.schema ?? deduceTableSchema(table);
|
|
1062
|
+
return new arrow3.Table(convertSchemaToArrow(schema), [
|
|
1063
|
+
...makeWrappedTableRecordBatchIterator({ ...table, schema }, options)
|
|
1064
|
+
]);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// src/schema-utils/deprecated.ts
|
|
1069
|
+
var convertTableToArrow2 = ((...args) => convertTableToArrow(
|
|
1070
|
+
...args
|
|
1071
|
+
));
|
|
1072
|
+
|
|
1073
|
+
// dist/scan/query-arrow-table.js
|
|
1074
|
+
var arrow7 = __toESM(require("apache-arrow"), 1);
|
|
1075
|
+
|
|
1076
|
+
// dist/scan/arrow-execution/project-arrow-table.js
|
|
1077
|
+
var arrow4 = __toESM(require("apache-arrow"), 1);
|
|
1078
|
+
function projectArrowTable(source, selections) {
|
|
1079
|
+
const outputNames = /* @__PURE__ */ new Set();
|
|
1080
|
+
const indices = [];
|
|
1081
|
+
const fields = selections.map((selection) => {
|
|
1082
|
+
const column = typeof selection === "string" ? selection : selection.column;
|
|
1083
|
+
const name = typeof selection === "string" ? selection : selection.as === void 0 ? column : selection.as;
|
|
1084
|
+
const index = source.schema.fields.findIndex((field) => field.name === column);
|
|
1085
|
+
if (index < 0)
|
|
1086
|
+
throw new Error(`Arrow projection column not found: ${column}`);
|
|
1087
|
+
if (typeof name !== "string" || typeof selection !== "string" && selection.as !== void 0 && !name.length || outputNames.has(name)) {
|
|
1088
|
+
throw new Error(`Invalid or duplicate Arrow projection output name: ${name}`);
|
|
1089
|
+
}
|
|
1090
|
+
outputNames.add(name);
|
|
1091
|
+
indices.push(index);
|
|
1092
|
+
return source.schema.fields[index].clone({ name });
|
|
1093
|
+
});
|
|
1094
|
+
const schema = new arrow4.Schema(fields, source.schema.metadata);
|
|
1095
|
+
const batches = source.batches.map((batch) => new arrow4.RecordBatch(schema, arrow4.makeData({
|
|
1096
|
+
type: new arrow4.Struct(fields),
|
|
1097
|
+
length: batch.numRows,
|
|
1098
|
+
children: indices.map((index) => batch.data.children[index])
|
|
1099
|
+
}), batch.metadata));
|
|
1100
|
+
return new arrow4.Table(schema, batches);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// dist/scan/arrow-execution/filter-arrow-table.js
|
|
1104
|
+
var arrow5 = __toESM(require("apache-arrow"), 1);
|
|
1105
|
+
var import_arrow = require("@math.gl/arrow");
|
|
1106
|
+
function filterArrowTable(source, predicate, options = {}) {
|
|
1107
|
+
validateColumnarPredicate(predicate, new Set(source.schema.fields.map((field) => field.name)));
|
|
1108
|
+
const columnNames = getColumnarPredicateColumns(predicate);
|
|
1109
|
+
return filterArrowRows(source, (batch) => {
|
|
1110
|
+
const columns = getPredicateColumns(new arrow5.Table(source.schema, [batch]), columnNames);
|
|
1111
|
+
return (rowIndex) => evaluatePredicate(predicate, columns, rowIndex) === true;
|
|
1112
|
+
}, options);
|
|
1113
|
+
}
|
|
1114
|
+
function filterArrowRows(source, selectBatch, options = {}) {
|
|
1115
|
+
var _a, _b, _c;
|
|
1116
|
+
let remaining = options.limit ?? Infinity;
|
|
1117
|
+
if (remaining !== Infinity && (!Number.isSafeInteger(remaining) || remaining < 0)) {
|
|
1118
|
+
throw new Error("Arrow filter limit must be a non-negative safe integer.");
|
|
1119
|
+
}
|
|
1120
|
+
(_a = options.signal) == null ? void 0 : _a.throwIfAborted();
|
|
1121
|
+
const batches = [];
|
|
1122
|
+
for (const batch of source.batches) {
|
|
1123
|
+
if (remaining === 0)
|
|
1124
|
+
break;
|
|
1125
|
+
(_b = options.signal) == null ? void 0 : _b.throwIfAborted();
|
|
1126
|
+
const data = new arrow5.Table(source.schema, [batch]);
|
|
1127
|
+
const selectRow = selectBatch(batch);
|
|
1128
|
+
const indices = [];
|
|
1129
|
+
for (let rowIndex = 0; rowIndex < batch.numRows && indices.length < remaining; rowIndex++) {
|
|
1130
|
+
(_c = options.signal) == null ? void 0 : _c.throwIfAborted();
|
|
1131
|
+
if (selectRow(rowIndex))
|
|
1132
|
+
indices.push(rowIndex);
|
|
1133
|
+
}
|
|
1134
|
+
remaining -= indices.length;
|
|
1135
|
+
if (indices.length === 0)
|
|
1136
|
+
continue;
|
|
1137
|
+
if (indices.length === batch.numRows) {
|
|
1138
|
+
batches.push(batch);
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
if (indices[indices.length - 1] - indices[0] + 1 === indices.length) {
|
|
1142
|
+
batches.push(batch.slice(indices[0], indices[indices.length - 1] + 1));
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
const gathered = (0, import_arrow.takeArrowTableRows)(data, Int32Array.from(indices));
|
|
1146
|
+
batches.push(...gathered.batches.map((output) => new arrow5.RecordBatch(source.schema, output.data, batch.metadata)));
|
|
1147
|
+
}
|
|
1148
|
+
return new arrow5.Table(source.schema, batches);
|
|
1149
|
+
}
|
|
1150
|
+
function getPredicateColumns(sourceTable, columnNames) {
|
|
1151
|
+
const columns = {};
|
|
1152
|
+
for (const columnName of columnNames) {
|
|
1153
|
+
const column = sourceTable.getChild(columnName);
|
|
1154
|
+
if (!column) {
|
|
1155
|
+
throw new Error(`Arrow query column not found: ${columnName}`);
|
|
1156
|
+
}
|
|
1157
|
+
columns[columnName] = column;
|
|
1158
|
+
}
|
|
1159
|
+
return columns;
|
|
1160
|
+
}
|
|
1161
|
+
function evaluatePredicate(predicate, columns, rowIndex) {
|
|
1162
|
+
if (isLogicalPredicate(predicate)) {
|
|
1163
|
+
const values = predicate.args.map((child) => evaluatePredicate(child, columns, rowIndex));
|
|
1164
|
+
return predicate.op === "and" ? evaluateAnd(values) : evaluateOr(values);
|
|
1165
|
+
}
|
|
1166
|
+
if (isNotPredicate(predicate)) {
|
|
1167
|
+
const value2 = evaluatePredicate(predicate.args[0], columns, rowIndex);
|
|
1168
|
+
return value2 === null ? null : !value2;
|
|
1169
|
+
}
|
|
1170
|
+
const value = getColumnValue(columns, predicate.args[0].property, rowIndex);
|
|
1171
|
+
if (isNullPredicate(predicate)) {
|
|
1172
|
+
return value === null || value === void 0;
|
|
1173
|
+
}
|
|
1174
|
+
if (isInPredicate(predicate)) {
|
|
1175
|
+
return evaluateIn(value, predicate.args[1]);
|
|
1176
|
+
}
|
|
1177
|
+
return evaluateComparison(value, predicate);
|
|
1178
|
+
}
|
|
1179
|
+
function getColumnValue(columns, columnName, rowIndex) {
|
|
1180
|
+
const path = typeof columnName === "string" ? [columnName] : columnName;
|
|
1181
|
+
const column = columns[path[0]];
|
|
1182
|
+
if (!column) {
|
|
1183
|
+
throw new Error(`Arrow query could not read predicate column "${columnName}".`);
|
|
1184
|
+
}
|
|
1185
|
+
let value = column.get(rowIndex);
|
|
1186
|
+
for (const property of path.slice(1)) {
|
|
1187
|
+
if (value === null || value === void 0)
|
|
1188
|
+
return null;
|
|
1189
|
+
value = value[property];
|
|
1190
|
+
}
|
|
1191
|
+
return value;
|
|
1192
|
+
}
|
|
1193
|
+
function evaluateAnd(values) {
|
|
1194
|
+
if (values.includes(false)) {
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
return values.includes(null) ? null : true;
|
|
1198
|
+
}
|
|
1199
|
+
function evaluateOr(values) {
|
|
1200
|
+
if (values.includes(true)) {
|
|
1201
|
+
return true;
|
|
1202
|
+
}
|
|
1203
|
+
return values.includes(null) ? null : false;
|
|
1204
|
+
}
|
|
1205
|
+
function evaluateIn(value, candidates) {
|
|
1206
|
+
if (value === null || value === void 0) {
|
|
1207
|
+
return null;
|
|
1208
|
+
}
|
|
1209
|
+
for (const candidate of candidates) {
|
|
1210
|
+
if (compareValues(value, candidate) === 0) {
|
|
1211
|
+
return true;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
return false;
|
|
1215
|
+
}
|
|
1216
|
+
function evaluateComparison(value, predicate) {
|
|
1217
|
+
if (value === null || value === void 0) {
|
|
1218
|
+
return null;
|
|
1219
|
+
}
|
|
1220
|
+
const comparison = compareValues(value, predicate.args[1]);
|
|
1221
|
+
switch (predicate.op) {
|
|
1222
|
+
case "=":
|
|
1223
|
+
return comparison === 0;
|
|
1224
|
+
case "<>":
|
|
1225
|
+
return comparison !== 0;
|
|
1226
|
+
case "<":
|
|
1227
|
+
return comparison < 0;
|
|
1228
|
+
case "<=":
|
|
1229
|
+
return comparison <= 0;
|
|
1230
|
+
case ">":
|
|
1231
|
+
return comparison > 0;
|
|
1232
|
+
case ">=":
|
|
1233
|
+
return comparison >= 0;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
function compareValues(left, right) {
|
|
1237
|
+
if (isColumnarPredicateParameter(right)) {
|
|
1238
|
+
throw new Error(`Arrow query parameter ":${right.parameter}" must be bound before query execution.`);
|
|
1239
|
+
}
|
|
1240
|
+
if (left instanceof Date && right instanceof Date) {
|
|
1241
|
+
return compareArrowQueryNumbers(left.getTime(), right.getTime());
|
|
1242
|
+
}
|
|
1243
|
+
if (typeof left === "number" && right instanceof Date) {
|
|
1244
|
+
return compareArrowQueryNumbers(left, right.getTime());
|
|
1245
|
+
}
|
|
1246
|
+
if (left instanceof Uint8Array && right instanceof Uint8Array) {
|
|
1247
|
+
return compareBinary(left, right);
|
|
1248
|
+
}
|
|
1249
|
+
if (typeof left === "bigint" && typeof right === "bigint") {
|
|
1250
|
+
return left === right ? 0 : left < right ? -1 : 1;
|
|
1251
|
+
}
|
|
1252
|
+
if (typeof left === "bigint" && typeof right === "number" || typeof left === "number" && typeof right === "bigint") {
|
|
1253
|
+
const numericValue = typeof left === "number" ? left : right;
|
|
1254
|
+
if (!Number.isFinite(numericValue))
|
|
1255
|
+
throw new Error("Arrow query cannot compare non-finite numbers.");
|
|
1256
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
1257
|
+
}
|
|
1258
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
1259
|
+
return compareArrowQueryNumbers(left, right);
|
|
1260
|
+
}
|
|
1261
|
+
if (typeof left === "string" && typeof right === "string") {
|
|
1262
|
+
return left === right ? 0 : left < right ? -1 : 1;
|
|
1263
|
+
}
|
|
1264
|
+
if (typeof left === "boolean" && typeof right === "boolean") {
|
|
1265
|
+
return Number(left) - Number(right);
|
|
1266
|
+
}
|
|
1267
|
+
throw new Error(`Arrow query cannot compare ${getArrowQueryValueType(left)} with ${getArrowQueryValueType(right)} values.`);
|
|
1268
|
+
}
|
|
1269
|
+
function compareArrowQueryNumbers(left, right) {
|
|
1270
|
+
if (!Number.isFinite(left) || !Number.isFinite(right)) {
|
|
1271
|
+
throw new Error("Arrow query cannot compare non-finite numbers.");
|
|
1272
|
+
}
|
|
1273
|
+
return left === right ? 0 : left < right ? -1 : 1;
|
|
1274
|
+
}
|
|
1275
|
+
function compareBinary(left, right) {
|
|
1276
|
+
const commonLength = Math.min(left.length, right.length);
|
|
1277
|
+
for (let index = 0; index < commonLength; index++) {
|
|
1278
|
+
if (left[index] !== right[index]) {
|
|
1279
|
+
return left[index] < right[index] ? -1 : 1;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
return left.length === right.length ? 0 : left.length < right.length ? -1 : 1;
|
|
1283
|
+
}
|
|
1284
|
+
function getArrowQueryValueType(value) {
|
|
1285
|
+
if (value instanceof Date) {
|
|
1286
|
+
return "Date";
|
|
1287
|
+
}
|
|
1288
|
+
if (value instanceof Uint8Array) {
|
|
1289
|
+
return "Uint8Array";
|
|
1290
|
+
}
|
|
1291
|
+
return typeof value;
|
|
1292
|
+
}
|
|
1293
|
+
function isLogicalPredicate(predicate) {
|
|
1294
|
+
return predicate.op === "and" || predicate.op === "or";
|
|
1295
|
+
}
|
|
1296
|
+
function isNotPredicate(predicate) {
|
|
1297
|
+
return predicate.op === "not";
|
|
1298
|
+
}
|
|
1299
|
+
function isNullPredicate(predicate) {
|
|
1300
|
+
return predicate.op === "isNull";
|
|
1301
|
+
}
|
|
1302
|
+
function isInPredicate(predicate) {
|
|
1303
|
+
return predicate.op === "in";
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// dist/scan/rows-to-arrow.js
|
|
1307
|
+
var arrow6 = __toESM(require("apache-arrow"), 1);
|
|
1308
|
+
function convertRowsToArrowTable(rows) {
|
|
1309
|
+
return arrow6.tableFromJSON(rows);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// dist/scan/sql-predicate-types.js
|
|
1313
|
+
function isSQLPredicateParameter(value) {
|
|
1314
|
+
return isColumnarPredicateParameter(value);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// dist/scan/sql-predicate-schema.js
|
|
1318
|
+
var MAXIMUM_PREDICATE_DEPTH = 64;
|
|
1319
|
+
var MAXIMUM_PREDICATE_NODES = 4096;
|
|
1320
|
+
function validateSQLPredicate(value) {
|
|
1321
|
+
const state = { nodes: 0 };
|
|
1322
|
+
validatePredicateNode(value, "$", 0, state);
|
|
1323
|
+
}
|
|
1324
|
+
function validatePredicateNode(value, path, depth, state) {
|
|
1325
|
+
if (depth > MAXIMUM_PREDICATE_DEPTH) {
|
|
1326
|
+
throw new Error(`SQL predicate ${path} exceeds the maximum nesting depth`);
|
|
1327
|
+
}
|
|
1328
|
+
state.nodes++;
|
|
1329
|
+
if (state.nodes > MAXIMUM_PREDICATE_NODES) {
|
|
1330
|
+
throw new Error("SQL predicate exceeds the maximum node count");
|
|
1331
|
+
}
|
|
1332
|
+
if (!isRecord(value) || !hasExactKeys(value, ["op", "args"])) {
|
|
1333
|
+
throw new Error(`SQL predicate ${path} must contain only op and args`);
|
|
1334
|
+
}
|
|
1335
|
+
if (typeof value.op !== "string" || !Array.isArray(value.args)) {
|
|
1336
|
+
throw new Error(`SQL predicate ${path} requires string op and array args`);
|
|
1337
|
+
}
|
|
1338
|
+
switch (value.op) {
|
|
1339
|
+
case "and":
|
|
1340
|
+
case "or":
|
|
1341
|
+
if (value.args.length < 2) {
|
|
1342
|
+
throw new Error(`SQL predicate ${path}.${value.op} requires at least two arguments`);
|
|
1343
|
+
}
|
|
1344
|
+
for (let index = 0; index < value.args.length; index++) {
|
|
1345
|
+
validatePredicateNode(value.args[index], `${path}.args[${index}]`, depth + 1, state);
|
|
1346
|
+
}
|
|
1347
|
+
return;
|
|
1348
|
+
case "not":
|
|
1349
|
+
if (value.args.length !== 1) {
|
|
1350
|
+
throw new Error(`SQL predicate ${path}.not requires exactly one argument`);
|
|
1351
|
+
}
|
|
1352
|
+
validatePredicateNode(value.args[0], `${path}.args[0]`, depth + 1, state);
|
|
1353
|
+
return;
|
|
1354
|
+
case "isNull":
|
|
1355
|
+
if (value.args.length !== 1) {
|
|
1356
|
+
throw new Error(`SQL predicate ${path}.isNull requires exactly one argument`);
|
|
1357
|
+
}
|
|
1358
|
+
validatePredicateProperty(value.args[0], `${path}.args[0]`);
|
|
1359
|
+
return;
|
|
1360
|
+
case "in":
|
|
1361
|
+
if (value.args.length !== 2 || !Array.isArray(value.args[1]) || value.args[1].length === 0) {
|
|
1362
|
+
throw new Error(`SQL predicate ${path}.in requires a property and non-empty value list`);
|
|
1363
|
+
}
|
|
1364
|
+
validatePredicateProperty(value.args[0], `${path}.args[0]`);
|
|
1365
|
+
value.args[1].forEach((item, index) => validatePredicateValue(item, `${path}.args[1][${index}]`));
|
|
1366
|
+
return;
|
|
1367
|
+
case "=":
|
|
1368
|
+
case "<>":
|
|
1369
|
+
case "<":
|
|
1370
|
+
case "<=":
|
|
1371
|
+
case ">":
|
|
1372
|
+
case ">=":
|
|
1373
|
+
if (value.args.length !== 2) {
|
|
1374
|
+
throw new Error(`SQL predicate ${path}.${value.op} requires exactly two arguments`);
|
|
1375
|
+
}
|
|
1376
|
+
validatePredicateProperty(value.args[0], `${path}.args[0]`);
|
|
1377
|
+
validatePredicateValue(value.args[1], `${path}.args[1]`);
|
|
1378
|
+
return;
|
|
1379
|
+
default:
|
|
1380
|
+
throw new Error(`SQL predicate ${path} has unsupported operator ${JSON.stringify(value.op)}`);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
function validatePredicateProperty(value, path) {
|
|
1384
|
+
if (!isRecord(value) || !hasAllowedKeys(value, ["property", "quoted"]) || typeof value.property !== "string" || value.property.length === 0 || value.quoted !== void 0 && typeof value.quoted !== "boolean") {
|
|
1385
|
+
throw new Error(`SQL predicate ${path} requires a non-empty property reference`);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
function validatePredicateValue(value, path) {
|
|
1389
|
+
if (isSQLPredicateParameter(value)) {
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
if (typeof value === "boolean" || typeof value === "bigint" || typeof value === "string" || value instanceof Uint8Array) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1398
|
+
if (value instanceof Date && Number.isFinite(value.getTime())) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
throw new Error(`SQL predicate ${path} contains an unsupported scalar value`);
|
|
1402
|
+
}
|
|
1403
|
+
function isRecord(value) {
|
|
1404
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1405
|
+
}
|
|
1406
|
+
function hasExactKeys(value, expectedKeys) {
|
|
1407
|
+
const keys = Object.keys(value);
|
|
1408
|
+
return keys.length === expectedKeys.length && expectedKeys.every((key) => keys.includes(key));
|
|
1409
|
+
}
|
|
1410
|
+
function hasAllowedKeys(value, allowedKeys) {
|
|
1411
|
+
return Object.keys(value).every((key) => allowedKeys.includes(key));
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// dist/scan/table-query.js
|
|
1415
|
+
function planTableQuery2(sourceColumnNames, options = {}) {
|
|
1416
|
+
if (options.predicate) {
|
|
1417
|
+
validateSQLPredicate(options.predicate);
|
|
1418
|
+
}
|
|
1419
|
+
return planTableQuery(sourceColumnNames, options);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// dist/scan/query-arrow-table.js
|
|
1423
|
+
function queryArrowTable(sourceTable, options = {}) {
|
|
1424
|
+
var _a, _b;
|
|
1425
|
+
throwIfAborted(options.signal);
|
|
1426
|
+
if (options.select !== void 0) {
|
|
1427
|
+
if (options.columns !== void 0 || hasRelationalOperators(options) || options.join) {
|
|
1428
|
+
throw new Error("Arrow select cannot be combined with columns or relational operators.");
|
|
1429
|
+
}
|
|
1430
|
+
projectArrowTable(sourceTable, options.select);
|
|
1431
|
+
const columns = [
|
|
1432
|
+
...new Set(options.select.map((selection) => typeof selection === "string" ? selection : selection.column))
|
|
1433
|
+
];
|
|
1434
|
+
const { select, ...remainingOptions } = options;
|
|
1435
|
+
const result = queryArrowTable(sourceTable, { ...remainingOptions, columns });
|
|
1436
|
+
return projectArrowTable(result, select);
|
|
1437
|
+
}
|
|
1438
|
+
if (options.join) {
|
|
1439
|
+
validateArrowJoinQuery(sourceTable, options);
|
|
1440
|
+
}
|
|
1441
|
+
if (options.join && hasRelationalOperatorsExceptJoin(options)) {
|
|
1442
|
+
throw new Error("Arrow joins cannot yet be combined with other relational operators.");
|
|
1443
|
+
}
|
|
1444
|
+
if (options.join && !hasRelationalOperatorsExceptJoin(options)) {
|
|
1445
|
+
return queryArrowJoin(sourceTable, options);
|
|
1446
|
+
}
|
|
1447
|
+
if (hasRelationalOperators(options)) {
|
|
1448
|
+
return queryArrowTableRelational(sourceTable, options);
|
|
1449
|
+
}
|
|
1450
|
+
const sourceData = sourceTable;
|
|
1451
|
+
const plan = planTableQuery2(sourceData.schema.fields.map((field) => field.name), options);
|
|
1452
|
+
const scannedData = sourceData.select([...getScanStep(plan).columns]);
|
|
1453
|
+
const predicate = (_a = getFilterStep(plan)) == null ? void 0 : _a.predicate;
|
|
1454
|
+
const limit = ((_b = getLimitStep(plan)) == null ? void 0 : _b.limit) ?? Number.POSITIVE_INFINITY;
|
|
1455
|
+
if (!predicate) {
|
|
1456
|
+
const projectedData = projectArrowTable(scannedData, getProjectStep(plan).columns);
|
|
1457
|
+
return projectedData.numRows === 0 ? projectedData : projectedData.slice(0, limit);
|
|
1458
|
+
}
|
|
1459
|
+
const filteredData = filterArrowTable(scannedData, predicate, { limit, signal: options.signal });
|
|
1460
|
+
return projectArrowTable(filteredData, getProjectStep(plan).columns);
|
|
1461
|
+
}
|
|
1462
|
+
function queryArrowTableRelational(sourceTable, options) {
|
|
1463
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1464
|
+
const sourceData = sourceTable;
|
|
1465
|
+
const sourceColumnNames = sourceData.schema.fields.map((field) => field.name);
|
|
1466
|
+
const relationalPlan = planRelationalQuery(sourceColumnNames, options);
|
|
1467
|
+
const scanStep = relationalPlan.tablePlan.find((step) => step.kind === "scan");
|
|
1468
|
+
if (!scanStep || scanStep.kind !== "scan") {
|
|
1469
|
+
throw new Error("Arrow relational query plan is missing a scan step.");
|
|
1470
|
+
}
|
|
1471
|
+
const scannedTable = sourceData.select([...scanStep.columns]);
|
|
1472
|
+
const filteredTable = queryArrowTable(scannedTable, {
|
|
1473
|
+
predicate: options.predicate,
|
|
1474
|
+
columns: scanStep.columns,
|
|
1475
|
+
signal: options.signal
|
|
1476
|
+
});
|
|
1477
|
+
let rows = arrowTableToRows(filteredTable);
|
|
1478
|
+
for (const child of options.union || []) {
|
|
1479
|
+
const childTable = (_a = options.tables) == null ? void 0 : _a[child.source];
|
|
1480
|
+
if (!childTable)
|
|
1481
|
+
throw new Error(`Arrow union source not found: ${child.source}`);
|
|
1482
|
+
const childResult = queryArrowTable(childTable, {
|
|
1483
|
+
...child.query || {},
|
|
1484
|
+
columns: getUnionChildColumns(sourceColumnNames, options),
|
|
1485
|
+
signal: options.signal
|
|
1486
|
+
});
|
|
1487
|
+
rows = rows.concat(arrowTableToRows(childResult));
|
|
1488
|
+
}
|
|
1489
|
+
for (const expression of options.expressions || []) {
|
|
1490
|
+
for (const row of rows) {
|
|
1491
|
+
row[expression.name] = evaluateRelationalExpression(expression, row);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
if (((_b = options.groupBy) == null ? void 0 : _b.length) || ((_c = options.aggregates) == null ? void 0 : _c.length)) {
|
|
1495
|
+
rows = aggregateRows(rows, options.groupBy || [], options.aggregates || []);
|
|
1496
|
+
}
|
|
1497
|
+
if ((_d = options.orderBy) == null ? void 0 : _d.length) {
|
|
1498
|
+
const orderBy = options.orderBy;
|
|
1499
|
+
rows = rows.map((row, index) => ({ row, index })).sort((left, right) => compareRows(left.row, right.row, orderBy) || left.index - right.index).map((entry) => entry.row);
|
|
1500
|
+
}
|
|
1501
|
+
const outputColumns = options.columns || (((_e = options.groupBy) == null ? void 0 : _e.length) || ((_f = options.aggregates) == null ? void 0 : _f.length) ? [...options.groupBy || [], ...(options.aggregates || []).map((aggregate) => aggregate.name)] : sourceColumnNames);
|
|
1502
|
+
const outputRows = rows.map((row) => {
|
|
1503
|
+
const output = {};
|
|
1504
|
+
for (const columnName of outputColumns) {
|
|
1505
|
+
if (!(columnName in row)) {
|
|
1506
|
+
throw new Error(`Arrow relational query column not found: ${columnName}`);
|
|
1507
|
+
}
|
|
1508
|
+
output[columnName] = row[columnName];
|
|
1509
|
+
}
|
|
1510
|
+
return output;
|
|
1511
|
+
});
|
|
1512
|
+
const limit = options.limit === void 0 ? outputRows.length : options.limit;
|
|
1513
|
+
const limitedRows = outputRows.slice(0, limit);
|
|
1514
|
+
return limitedRows.length ? convertRowsToArrowTable(limitedRows) : createEmptyRelationalResult(sourceData, outputColumns, options);
|
|
1515
|
+
}
|
|
1516
|
+
function getUnionChildColumns(sourceColumnNames, options) {
|
|
1517
|
+
var _a, _b;
|
|
1518
|
+
const expressionNames = new Set((options.expressions || []).map((expression) => expression.name));
|
|
1519
|
+
const aggregateNames = new Set((options.aggregates || []).map((aggregate) => aggregate.name));
|
|
1520
|
+
const outputColumns = options.columns || (((_a = options.groupBy) == null ? void 0 : _a.length) || ((_b = options.aggregates) == null ? void 0 : _b.length) ? [...options.groupBy || [], ...(options.aggregates || []).map((aggregate) => aggregate.name)] : sourceColumnNames);
|
|
1521
|
+
const requiredColumns = new Set(outputColumns.filter((column) => !expressionNames.has(column) && !aggregateNames.has(column)));
|
|
1522
|
+
for (const expression of options.expressions || []) {
|
|
1523
|
+
const definition = expression.expression;
|
|
1524
|
+
if (definition.op === "column")
|
|
1525
|
+
requiredColumns.add(definition.column);
|
|
1526
|
+
if ("left" in definition) {
|
|
1527
|
+
requiredColumns.add(definition.left);
|
|
1528
|
+
requiredColumns.add(definition.right);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
for (const key of options.orderBy || []) {
|
|
1532
|
+
if (!expressionNames.has(key.column) && !aggregateNames.has(key.column)) {
|
|
1533
|
+
requiredColumns.add(key.column);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
for (const column of options.groupBy || [])
|
|
1537
|
+
requiredColumns.add(column);
|
|
1538
|
+
for (const aggregate of options.aggregates || []) {
|
|
1539
|
+
if (aggregate.column)
|
|
1540
|
+
requiredColumns.add(aggregate.column);
|
|
1541
|
+
}
|
|
1542
|
+
return sourceColumnNames.filter((column) => requiredColumns.has(column));
|
|
1543
|
+
}
|
|
1544
|
+
function hasRelationalOperators(options) {
|
|
1545
|
+
var _a, _b, _c, _d, _e;
|
|
1546
|
+
return Boolean(((_a = options.expressions) == null ? void 0 : _a.length) || ((_b = options.orderBy) == null ? void 0 : _b.length) || ((_c = options.groupBy) == null ? void 0 : _c.length) || ((_d = options.aggregates) == null ? void 0 : _d.length) || ((_e = options.union) == null ? void 0 : _e.length) || options.join);
|
|
1547
|
+
}
|
|
1548
|
+
function hasRelationalOperatorsExceptJoin(options) {
|
|
1549
|
+
var _a, _b, _c, _d, _e;
|
|
1550
|
+
return Boolean(((_a = options.expressions) == null ? void 0 : _a.length) || ((_b = options.orderBy) == null ? void 0 : _b.length) || ((_c = options.groupBy) == null ? void 0 : _c.length) || ((_d = options.aggregates) == null ? void 0 : _d.length) || ((_e = options.union) == null ? void 0 : _e.length));
|
|
1551
|
+
}
|
|
1552
|
+
function queryArrowJoin(sourceTable, options) {
|
|
1553
|
+
var _a;
|
|
1554
|
+
const join = options.join;
|
|
1555
|
+
if (!join)
|
|
1556
|
+
throw new Error("Arrow join query is missing a join definition.");
|
|
1557
|
+
const childTable = (_a = options.tables) == null ? void 0 : _a[join.child.source];
|
|
1558
|
+
if (!childTable)
|
|
1559
|
+
throw new Error(`Arrow join source not found: ${join.child.source}`);
|
|
1560
|
+
const leftResult = queryArrowTable(sourceTable, {
|
|
1561
|
+
predicate: options.predicate,
|
|
1562
|
+
columns: void 0,
|
|
1563
|
+
signal: options.signal
|
|
1564
|
+
});
|
|
1565
|
+
const rightResult = queryArrowTable(childTable, {
|
|
1566
|
+
...join.child.query || {},
|
|
1567
|
+
signal: options.signal
|
|
1568
|
+
});
|
|
1569
|
+
const leftRows = arrowTableToRows(leftResult);
|
|
1570
|
+
const rightRows = arrowTableToRows(rightResult);
|
|
1571
|
+
const rightPrefix = `${join.child.source}.`;
|
|
1572
|
+
const defaultOutputColumns = [
|
|
1573
|
+
...sourceTable.schema.fields.map((field) => field.name),
|
|
1574
|
+
...rightResult.schema.fields.map((field) => `${rightPrefix}${field.name}`)
|
|
1575
|
+
];
|
|
1576
|
+
const rows = [];
|
|
1577
|
+
for (const leftRow of leftRows) {
|
|
1578
|
+
for (const rightRow of rightRows) {
|
|
1579
|
+
if (leftRow[join.left] !== null && leftRow[join.left] !== void 0 && rightRow[join.right] !== null && rightRow[join.right] !== void 0 && compareSortValues(leftRow[join.left], rightRow[join.right]) === 0) {
|
|
1580
|
+
rows.push({
|
|
1581
|
+
...leftRow,
|
|
1582
|
+
...Object.fromEntries(Object.entries(rightRow).map(([key, value]) => [`${rightPrefix}${key}`, value]))
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
const outputColumns = options.columns || defaultOutputColumns;
|
|
1588
|
+
const outputRows = rows.map((row) => Object.fromEntries(outputColumns.map((column) => [column, row[column]])));
|
|
1589
|
+
const limitedRows = outputRows.slice(0, options.limit);
|
|
1590
|
+
return limitedRows.length ? convertRowsToArrowTable(limitedRows) : createEmptyRelationalResult(sourceTable, outputColumns, options, new Map(rightResult.schema.fields.map((field) => [
|
|
1591
|
+
`${rightPrefix}${field.name}`,
|
|
1592
|
+
new arrow7.Field(`${rightPrefix}${field.name}`, field.type, field.nullable, field.metadata)
|
|
1593
|
+
])));
|
|
1594
|
+
}
|
|
1595
|
+
function validateArrowJoinQuery(sourceTable, options) {
|
|
1596
|
+
var _a, _b, _c;
|
|
1597
|
+
const join = options.join;
|
|
1598
|
+
if (!join)
|
|
1599
|
+
return;
|
|
1600
|
+
const sourceColumnNames = sourceTable.schema.fields.map((field) => field.name);
|
|
1601
|
+
const childTable = (_a = options.tables) == null ? void 0 : _a[join.child.source];
|
|
1602
|
+
if (!childTable)
|
|
1603
|
+
throw new Error(`Arrow join source not found: ${join.child.source}`);
|
|
1604
|
+
const childColumnNames = childTable.schema.fields.map((field) => field.name);
|
|
1605
|
+
if (!sourceColumnNames.includes(join.left)) {
|
|
1606
|
+
throw new Error(`Arrow join column not found: ${join.left}`);
|
|
1607
|
+
}
|
|
1608
|
+
if (!childColumnNames.includes(join.right)) {
|
|
1609
|
+
throw new Error(`Arrow join column not found: ${join.right}`);
|
|
1610
|
+
}
|
|
1611
|
+
const childPrefix = `${join.child.source}.`;
|
|
1612
|
+
const rootColumns = (_b = options.columns) == null ? void 0 : _b.filter((column) => !column.startsWith(childPrefix));
|
|
1613
|
+
planTableQuery2(sourceColumnNames, {
|
|
1614
|
+
predicate: options.predicate,
|
|
1615
|
+
columns: (rootColumns == null ? void 0 : rootColumns.length) ? rootColumns : void 0,
|
|
1616
|
+
limit: options.limit,
|
|
1617
|
+
signal: options.signal
|
|
1618
|
+
});
|
|
1619
|
+
const childQuery = join.child.query || {};
|
|
1620
|
+
planTableQuery2(childColumnNames, childQuery);
|
|
1621
|
+
const childOutputColumns = childQuery.columns || childColumnNames;
|
|
1622
|
+
if (!childOutputColumns.includes(join.right)) {
|
|
1623
|
+
throw new Error(`Arrow join child projection must include: ${join.right}`);
|
|
1624
|
+
}
|
|
1625
|
+
const projectedChildColumns = ((_c = options.columns) == null ? void 0 : _c.filter((column) => column.startsWith(childPrefix))) || [];
|
|
1626
|
+
const seenChildColumns = /* @__PURE__ */ new Set();
|
|
1627
|
+
for (const projectedColumn of projectedChildColumns) {
|
|
1628
|
+
const childColumn = projectedColumn.slice(childPrefix.length);
|
|
1629
|
+
if (!childColumnNames.includes(childColumn)) {
|
|
1630
|
+
throw new Error(`Arrow join column not found: ${projectedColumn}`);
|
|
1631
|
+
}
|
|
1632
|
+
if (seenChildColumns.has(childColumn)) {
|
|
1633
|
+
throw new Error(`Arrow query column was selected more than once: ${projectedColumn}`);
|
|
1634
|
+
}
|
|
1635
|
+
seenChildColumns.add(childColumn);
|
|
1636
|
+
if (!childOutputColumns.includes(childColumn)) {
|
|
1637
|
+
throw new Error(`Arrow join child projection does not include: ${childColumn}`);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
function arrowTableToRows(data) {
|
|
1642
|
+
const columns = data.schema.fields.map((field) => ({
|
|
1643
|
+
name: field.name,
|
|
1644
|
+
vector: data.getChild(field.name)
|
|
1645
|
+
}));
|
|
1646
|
+
return Array.from({ length: data.numRows }, (_, rowIndex) => {
|
|
1647
|
+
const row = {};
|
|
1648
|
+
for (const column of columns) {
|
|
1649
|
+
if (!column.vector)
|
|
1650
|
+
throw new Error(`Arrow relational query could not read ${column.name}`);
|
|
1651
|
+
row[column.name] = column.vector.get(rowIndex);
|
|
1652
|
+
}
|
|
1653
|
+
return row;
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
function evaluateRelationalExpression(expression, row) {
|
|
1657
|
+
const definition = expression.expression;
|
|
1658
|
+
if (definition.op === "literal")
|
|
1659
|
+
return definition.value;
|
|
1660
|
+
if (definition.op === "column")
|
|
1661
|
+
return row[definition.column];
|
|
1662
|
+
const left = row[definition.left];
|
|
1663
|
+
const right = row[definition.right];
|
|
1664
|
+
if (left === null || left === void 0 || right === null || right === void 0)
|
|
1665
|
+
return null;
|
|
1666
|
+
if (typeof left !== "number" || typeof right !== "number") {
|
|
1667
|
+
throw new Error(`Arrow relational expression ${expression.name} requires numeric operands.`);
|
|
1668
|
+
}
|
|
1669
|
+
switch (definition.op) {
|
|
1670
|
+
case "add":
|
|
1671
|
+
return left + right;
|
|
1672
|
+
case "subtract":
|
|
1673
|
+
return left - right;
|
|
1674
|
+
case "multiply":
|
|
1675
|
+
return left * right;
|
|
1676
|
+
case "divide":
|
|
1677
|
+
return right === 0 ? null : left / right;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
function compareRows(left, right, orderBy) {
|
|
1681
|
+
for (const key of orderBy) {
|
|
1682
|
+
const leftValue = left[key.column];
|
|
1683
|
+
const rightValue = right[key.column];
|
|
1684
|
+
const nulls = key.nulls || "last";
|
|
1685
|
+
if (leftValue === null || leftValue === void 0 || rightValue === null || rightValue === void 0) {
|
|
1686
|
+
if (leftValue === rightValue)
|
|
1687
|
+
continue;
|
|
1688
|
+
const nullResult = leftValue === null || leftValue === void 0 ? -1 : 1;
|
|
1689
|
+
return nulls === "first" ? nullResult : -nullResult;
|
|
1690
|
+
}
|
|
1691
|
+
const result = compareSortValues(leftValue, rightValue);
|
|
1692
|
+
if (result)
|
|
1693
|
+
return (key.direction === "desc" ? -1 : 1) * result;
|
|
1694
|
+
}
|
|
1695
|
+
return 0;
|
|
1696
|
+
}
|
|
1697
|
+
function compareSortValues(left, right) {
|
|
1698
|
+
if (left instanceof Date && right instanceof Date)
|
|
1699
|
+
return compareArrowQueryNumbers(left.getTime(), right.getTime());
|
|
1700
|
+
if (typeof left === "bigint" && typeof right === "bigint")
|
|
1701
|
+
return left === right ? 0 : left < right ? -1 : 1;
|
|
1702
|
+
if (typeof left === "number" && typeof right === "number")
|
|
1703
|
+
return compareArrowQueryNumbers(left, right);
|
|
1704
|
+
if (typeof left === "string" && typeof right === "string")
|
|
1705
|
+
return left === right ? 0 : left < right ? -1 : 1;
|
|
1706
|
+
if (typeof left === "boolean" && typeof right === "boolean")
|
|
1707
|
+
return Number(left) - Number(right);
|
|
1708
|
+
throw new Error(`Arrow relational order cannot compare ${getArrowQueryValueType(left)} with ${getArrowQueryValueType(right)}.`);
|
|
1709
|
+
}
|
|
1710
|
+
function aggregateRows(rows, groupBy, aggregates) {
|
|
1711
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1712
|
+
for (const row of rows) {
|
|
1713
|
+
const key = serializeGroupKey(groupBy.map((column) => row[column]));
|
|
1714
|
+
const group = groups.get(key) || [];
|
|
1715
|
+
group.push(row);
|
|
1716
|
+
groups.set(key, group);
|
|
1717
|
+
}
|
|
1718
|
+
if (!groupBy.length && !rows.length)
|
|
1719
|
+
groups.set("[]", []);
|
|
1720
|
+
return [...groups.values()].map((group) => {
|
|
1721
|
+
var _a;
|
|
1722
|
+
const output = {};
|
|
1723
|
+
for (const column of groupBy)
|
|
1724
|
+
output[column] = ((_a = group[0]) == null ? void 0 : _a[column]) ?? null;
|
|
1725
|
+
for (const aggregate of aggregates)
|
|
1726
|
+
output[aggregate.name] = evaluateAggregate(aggregate, group);
|
|
1727
|
+
return output;
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
function serializeGroupKey(values) {
|
|
1731
|
+
return values.map((value) => {
|
|
1732
|
+
if (value === null || value === void 0)
|
|
1733
|
+
return "null:";
|
|
1734
|
+
if (value instanceof Date)
|
|
1735
|
+
return `date:${value.getTime()}`;
|
|
1736
|
+
if (value instanceof Uint8Array)
|
|
1737
|
+
return `bytes:${Array.from(value).join(".")}`;
|
|
1738
|
+
return `${typeof value}:${String(value)}`;
|
|
1739
|
+
}).join("");
|
|
1740
|
+
}
|
|
1741
|
+
function createEmptyRelationalResult(sourceData, outputColumns, options, additionalFields) {
|
|
1742
|
+
const sourceFields = new Map(sourceData.schema.fields.map((field) => [field.name, field]));
|
|
1743
|
+
const expressions = new Map((options.expressions || []).map((expression) => [expression.name, expression]));
|
|
1744
|
+
const aggregates = new Map((options.aggregates || []).map((aggregate) => [aggregate.name, aggregate]));
|
|
1745
|
+
const fields = outputColumns.map((columnName) => {
|
|
1746
|
+
const sourceField = sourceFields.get(columnName);
|
|
1747
|
+
if (sourceField)
|
|
1748
|
+
return sourceField;
|
|
1749
|
+
const additionalField = additionalFields == null ? void 0 : additionalFields.get(columnName);
|
|
1750
|
+
if (additionalField)
|
|
1751
|
+
return additionalField;
|
|
1752
|
+
const expression = expressions.get(columnName);
|
|
1753
|
+
if (expression)
|
|
1754
|
+
return new arrow7.Field(columnName, getExpressionType(expression, sourceFields), true);
|
|
1755
|
+
const aggregate = aggregates.get(columnName);
|
|
1756
|
+
if (aggregate)
|
|
1757
|
+
return new arrow7.Field(columnName, getAggregateType(aggregate, sourceFields), true);
|
|
1758
|
+
return new arrow7.Field(columnName, new arrow7.Utf8(), true);
|
|
1759
|
+
});
|
|
1760
|
+
const columns = {};
|
|
1761
|
+
for (const field of fields)
|
|
1762
|
+
columns[field.name] = arrow7.vectorFromArray([], field.type);
|
|
1763
|
+
return new arrow7.Table(new arrow7.Schema(fields), columns);
|
|
1764
|
+
}
|
|
1765
|
+
function getExpressionType(expression, sourceFields) {
|
|
1766
|
+
var _a;
|
|
1767
|
+
if (expression.expression.op === "literal") {
|
|
1768
|
+
const value = expression.expression.value;
|
|
1769
|
+
if (typeof value === "boolean")
|
|
1770
|
+
return new arrow7.Bool();
|
|
1771
|
+
if (typeof value === "number")
|
|
1772
|
+
return new arrow7.Float64();
|
|
1773
|
+
return new arrow7.Utf8();
|
|
1774
|
+
}
|
|
1775
|
+
if (expression.expression.op === "column") {
|
|
1776
|
+
return ((_a = sourceFields.get(expression.expression.column)) == null ? void 0 : _a.type) || new arrow7.Utf8();
|
|
1777
|
+
}
|
|
1778
|
+
return new arrow7.Float64();
|
|
1779
|
+
}
|
|
1780
|
+
function getAggregateType(aggregate, sourceFields) {
|
|
1781
|
+
var _a;
|
|
1782
|
+
if (aggregate.function === "count")
|
|
1783
|
+
return new arrow7.Int32();
|
|
1784
|
+
return aggregate.column ? ((_a = sourceFields.get(aggregate.column)) == null ? void 0 : _a.type) || new arrow7.Float64() : new arrow7.Float64();
|
|
1785
|
+
}
|
|
1786
|
+
function evaluateAggregate(aggregate, rows) {
|
|
1787
|
+
if (aggregate.function === "count")
|
|
1788
|
+
return aggregate.column ? rows.filter((row) => row[aggregate.column] != null).length : rows.length;
|
|
1789
|
+
const values = rows.map((row) => row[aggregate.column]).filter((value) => value != null);
|
|
1790
|
+
if (!values.length)
|
|
1791
|
+
return null;
|
|
1792
|
+
if (!values.every((value) => typeof value === "number"))
|
|
1793
|
+
throw new Error(`Arrow aggregate ${aggregate.function} requires numeric values.`);
|
|
1794
|
+
const numericValues = values;
|
|
1795
|
+
switch (aggregate.function) {
|
|
1796
|
+
case "sum":
|
|
1797
|
+
return numericValues.reduce((sum, value) => sum + value, 0);
|
|
1798
|
+
case "avg":
|
|
1799
|
+
return numericValues.reduce((sum, value) => sum + value, 0) / numericValues.length;
|
|
1800
|
+
case "min":
|
|
1801
|
+
return Math.min(...numericValues);
|
|
1802
|
+
case "max":
|
|
1803
|
+
return Math.max(...numericValues);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
function getScanStep(plan) {
|
|
1807
|
+
const step = plan.find((candidate) => candidate.kind === "scan");
|
|
1808
|
+
if (!step) {
|
|
1809
|
+
throw new Error("Arrow query plan is missing a scan step.");
|
|
1810
|
+
}
|
|
1811
|
+
return step;
|
|
1812
|
+
}
|
|
1813
|
+
function getFilterStep(plan) {
|
|
1814
|
+
return plan.find((candidate) => candidate.kind === "filter");
|
|
1815
|
+
}
|
|
1816
|
+
function getProjectStep(plan) {
|
|
1817
|
+
const step = plan.find((candidate) => candidate.kind === "project");
|
|
1818
|
+
if (!step) {
|
|
1819
|
+
throw new Error("Arrow query plan is missing a project step.");
|
|
1820
|
+
}
|
|
1821
|
+
return step;
|
|
1822
|
+
}
|
|
1823
|
+
function getLimitStep(plan) {
|
|
1824
|
+
return plan.find((candidate) => candidate.kind === "limit");
|
|
1825
|
+
}
|
|
1826
|
+
function throwIfAborted(signal) {
|
|
1827
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
1828
|
+
const error = new Error("Arrow query was aborted.");
|
|
1829
|
+
error.name = "AbortError";
|
|
1830
|
+
throw error;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
// dist/scan/federated-table-scan-source.js
|
|
1835
|
+
function getFederatedTableBatchProvenance(batch) {
|
|
1836
|
+
return JSON.parse(batch.metadata.get("loaders.gl.federation"));
|
|
1837
|
+
}
|
|
1838
|
+
var FEDERATED_TABLE_QUERY_CAPABILITIES = Object.freeze({
|
|
1839
|
+
predicate: "residual",
|
|
1840
|
+
projection: "pushdown+residual",
|
|
1841
|
+
limit: "pushdown+residual",
|
|
1842
|
+
streaming: true,
|
|
1843
|
+
cancellation: true
|
|
1844
|
+
});
|
|
1845
|
+
var nextFederatedSourceId = 0;
|
|
1846
|
+
var FederatedTableScanSource = class {
|
|
1847
|
+
/** Shared manager used as the authoritative named-source registry. */
|
|
1848
|
+
dataSourceManager;
|
|
1849
|
+
/** Immutable sources in physical append order. */
|
|
1850
|
+
sources;
|
|
1851
|
+
/** Schema reconciliation policy. */
|
|
1852
|
+
schemaPolicy;
|
|
1853
|
+
/** Optional caller-declared normalized output schema. */
|
|
1854
|
+
outputSchema;
|
|
1855
|
+
/** Optional display name reported through scan metadata. */
|
|
1856
|
+
name;
|
|
1857
|
+
/** Human-readable description reported through scan metadata. */
|
|
1858
|
+
description;
|
|
1859
|
+
/** Stable id used to isolate this adapter's manager subscriptions. */
|
|
1860
|
+
instanceId = nextFederatedSourceId++;
|
|
1861
|
+
/** Monotonic id used to isolate overlapping operations on this adapter. */
|
|
1862
|
+
nextOperationId = 0;
|
|
1863
|
+
/** Creates an ordered federated source backed by one shared DataSourceManager. */
|
|
1864
|
+
constructor(dataSourceManager, options) {
|
|
1865
|
+
if (!options.sources.length) {
|
|
1866
|
+
throw new Error("Federated scans require at least one source.");
|
|
1867
|
+
}
|
|
1868
|
+
if (options.schemaPolicy && options.schemaPolicy !== "strict" && options.schemaPolicy !== "union") {
|
|
1869
|
+
throw new Error(`Unsupported federated schema policy: ${options.schemaPolicy}`);
|
|
1870
|
+
}
|
|
1871
|
+
this.dataSourceManager = dataSourceManager;
|
|
1872
|
+
this.sources = Object.freeze(options.sources.map(cloneSourceEntry));
|
|
1873
|
+
this.schemaPolicy = options.schemaPolicy || "strict";
|
|
1874
|
+
this.outputSchema = options.outputSchema ? cloneSchema(options.outputSchema) : void 0;
|
|
1875
|
+
this.name = options.name;
|
|
1876
|
+
this.description = options.description || `${this.sources.length} ordered table sources`;
|
|
1877
|
+
}
|
|
1878
|
+
/** Discovers and reconciles every child schema without reading federated result batches. */
|
|
1879
|
+
async getQueryMetadata(options = {}) {
|
|
1880
|
+
const consumerId = this.createConsumerId("metadata");
|
|
1881
|
+
try {
|
|
1882
|
+
const plan = await this.resolvePlan(consumerId, options.signal);
|
|
1883
|
+
return createScanQueryMetadata({
|
|
1884
|
+
sourceType: "federated-table",
|
|
1885
|
+
queryType: "table",
|
|
1886
|
+
execution: { status: "supported", method: "read" },
|
|
1887
|
+
name: this.name,
|
|
1888
|
+
description: this.description,
|
|
1889
|
+
schema: plan.schema,
|
|
1890
|
+
capabilities: { table: FEDERATED_TABLE_QUERY_CAPABILITIES },
|
|
1891
|
+
statistics: getFederatedStatistics(plan.sources)
|
|
1892
|
+
});
|
|
1893
|
+
} finally {
|
|
1894
|
+
this.dataSourceManager.unsubscribe({ consumerId });
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
/** Explains source resolution, schema reconciliation, and the global table query. */
|
|
1898
|
+
async explain(options = {}) {
|
|
1899
|
+
const consumerId = this.createConsumerId("explain");
|
|
1900
|
+
try {
|
|
1901
|
+
const plan = await this.resolvePlan(consumerId, options.signal);
|
|
1902
|
+
const explanation = explainTableQuery(plan.schema.fields.map((field) => field.name), options, FEDERATED_TABLE_QUERY_CAPABILITIES);
|
|
1903
|
+
return Object.freeze({
|
|
1904
|
+
...explanation,
|
|
1905
|
+
schemaPolicy: this.schemaPolicy,
|
|
1906
|
+
sources: Object.freeze(plan.sources.map((source) => createSourceExplanation(source, plan.schema)))
|
|
1907
|
+
});
|
|
1908
|
+
} finally {
|
|
1909
|
+
this.dataSourceManager.unsubscribe({ consumerId });
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Emits source and batch ordered Arrow results with one global limit and batch provenance.
|
|
1914
|
+
*
|
|
1915
|
+
* Returning early from the iterator closes the active child iterator and releases every manager
|
|
1916
|
+
* subscription. Later sources are never read once the global limit has been satisfied.
|
|
1917
|
+
*/
|
|
1918
|
+
async *read(options = {}) {
|
|
1919
|
+
var _a, _b;
|
|
1920
|
+
const consumerId = this.createConsumerId("read");
|
|
1921
|
+
const startedAt = Date.now();
|
|
1922
|
+
const telemetry = {
|
|
1923
|
+
status: "early-terminated",
|
|
1924
|
+
sourcesPlanned: this.sources.length,
|
|
1925
|
+
sourcesRead: 0,
|
|
1926
|
+
batchesRead: 0,
|
|
1927
|
+
rowsRead: 0,
|
|
1928
|
+
rowsTested: 0,
|
|
1929
|
+
rowsRetained: 0,
|
|
1930
|
+
rowsReturned: 0,
|
|
1931
|
+
bytesFetched: 0,
|
|
1932
|
+
filesOpened: 0,
|
|
1933
|
+
tasksOpened: 0,
|
|
1934
|
+
rowsPruned: 0,
|
|
1935
|
+
durationMilliseconds: 0,
|
|
1936
|
+
sources: []
|
|
1937
|
+
};
|
|
1938
|
+
try {
|
|
1939
|
+
const plan = await this.resolvePlan(consumerId, options.signal);
|
|
1940
|
+
const scanStep = planTableQuery(plan.schema.fields.map((field) => field.name), options)[0];
|
|
1941
|
+
let remaining = options.limit ?? Number.POSITIVE_INFINITY;
|
|
1942
|
+
if (remaining <= 0) {
|
|
1943
|
+
telemetry.earlyTerminationReason = "limit";
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1946
|
+
for (const resolvedSource of plan.sources) {
|
|
1947
|
+
throwIfAborted2(options.signal);
|
|
1948
|
+
if (remaining <= 0) {
|
|
1949
|
+
telemetry.earlyTerminationReason = "limit";
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
const sourceStartedAt = Date.now();
|
|
1953
|
+
let childTelemetry;
|
|
1954
|
+
let sourceCompleted = false;
|
|
1955
|
+
let sourceError;
|
|
1956
|
+
let sourceBatchesDecoded = 0;
|
|
1957
|
+
let sourceRowsRead = 0;
|
|
1958
|
+
let sourceRowsTested = 0;
|
|
1959
|
+
let sourceRowsRetained = 0;
|
|
1960
|
+
let sourceRowsReturned = 0;
|
|
1961
|
+
const sourceReadOptions = createSourceReadOptions(resolvedSource, scanStep.columns, remaining, options, (value) => {
|
|
1962
|
+
childTelemetry = value;
|
|
1963
|
+
});
|
|
1964
|
+
const sourceResidualPredicate = getSourceResidualPredicate(resolvedSource);
|
|
1965
|
+
let sourceRemaining = ((_a = resolvedSource.entry.query) == null ? void 0 : _a.limit) ?? Number.POSITIVE_INFINITY;
|
|
1966
|
+
telemetry.sourcesRead++;
|
|
1967
|
+
let sourceBatchIndex = 0;
|
|
1968
|
+
try {
|
|
1969
|
+
for await (const input of resolvedSource.source.read(sourceReadOptions)) {
|
|
1970
|
+
const batch = "shape" in input ? input : makeTableScanBatch({
|
|
1971
|
+
shape: "arrow-table",
|
|
1972
|
+
data: new arrow8.Table(input.schema, [input])
|
|
1973
|
+
});
|
|
1974
|
+
throwIfAborted2(options.signal);
|
|
1975
|
+
if (remaining <= 0) {
|
|
1976
|
+
telemetry.earlyTerminationReason = "limit";
|
|
1977
|
+
return;
|
|
1978
|
+
}
|
|
1979
|
+
if (sourceRemaining <= 0)
|
|
1980
|
+
break;
|
|
1981
|
+
if (batch.batchType !== "data")
|
|
1982
|
+
continue;
|
|
1983
|
+
telemetry.batchesRead++;
|
|
1984
|
+
telemetry.rowsRead += batch.length;
|
|
1985
|
+
sourceBatchesDecoded++;
|
|
1986
|
+
sourceRowsRead += batch.length;
|
|
1987
|
+
if (batch.length <= 0)
|
|
1988
|
+
continue;
|
|
1989
|
+
const physicalTable = convertTableToArrow2(batch.schema ? batch : { ...batch, schema: resolvedSource.metadata.schema });
|
|
1990
|
+
const sourceResult = queryArrowTable(physicalTable, {
|
|
1991
|
+
predicate: sourceResidualPredicate,
|
|
1992
|
+
limit: Number.isFinite(sourceRemaining) ? sourceRemaining : void 0,
|
|
1993
|
+
signal: options.signal
|
|
1994
|
+
});
|
|
1995
|
+
if (sourceResidualPredicate) {
|
|
1996
|
+
sourceRowsTested += physicalTable.numRows;
|
|
1997
|
+
sourceRowsRetained += sourceResult.numRows;
|
|
1998
|
+
}
|
|
1999
|
+
sourceRemaining -= sourceResult.numRows;
|
|
2000
|
+
const currentSourceBatchIndex = sourceBatchIndex++;
|
|
2001
|
+
if (!sourceResult.numRows)
|
|
2002
|
+
continue;
|
|
2003
|
+
const canonicalTable = createCanonicalArrowTable(plan.schema, resolvedSource, sourceResult);
|
|
2004
|
+
const result = queryArrowTable(canonicalTable, {
|
|
2005
|
+
predicate: options.predicate,
|
|
2006
|
+
columns: options.columns,
|
|
2007
|
+
limit: Number.isFinite(remaining) ? remaining : void 0,
|
|
2008
|
+
signal: options.signal
|
|
2009
|
+
});
|
|
2010
|
+
if (options.predicate) {
|
|
2011
|
+
telemetry.rowsTested += canonicalTable.numRows;
|
|
2012
|
+
telemetry.rowsRetained += result.numRows;
|
|
2013
|
+
}
|
|
2014
|
+
const resultLength = result.numRows;
|
|
2015
|
+
if (!resultLength)
|
|
2016
|
+
continue;
|
|
2017
|
+
const provenance = Object.freeze({
|
|
2018
|
+
sourceId: resolvedSource.entry.dataSourceId,
|
|
2019
|
+
sourceIndex: resolvedSource.sourceIndex,
|
|
2020
|
+
sourceBatchIndex: currentSourceBatchIndex,
|
|
2021
|
+
sourceMetadata: "shape" in input ? batch.metadata : Object.fromEntries(input.metadata)
|
|
2022
|
+
});
|
|
2023
|
+
telemetry.rowsReturned += resultLength;
|
|
2024
|
+
sourceRowsReturned += resultLength;
|
|
2025
|
+
for (const recordBatch of result.batches) {
|
|
2026
|
+
const metadata = new Map(resultLength === batch.length && !("shape" in input) ? input.metadata : void 0);
|
|
2027
|
+
metadata.set("loaders.gl.federation", JSON.stringify(provenance));
|
|
2028
|
+
yield new arrow8.RecordBatch(recordBatch.schema, recordBatch.data, metadata);
|
|
2029
|
+
}
|
|
2030
|
+
remaining -= resultLength;
|
|
2031
|
+
}
|
|
2032
|
+
sourceCompleted = true;
|
|
2033
|
+
} catch (error) {
|
|
2034
|
+
sourceError = error;
|
|
2035
|
+
throw error;
|
|
2036
|
+
} finally {
|
|
2037
|
+
const sourceTelemetry = createSourceTelemetry({
|
|
2038
|
+
resolvedSource,
|
|
2039
|
+
childTelemetry,
|
|
2040
|
+
sourceStartedAt,
|
|
2041
|
+
sourceCompleted,
|
|
2042
|
+
sourceError,
|
|
2043
|
+
signal: options.signal,
|
|
2044
|
+
batchesDecoded: sourceBatchesDecoded,
|
|
2045
|
+
rowsRead: sourceRowsRead,
|
|
2046
|
+
rowsTested: sourceRowsTested,
|
|
2047
|
+
rowsRetained: sourceRowsRetained,
|
|
2048
|
+
rowsReturned: sourceRowsReturned
|
|
2049
|
+
});
|
|
2050
|
+
telemetry.sources.push(sourceTelemetry);
|
|
2051
|
+
telemetry.bytesFetched += sourceTelemetry.bytesFetched || 0;
|
|
2052
|
+
telemetry.filesOpened += sourceTelemetry.filesOpened || 0;
|
|
2053
|
+
telemetry.tasksOpened += sourceTelemetry.tasksOpened || 0;
|
|
2054
|
+
telemetry.rowsPruned += sourceTelemetry.rowsPruned || 0;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
telemetry.status = "completed";
|
|
2058
|
+
} catch (error) {
|
|
2059
|
+
telemetry.status = ((_b = options.signal) == null ? void 0 : _b.aborted) ? "cancelled" : "failed";
|
|
2060
|
+
telemetry.error = error;
|
|
2061
|
+
throw error;
|
|
2062
|
+
} finally {
|
|
2063
|
+
this.dataSourceManager.unsubscribe({ consumerId });
|
|
2064
|
+
telemetry.durationMilliseconds = Date.now() - startedAt;
|
|
2065
|
+
if (telemetry.status === "early-terminated" && !telemetry.earlyTerminationReason) {
|
|
2066
|
+
telemetry.earlyTerminationReason = "consumer-return";
|
|
2067
|
+
}
|
|
2068
|
+
emitQueryComplete(options.onQueryComplete, Object.freeze({
|
|
2069
|
+
...telemetry,
|
|
2070
|
+
batchesDecoded: telemetry.batchesRead,
|
|
2071
|
+
sources: Object.freeze([...telemetry.sources])
|
|
2072
|
+
}));
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
/** Resolves managed sources, discovers their schemas, and creates one compatibility plan. */
|
|
2076
|
+
async resolvePlan(consumerId, signal) {
|
|
2077
|
+
const sources = [];
|
|
2078
|
+
for (let sourceIndex = 0; sourceIndex < this.sources.length; sourceIndex++) {
|
|
2079
|
+
throwIfAborted2(signal);
|
|
2080
|
+
const entry = this.sources[sourceIndex];
|
|
2081
|
+
const source = await resolveManagedSource(this.dataSourceManager, entry.dataSourceId, consumerId, String(sourceIndex), signal);
|
|
2082
|
+
if (typeof source.getQueryMetadata !== "function" || typeof source.read !== "function") {
|
|
2083
|
+
throw new Error(`Managed source does not implement TableScanSource: ${entry.dataSourceId}`);
|
|
2084
|
+
}
|
|
2085
|
+
const metadata = await source.getQueryMetadata({ signal });
|
|
2086
|
+
if (metadata.execution.status !== "supported" || metadata.execution.method !== "read") {
|
|
2087
|
+
throw new Error(`Source does not support read(): ${entry.dataSourceId}`);
|
|
2088
|
+
}
|
|
2089
|
+
if (metadata.queryType !== "table") {
|
|
2090
|
+
throw new Error(`Federated source is not a table source: ${entry.dataSourceId}`);
|
|
2091
|
+
}
|
|
2092
|
+
const fields = resolveMappedFields(entry, metadata);
|
|
2093
|
+
sources.push({
|
|
2094
|
+
entry,
|
|
2095
|
+
source,
|
|
2096
|
+
metadata,
|
|
2097
|
+
sourceIndex,
|
|
2098
|
+
fields,
|
|
2099
|
+
sourceNameByOutputName: new Map(fields.map((field) => [field.outputName, field.sourceName]))
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
return Object.freeze({
|
|
2103
|
+
schema: reconcileSchemas(sources, this.schemaPolicy, this.outputSchema),
|
|
2104
|
+
sources: Object.freeze(sources)
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
/** Returns a collision-free manager consumer id for one operation. */
|
|
2108
|
+
createConsumerId(operation) {
|
|
2109
|
+
return `federated-table:${this.instanceId}:${operation}:${this.nextOperationId++}`;
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
function cloneSourceEntry(entry) {
|
|
2113
|
+
if (!entry.dataSourceId) {
|
|
2114
|
+
throw new Error("Federated table source ids must be non-empty.");
|
|
2115
|
+
}
|
|
2116
|
+
return Object.freeze({
|
|
2117
|
+
dataSourceId: entry.dataSourceId,
|
|
2118
|
+
query: entry.query ? Object.freeze({
|
|
2119
|
+
...entry.query,
|
|
2120
|
+
columns: entry.query.columns ? Object.freeze([...entry.query.columns]) : void 0
|
|
2121
|
+
}) : void 0,
|
|
2122
|
+
columnMapping: entry.columnMapping ? Object.freeze({ ...entry.columnMapping }) : void 0
|
|
2123
|
+
});
|
|
2124
|
+
}
|
|
2125
|
+
function resolveMappedFields(entry, metadata) {
|
|
2126
|
+
var _a;
|
|
2127
|
+
const sourceFields = new Map(metadata.schema.fields.map((field) => [field.name, field]));
|
|
2128
|
+
for (const sourceName of Object.keys(entry.columnMapping || {})) {
|
|
2129
|
+
if (!sourceFields.has(sourceName)) {
|
|
2130
|
+
throw new Error(`Federated column mapping source not found in ${entry.dataSourceId}: ${sourceName}`);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
const selectedNames = ((_a = entry.query) == null ? void 0 : _a.columns) || metadata.schema.fields.map((field) => field.name);
|
|
2134
|
+
if (!selectedNames.length) {
|
|
2135
|
+
throw new Error(`Federated source projection must not be empty: ${entry.dataSourceId}`);
|
|
2136
|
+
}
|
|
2137
|
+
const outputNames = /* @__PURE__ */ new Set();
|
|
2138
|
+
return Object.freeze(selectedNames.map((sourceName) => {
|
|
2139
|
+
var _a2;
|
|
2140
|
+
const field = sourceFields.get(sourceName);
|
|
2141
|
+
if (!field) {
|
|
2142
|
+
throw new Error(`Federated source column not found in ${entry.dataSourceId}: ${sourceName}`);
|
|
2143
|
+
}
|
|
2144
|
+
const outputName = ((_a2 = entry.columnMapping) == null ? void 0 : _a2[sourceName]) ?? sourceName;
|
|
2145
|
+
if (!outputName) {
|
|
2146
|
+
throw new Error(`Federated output column names must be non-empty: ${sourceName}`);
|
|
2147
|
+
}
|
|
2148
|
+
if (outputNames.has(outputName)) {
|
|
2149
|
+
throw new Error(`Federated column mapping creates duplicate output column in ${entry.dataSourceId}: ${outputName}`);
|
|
2150
|
+
}
|
|
2151
|
+
outputNames.add(outputName);
|
|
2152
|
+
return Object.freeze({ sourceName, outputName, field });
|
|
2153
|
+
}));
|
|
2154
|
+
}
|
|
2155
|
+
function reconcileSchemas(sources, schemaPolicy, outputSchema) {
|
|
2156
|
+
const outputFields = /* @__PURE__ */ new Map();
|
|
2157
|
+
const firstSourceNames = sources[0].fields.map((field) => field.outputName);
|
|
2158
|
+
for (const source of sources) {
|
|
2159
|
+
const sourceNames = new Set(source.fields.map((field) => field.outputName));
|
|
2160
|
+
if (schemaPolicy === "strict") {
|
|
2161
|
+
const missing = firstSourceNames.filter((name) => !sourceNames.has(name));
|
|
2162
|
+
const extra = source.fields.map((field) => field.outputName).filter((name) => !firstSourceNames.includes(name));
|
|
2163
|
+
if (missing.length || extra.length) {
|
|
2164
|
+
throw new Error(`Federated strict schema mismatch for ${source.entry.dataSourceId}: missing [${missing.join(", ")}], extra [${extra.join(", ")}]`);
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
for (const mappedField of source.fields) {
|
|
2168
|
+
const current = outputFields.get(mappedField.outputName);
|
|
2169
|
+
if (current) {
|
|
2170
|
+
if (!outputSchema && !areDataTypesEqual(current.type, mappedField.field.type)) {
|
|
2171
|
+
throw new Error(`Federated column type mismatch for ${mappedField.outputName}: ${formatDataType(current.type)} versus ${formatDataType(mappedField.field.type)} in ${source.entry.dataSourceId}`);
|
|
2172
|
+
}
|
|
2173
|
+
current.nullable = Boolean(current.nullable || mappedField.field.nullable);
|
|
2174
|
+
current.presentCount++;
|
|
2175
|
+
} else {
|
|
2176
|
+
outputFields.set(mappedField.outputName, {
|
|
2177
|
+
...mappedField.field,
|
|
2178
|
+
name: mappedField.outputName,
|
|
2179
|
+
metadata: mappedField.field.metadata ? { ...mappedField.field.metadata } : void 0,
|
|
2180
|
+
presentCount: 1
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
const fields = [...outputFields.values()].map(({ presentCount, ...field }) => ({
|
|
2186
|
+
...field,
|
|
2187
|
+
nullable: Boolean(field.nullable || presentCount < sources.length)
|
|
2188
|
+
}));
|
|
2189
|
+
const inferredSchema = { fields, metadata: {} };
|
|
2190
|
+
return outputSchema ? validateAndCloneOutputSchema(outputSchema, sources, inferredSchema, schemaPolicy) : inferredSchema;
|
|
2191
|
+
}
|
|
2192
|
+
function validateAndCloneOutputSchema(outputSchema, sources, inferredSchema, schemaPolicy) {
|
|
2193
|
+
const outputFields = /* @__PURE__ */ new Map();
|
|
2194
|
+
for (const field of outputSchema.fields) {
|
|
2195
|
+
if (!field.name || outputFields.has(field.name)) {
|
|
2196
|
+
throw new Error(`Federated output schema contains an invalid or duplicate field: ${field.name}`);
|
|
2197
|
+
}
|
|
2198
|
+
outputFields.set(field.name, field);
|
|
2199
|
+
}
|
|
2200
|
+
const inferredNames = new Set(inferredSchema.fields.map((field) => field.name));
|
|
2201
|
+
const missingFromContract = [...inferredNames].filter((name) => !outputFields.has(name));
|
|
2202
|
+
const absentFromSources = outputSchema.fields.map((field) => field.name).filter((name) => !inferredNames.has(name));
|
|
2203
|
+
if (missingFromContract.length || schemaPolicy === "strict" && absentFromSources.length) {
|
|
2204
|
+
throw new Error(`Federated output schema mismatch: missing [${missingFromContract.join(", ")}], absent [${absentFromSources.join(", ")}]`);
|
|
2205
|
+
}
|
|
2206
|
+
for (const outputField of outputSchema.fields) {
|
|
2207
|
+
const presentFields = sources.flatMap((source) => source.fields.filter((field) => field.outputName === outputField.name).map((field) => ({ sourceId: source.entry.dataSourceId, field: field.field })));
|
|
2208
|
+
if (!presentFields.length) {
|
|
2209
|
+
if (!outputField.nullable) {
|
|
2210
|
+
throw new Error(`Federated output field is absent from every source and must be nullable: ${outputField.name}`);
|
|
2211
|
+
}
|
|
2212
|
+
continue;
|
|
2213
|
+
}
|
|
2214
|
+
for (const presentField of presentFields) {
|
|
2215
|
+
if (presentField.field.nullable && !outputField.nullable) {
|
|
2216
|
+
throw new Error(`Federated output field cannot remove nullability for ${outputField.name} in ${presentField.sourceId}`);
|
|
2217
|
+
}
|
|
2218
|
+
if (!isLosslessDataTypeCast(presentField.field.type, outputField.type)) {
|
|
2219
|
+
throw new Error(`Unsupported federated normalization for ${outputField.name}: ${formatDataType(presentField.field.type)} to ${formatDataType(outputField.type)} in ${presentField.sourceId}`);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
if (presentFields.length < sources.length && !outputField.nullable) {
|
|
2223
|
+
throw new Error(`Federated union field must be nullable when absent from a source: ${outputField.name}`);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
return cloneSchema(outputSchema);
|
|
2227
|
+
}
|
|
2228
|
+
function createSourceReadOptions(source, requiredOutputColumns, remaining, options, onQueryComplete) {
|
|
2229
|
+
var _a, _b;
|
|
2230
|
+
const sourceResidualPredicate = getSourceResidualPredicate(source);
|
|
2231
|
+
const requiredSourceColumns = requiredOutputColumns.map((outputName) => source.sourceNameByOutputName.get(outputName)).filter((sourceName) => Boolean(sourceName));
|
|
2232
|
+
if (sourceResidualPredicate) {
|
|
2233
|
+
requiredSourceColumns.push(...getColumnarPredicateColumns(sourceResidualPredicate));
|
|
2234
|
+
}
|
|
2235
|
+
if (!requiredSourceColumns.length) {
|
|
2236
|
+
requiredSourceColumns.push(source.fields[0].sourceName);
|
|
2237
|
+
}
|
|
2238
|
+
const sourceLimit = (_a = source.entry.query) == null ? void 0 : _a.limit;
|
|
2239
|
+
const globalLimitCanBePushed = options.predicate === void 0 && Number.isFinite(remaining);
|
|
2240
|
+
const limit = globalLimitCanBePushed ? Math.min(sourceLimit ?? Number.POSITIVE_INFINITY, remaining) : sourceLimit;
|
|
2241
|
+
return {
|
|
2242
|
+
...source.entry.query,
|
|
2243
|
+
columns: Object.freeze([...new Set(requiredSourceColumns)]),
|
|
2244
|
+
predicate: sourceResidualPredicate ? void 0 : (_b = source.entry.query) == null ? void 0 : _b.predicate,
|
|
2245
|
+
limit: sourceResidualPredicate ? void 0 : Number.isFinite(limit) ? limit : void 0,
|
|
2246
|
+
signal: options.signal,
|
|
2247
|
+
onQueryComplete
|
|
2248
|
+
};
|
|
2249
|
+
}
|
|
2250
|
+
function getSourceResidualPredicate(source) {
|
|
2251
|
+
var _a, _b;
|
|
2252
|
+
return ((_a = source.metadata.capabilities.table) == null ? void 0 : _a.predicate) === "unsupported" ? (_b = source.entry.query) == null ? void 0 : _b.predicate : void 0;
|
|
2253
|
+
}
|
|
2254
|
+
function createCanonicalArrowTable(schema, source, physicalTable) {
|
|
2255
|
+
const arrowSchema = convertSchemaToArrow(schema);
|
|
2256
|
+
const columns = {};
|
|
2257
|
+
for (const field of arrowSchema.fields) {
|
|
2258
|
+
const sourceName = source.sourceNameByOutputName.get(field.name);
|
|
2259
|
+
const vector = sourceName ? physicalTable.getChild(sourceName) : null;
|
|
2260
|
+
const mappedField = source.fields.find((sourceField) => sourceField.outputName === field.name);
|
|
2261
|
+
columns[field.name] = vector ? mappedField && !areDataTypesEqual(mappedField.field.type, schema.fields.find((schemaField) => schemaField.name === field.name).type) ? arrow8.vectorFromArray(Array.from(vector), field.type) : vector : arrow8.vectorFromArray(Array.from({ length: physicalTable.numRows }, () => null), field.type);
|
|
2262
|
+
}
|
|
2263
|
+
return new arrow8.Table(arrowSchema, columns);
|
|
2264
|
+
}
|
|
2265
|
+
function createSourceTelemetry(options) {
|
|
2266
|
+
var _a;
|
|
2267
|
+
const { resolvedSource, childTelemetry } = options;
|
|
2268
|
+
const status = (childTelemetry == null ? void 0 : childTelemetry.status) || (((_a = options.signal) == null ? void 0 : _a.aborted) ? "cancelled" : options.sourceError ? "failed" : options.sourceCompleted ? "completed" : "early-terminated");
|
|
2269
|
+
const details = childTelemetry ? Object.freeze(Object.fromEntries(Object.entries(childTelemetry).filter(([key]) => ![
|
|
2270
|
+
"status",
|
|
2271
|
+
"sourcesPlanned",
|
|
2272
|
+
"sourcesRead",
|
|
2273
|
+
"batchesRead",
|
|
2274
|
+
"batchesDecoded",
|
|
2275
|
+
"rowsRead",
|
|
2276
|
+
"rowsTested",
|
|
2277
|
+
"rowsRetained",
|
|
2278
|
+
"rowsReturned",
|
|
2279
|
+
"bytesRead",
|
|
2280
|
+
"bytesFetched",
|
|
2281
|
+
"filesOpened",
|
|
2282
|
+
"tasksOpened",
|
|
2283
|
+
"rowsPruned",
|
|
2284
|
+
"durationMilliseconds",
|
|
2285
|
+
"sources",
|
|
2286
|
+
"details",
|
|
2287
|
+
"error"
|
|
2288
|
+
].includes(key)))) : void 0;
|
|
2289
|
+
return Object.freeze({
|
|
2290
|
+
sourceId: resolvedSource.entry.dataSourceId,
|
|
2291
|
+
sourceType: resolvedSource.metadata.sourceType,
|
|
2292
|
+
sourceIndex: resolvedSource.sourceIndex,
|
|
2293
|
+
status,
|
|
2294
|
+
filesOpened: childTelemetry == null ? void 0 : childTelemetry.filesOpened,
|
|
2295
|
+
tasksOpened: childTelemetry == null ? void 0 : childTelemetry.tasksOpened,
|
|
2296
|
+
bytesFetched: (childTelemetry == null ? void 0 : childTelemetry.bytesFetched) ?? (childTelemetry == null ? void 0 : childTelemetry.bytesRead),
|
|
2297
|
+
batchesDecoded: (childTelemetry == null ? void 0 : childTelemetry.batchesDecoded) ?? options.batchesDecoded,
|
|
2298
|
+
rowsRead: (childTelemetry == null ? void 0 : childTelemetry.rowsRead) ?? options.rowsRead,
|
|
2299
|
+
rowsTested: (childTelemetry == null ? void 0 : childTelemetry.rowsTested) || options.rowsTested || void 0,
|
|
2300
|
+
rowsRetained: (childTelemetry == null ? void 0 : childTelemetry.rowsRetained) || options.rowsRetained || void 0,
|
|
2301
|
+
rowsReturned: options.rowsReturned,
|
|
2302
|
+
rowsPruned: childTelemetry == null ? void 0 : childTelemetry.rowsPruned,
|
|
2303
|
+
durationMilliseconds: Date.now() - options.sourceStartedAt,
|
|
2304
|
+
details: (childTelemetry == null ? void 0 : childTelemetry.details) ?? (details && Object.keys(details).length ? details : void 0),
|
|
2305
|
+
error: (childTelemetry == null ? void 0 : childTelemetry.error) ?? options.sourceError
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
function getFederatedStatistics(sources) {
|
|
2309
|
+
if (sources.some((source) => {
|
|
2310
|
+
var _a, _b, _c;
|
|
2311
|
+
return ((_a = source.entry.query) == null ? void 0 : _a.predicate) || ((_b = source.entry.query) == null ? void 0 : _b.limit) !== void 0 || ((_c = source.metadata.statistics) == null ? void 0 : _c.rowCount) === void 0;
|
|
2312
|
+
})) {
|
|
2313
|
+
return void 0;
|
|
2314
|
+
}
|
|
2315
|
+
const counts = sources.map((source) => source.metadata.statistics.rowCount);
|
|
2316
|
+
return {
|
|
2317
|
+
rowCount: counts.some((count) => typeof count === "bigint") ? counts.reduce((sum, count) => sum + BigInt(count), 0n) : counts.reduce((sum, count) => sum + Number(count), 0)
|
|
2318
|
+
};
|
|
2319
|
+
}
|
|
2320
|
+
function createSourceExplanation(source, outputSchema) {
|
|
2321
|
+
const normalizedTypes = Object.fromEntries(source.fields.filter((field) => {
|
|
2322
|
+
const outputField = outputSchema.fields.find((schemaField) => schemaField.name === field.outputName);
|
|
2323
|
+
return outputField && !areDataTypesEqual(outputField.type, field.field.type);
|
|
2324
|
+
}).map((field) => [
|
|
2325
|
+
field.outputName,
|
|
2326
|
+
outputSchema.fields.find((schemaField) => schemaField.name === field.outputName).type
|
|
2327
|
+
]));
|
|
2328
|
+
return Object.freeze({
|
|
2329
|
+
sourceId: source.entry.dataSourceId,
|
|
2330
|
+
sourceIndex: source.sourceIndex,
|
|
2331
|
+
sourceType: source.metadata.sourceType,
|
|
2332
|
+
sourceColumns: Object.freeze(source.fields.map((field) => field.sourceName)),
|
|
2333
|
+
outputColumns: Object.freeze(source.fields.map((field) => field.outputName)),
|
|
2334
|
+
columnMapping: Object.freeze({ ...source.entry.columnMapping }),
|
|
2335
|
+
normalizedTypes: Object.freeze(normalizedTypes)
|
|
2336
|
+
});
|
|
2337
|
+
}
|
|
2338
|
+
function isLosslessDataTypeCast(sourceType, outputType) {
|
|
2339
|
+
if (areDataTypesEqual(sourceType, outputType) || sourceType === "null")
|
|
2340
|
+
return true;
|
|
2341
|
+
if (typeof sourceType === "object" && sourceType.type === "dictionary") {
|
|
2342
|
+
return isLosslessDataTypeCast(sourceType.dictionary, outputType);
|
|
2343
|
+
}
|
|
2344
|
+
if (sourceType === "utf8-view" && outputType === "utf8")
|
|
2345
|
+
return true;
|
|
2346
|
+
if (sourceType === "binary-view" && outputType === "binary")
|
|
2347
|
+
return true;
|
|
2348
|
+
const sourceInteger = getIntegerType(sourceType);
|
|
2349
|
+
const outputInteger = getIntegerType(outputType);
|
|
2350
|
+
if (sourceInteger && outputInteger) {
|
|
2351
|
+
return sourceInteger.signed === outputInteger.signed && sourceInteger.bits <= outputInteger.bits || !sourceInteger.signed && outputInteger.signed && sourceInteger.bits < outputInteger.bits;
|
|
2352
|
+
}
|
|
2353
|
+
const sourceFloatBits = getFloatBits(sourceType);
|
|
2354
|
+
const outputFloatBits = getFloatBits(outputType);
|
|
2355
|
+
if (sourceFloatBits && outputFloatBits)
|
|
2356
|
+
return sourceFloatBits <= outputFloatBits;
|
|
2357
|
+
return Boolean(sourceInteger && sourceInteger.bits <= 32 && outputFloatBits === 64);
|
|
2358
|
+
}
|
|
2359
|
+
function getIntegerType(dataType) {
|
|
2360
|
+
const types = {
|
|
2361
|
+
int: { signed: true, bits: 32 },
|
|
2362
|
+
int8: { signed: true, bits: 8 },
|
|
2363
|
+
int16: { signed: true, bits: 16 },
|
|
2364
|
+
int32: { signed: true, bits: 32 },
|
|
2365
|
+
int64: { signed: true, bits: 64 },
|
|
2366
|
+
uint8: { signed: false, bits: 8 },
|
|
2367
|
+
uint16: { signed: false, bits: 16 },
|
|
2368
|
+
uint32: { signed: false, bits: 32 },
|
|
2369
|
+
uint64: { signed: false, bits: 64 }
|
|
2370
|
+
};
|
|
2371
|
+
return typeof dataType === "string" ? types[dataType] || null : null;
|
|
2372
|
+
}
|
|
2373
|
+
function getFloatBits(dataType) {
|
|
2374
|
+
const types = { float: 32, float16: 16, float32: 32, float64: 64 };
|
|
2375
|
+
return typeof dataType === "string" ? types[dataType] || null : null;
|
|
2376
|
+
}
|
|
2377
|
+
function cloneSchema(schema) {
|
|
2378
|
+
return convertArrowToSchema(convertSchemaToArrow(schema));
|
|
2379
|
+
}
|
|
2380
|
+
function areDataTypesEqual(left, right) {
|
|
2381
|
+
return formatDataType(left) === formatDataType(right);
|
|
2382
|
+
}
|
|
2383
|
+
function formatDataType(dataType) {
|
|
2384
|
+
return typeof dataType === "string" ? dataType : JSON.stringify(canonicalizeValue(dataType));
|
|
2385
|
+
}
|
|
2386
|
+
function canonicalizeValue(value) {
|
|
2387
|
+
if (ArrayBuffer.isView(value)) {
|
|
2388
|
+
return Array.from(value);
|
|
2389
|
+
}
|
|
2390
|
+
if (Array.isArray(value)) {
|
|
2391
|
+
return value.map(canonicalizeValue);
|
|
2392
|
+
}
|
|
2393
|
+
if (value && typeof value === "object") {
|
|
2394
|
+
return Object.fromEntries(Object.entries(value).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)).map(([key, child]) => [key, canonicalizeValue(child)]));
|
|
2395
|
+
}
|
|
2396
|
+
return value;
|
|
2397
|
+
}
|
|
2398
|
+
function resolveManagedSource(dataSourceManager, dataSourceId, consumerId, requestId, signal) {
|
|
2399
|
+
let resolveDeferredSource;
|
|
2400
|
+
let rejectDeferredSource;
|
|
2401
|
+
const deferredSource = new Promise((resolve, reject) => {
|
|
2402
|
+
resolveDeferredSource = resolve;
|
|
2403
|
+
rejectDeferredSource = reject;
|
|
2404
|
+
});
|
|
2405
|
+
let sourceGeneration = 0;
|
|
2406
|
+
const acceptSource = (source) => {
|
|
2407
|
+
const generation = ++sourceGeneration;
|
|
2408
|
+
if (source) {
|
|
2409
|
+
void Promise.resolve(source).then((result) => {
|
|
2410
|
+
if (generation === sourceGeneration)
|
|
2411
|
+
resolveDeferredSource(result);
|
|
2412
|
+
}, (error) => {
|
|
2413
|
+
if (generation === sourceGeneration)
|
|
2414
|
+
rejectDeferredSource(error);
|
|
2415
|
+
});
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
const managedSource = dataSourceManager.subscribe({
|
|
2419
|
+
dataSourceId,
|
|
2420
|
+
consumerId,
|
|
2421
|
+
requestId,
|
|
2422
|
+
onChange: acceptSource
|
|
2423
|
+
});
|
|
2424
|
+
if (managedSource === void 0) {
|
|
2425
|
+
throw new Error(`Federated table source is not registered: ${dataSourceId}`);
|
|
2426
|
+
}
|
|
2427
|
+
acceptSource(managedSource || null);
|
|
2428
|
+
return waitForPromise(deferredSource, signal);
|
|
2429
|
+
}
|
|
2430
|
+
async function waitForPromise(promise, signal) {
|
|
2431
|
+
if (!signal)
|
|
2432
|
+
return await promise;
|
|
2433
|
+
throwIfAborted2(signal);
|
|
2434
|
+
return await new Promise((resolve, reject) => {
|
|
2435
|
+
const abort = () => reject(getAbortReason(signal));
|
|
2436
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
2437
|
+
void promise.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2440
|
+
function throwIfAborted2(signal) {
|
|
2441
|
+
if (signal == null ? void 0 : signal.aborted)
|
|
2442
|
+
throw getAbortReason(signal);
|
|
2443
|
+
}
|
|
2444
|
+
function getAbortReason(signal) {
|
|
2445
|
+
return signal.reason || new DOMException("Request aborted", "AbortError");
|
|
2446
|
+
}
|
|
2447
|
+
//# sourceMappingURL=federated-table-scan-source.cjs.map
|