@loaders.gl/core 5.0.0-beta.10 → 5.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SCAN-README.md +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs +1 -5
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts +4 -3
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +2 -6
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +2 -10
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts +6 -5
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +5 -13
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.cjs +1 -5
- package/dist/arrow-geometry/wkb-arrow-utils.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts +7 -7
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.js +4 -8
- package/dist/arrow-geometry/wkb-arrow-utils.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +7 -75
- package/dist/arrow-worker-transport.cjs.map +1 -1
- package/dist/arrow-worker-transport.d.ts +3 -7
- package/dist/arrow-worker-transport.d.ts.map +1 -1
- package/dist/arrow-worker-transport.js +15 -89
- package/dist/arrow-worker-transport.js.map +1 -1
- package/dist/cluster-source.cjs +12 -12
- package/dist/cluster-source.cjs.map +1 -1
- package/dist/dist.dev.js +71 -60
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +87 -125
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.cjs +12 -12
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts +3 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +12 -14
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +4 -12
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +5 -5
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +6 -14
- package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +10 -11
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-stream.js +9 -12
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.cjs.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js +3 -3
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +5 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/index.cjs +69 -54
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +2 -4
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/loader-options.d.ts +6 -0
- package/dist/lib/api/loader-options.d.ts.map +1 -1
- package/dist/lib/api/loader-options.js +48 -0
- package/dist/lib/api/loader-options.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +2 -5
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.js +6 -10
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +2 -5
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +2 -5
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +5 -8
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
- package/dist/lib/loader-utils/native-arrow.js +13 -31
- package/dist/lib/loader-utils/native-arrow.js.map +1 -1
- package/dist/loader-utils/index.cjs +27 -22
- package/dist/loader-utils/index.cjs.map +1 -1
- package/dist/loader-utils/index.d.ts +1 -1
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +6 -2
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +15 -12
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +36 -22
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +2 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -3
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +3 -5
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +4 -4
- package/dist/scan/arrow-execution/expressions.cjs.map +2 -2
- package/dist/scan/arrow-execution/expressions.d.ts +4 -4
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +4 -4
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-query-worker-entry.cjs +121 -0
- package/dist/scan/arrow-query-worker-entry.cjs.map +7 -0
- package/dist/scan/arrow-query-worker-entry.d.ts +2 -0
- package/dist/scan/arrow-query-worker-entry.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker-entry.js +7 -0
- package/dist/scan/arrow-query-worker-entry.js.map +1 -0
- package/dist/scan/arrow-query-worker.cjs +197 -0
- package/dist/scan/arrow-query-worker.cjs.map +7 -0
- package/dist/scan/arrow-query-worker.d.ts +47 -0
- package/dist/scan/arrow-query-worker.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker.js +101 -0
- package/dist/scan/arrow-query-worker.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +12 -13
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +14 -15
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +5 -2
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +2 -2
- package/dist/scan/parse-sql-predicate.cjs.map +2 -2
- package/dist/scan/parse-sql-predicate.js +1 -1
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-pushdown.cjs +6 -6
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.d.ts +1 -1
- package/dist/scan/query-pushdown.d.ts.map +1 -1
- package/dist/scan/query-pushdown.js +3 -6
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query-scales.cjs +140 -0
- package/dist/scan/query-scales.cjs.map +7 -0
- package/dist/scan/query-scales.d.ts +35 -0
- package/dist/scan/query-scales.d.ts.map +1 -0
- package/dist/scan/query-scales.js +120 -0
- package/dist/scan/query-scales.js.map +1 -0
- package/dist/scan/query.cjs +49 -45
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts +7 -4
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +35 -52
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +19 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +3 -4
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +11 -12
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/categories/category-mesh.d.ts +3 -10
- package/dist/schema/categories/category-mesh.d.ts.map +1 -1
- package/dist/schema/categories/category-mesh.js.map +1 -1
- package/dist/schema/categories/category-table.d.ts +2 -19
- package/dist/schema/categories/category-table.d.ts.map +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/types/batch.d.ts +0 -4
- package/dist/schema/types/batch.d.ts.map +1 -1
- package/dist/schema-utils/index.cjs +419 -502
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +4 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +4 -5
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +4 -5
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +21 -18
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +6 -11
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +8 -21
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -4
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +13 -15
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +2 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +3 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +5 -8
- package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +2 -6
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +4 -24
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +3 -6
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +6 -57
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +2 -2
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +2 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +2 -2
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +4 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.d.ts +1 -3
- package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.js +0 -4
- package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +16 -10
- package/dist/vector-table-scan-source.cjs.map +2 -2
- package/dist/worker-utils/index.cjs +2 -2
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/package.json +23 -8
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -8
- package/src/arrow-geometry/feature-table.ts +8 -21
- package/src/arrow-geometry/wkb-arrow-utils.ts +8 -12
- package/src/arrow-worker-transport.ts +21 -120
- package/src/geoarrow/clustering/cluster-source.ts +16 -23
- package/src/geoarrow/convert-table-to-geoarrow.ts +11 -23
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +2 -2
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +2 -4
- package/src/geoarrow/geoarrow-stream.ts +15 -15
- package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts +3 -3
- package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +7 -5
- package/src/index.ts +1 -1
- package/src/lib/api/load.ts +2 -12
- package/src/lib/api/loader-options.ts +69 -0
- package/src/lib/api/parse-file.ts +2 -11
- package/src/lib/api/parse-in-batches.ts +8 -12
- package/src/lib/api/parse-sync.ts +3 -7
- package/src/lib/api/parse.ts +2 -6
- package/src/lib/loader-utils/native-arrow.ts +12 -38
- package/src/loader-utils/index.ts +0 -1
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +7 -6
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +64 -41
- package/src/loader-utils/lib/sources/table-source-collection.ts +2 -1
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -9
- package/src/loader-utils/loader-types.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +7 -7
- package/src/scan/arrow-query-worker-entry.ts +8 -0
- package/src/scan/arrow-query-worker.ts +158 -0
- package/src/scan/federated-table-scan-source.ts +15 -18
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +1 -1
- package/src/scan/query-pushdown.ts +7 -7
- package/src/scan/query-scales.ts +199 -0
- package/src/scan/query.ts +68 -71
- package/src/scan/vector-table-scan-source.ts +16 -21
- package/src/schema/categories/category-mesh.ts +3 -11
- package/src/schema/categories/category-table.ts +2 -28
- package/src/schema/geometry/arrow-binary-features.ts +1 -1
- package/src/schema/index.ts +1 -3
- package/src/schema/types/batch.ts +0 -5
- package/src/schema-utils/index.ts +4 -10
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +33 -30
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +12 -38
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +15 -18
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +4 -13
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +10 -9
- package/src/schema-utils/lib/table/batches/convert-batches.ts +5 -8
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +2 -6
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +5 -27
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +9 -72
- package/src/schema-utils/lib/table/tables/make-table.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +2 -22
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +6 -6
- package/src/schema-utils/lib/table/tables/table-types.ts +1 -7
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +0 -27
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +0 -23
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +0 -1
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +0 -54
package/src/scan/query.ts
CHANGED
|
@@ -8,8 +8,8 @@ import type {
|
|
|
8
8
|
ProgressiveQueryOptions,
|
|
9
9
|
ProgressiveQuerySnapshot
|
|
10
10
|
} from './query-progressive';
|
|
11
|
-
import type {SQLQuery} from '@math.gl/
|
|
12
|
-
import type {
|
|
11
|
+
import type {SQLQuery} from '@math.gl/sql/parser';
|
|
12
|
+
import type {TableBatch, Schema} from '@loaders.gl/core/schema';
|
|
13
13
|
import {
|
|
14
14
|
normalizeTableQuery,
|
|
15
15
|
getColumnarPredicateColumns,
|
|
@@ -85,6 +85,10 @@ export type QueryOptions = TableQueryExecutionOptions &
|
|
|
85
85
|
core?: DataSourceOptions['core'];
|
|
86
86
|
/** Named caller-owned data sources used by FROM and metadata commands. */
|
|
87
87
|
sources?: readonly DataSource<unknown, DataSourceOptions>[];
|
|
88
|
+
/** Row offset belongs on the logical query. */
|
|
89
|
+
offset?: never;
|
|
90
|
+
/** Row limit belongs on the logical query. */
|
|
91
|
+
limit?: never;
|
|
88
92
|
/** Parser or lazy parser promise, required only for SQL string input. */
|
|
89
93
|
sqlParser?: SQLQueryParser | Promise<SQLQueryParser>;
|
|
90
94
|
/** Append-only batches (default), or complete progressive replacement snapshots. */
|
|
@@ -93,7 +97,7 @@ export type QueryOptions = TableQueryExecutionOptions &
|
|
|
93
97
|
Readonly<
|
|
94
98
|
| {
|
|
95
99
|
/** Already loaded Arrow table or caller-owned table scan source. */
|
|
96
|
-
source: arrow.Table |
|
|
100
|
+
source: arrow.Table | TableScanSource;
|
|
97
101
|
/** URL loader selection is only used with URL sources. */
|
|
98
102
|
loaders?: never;
|
|
99
103
|
}
|
|
@@ -148,9 +152,9 @@ export async function* queryInBatches(
|
|
|
148
152
|
if (typeof tableQuery === 'object' && tableQuery && 'aggregates' in tableQuery) {
|
|
149
153
|
throw new Error('Aggregates require snapshots.');
|
|
150
154
|
}
|
|
151
|
-
for await (const
|
|
152
|
-
if (
|
|
153
|
-
else yield makeArrowMetadataBatch(
|
|
155
|
+
for await (const table of queryAppendBatches(tableQuery as Query | string, options)) {
|
|
156
|
+
if (table.batches.length) yield* table.batches;
|
|
157
|
+
else yield makeArrowMetadataBatch(table.schema);
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
|
|
@@ -167,7 +171,7 @@ export async function* queryProgressive(
|
|
|
167
171
|
async function* queryAppendBatches(
|
|
168
172
|
tableQuery: Query | string,
|
|
169
173
|
options: QueryOptions
|
|
170
|
-
): AsyncIterable<
|
|
174
|
+
): AsyncIterable<arrow.Table> {
|
|
171
175
|
const startedAt = Date.now();
|
|
172
176
|
let status: TableQueryExecutionSummary['status'] = 'early-terminated';
|
|
173
177
|
let rowsRead = 0;
|
|
@@ -179,6 +183,15 @@ async function* queryAppendBatches(
|
|
|
179
183
|
let earlyTerminationReason: TableQueryExecutionSummary['earlyTerminationReason'];
|
|
180
184
|
try {
|
|
181
185
|
options.signal?.throwIfAborted();
|
|
186
|
+
const scan = options._scan;
|
|
187
|
+
if (
|
|
188
|
+
options.offset !== undefined ||
|
|
189
|
+
options.limit !== undefined ||
|
|
190
|
+
scan?.limit !== undefined ||
|
|
191
|
+
(scan && 'offset' in scan && scan.offset !== undefined)
|
|
192
|
+
) {
|
|
193
|
+
throw new Error('Put offset and limit in the logical query, not the execution options.');
|
|
194
|
+
}
|
|
182
195
|
let parsedQuery: Query;
|
|
183
196
|
if (typeof tableQuery === 'string') {
|
|
184
197
|
const parser = await options.sqlParser;
|
|
@@ -225,12 +238,7 @@ async function* queryAppendBatches(
|
|
|
225
238
|
options.signal?.throwIfAborted();
|
|
226
239
|
if (!source || typeof source !== 'object')
|
|
227
240
|
throw new Error('Expected an Arrow table or table scan source.');
|
|
228
|
-
const inMemory =
|
|
229
|
-
'batches' in source
|
|
230
|
-
? (source as arrow.Table)
|
|
231
|
-
: 'shape' in source && source.shape === 'arrow-table'
|
|
232
|
-
? (source as ArrowTable).data
|
|
233
|
-
: null;
|
|
241
|
+
const inMemory = 'batches' in source ? (source as arrow.Table) : null;
|
|
234
242
|
if (
|
|
235
243
|
!inMemory &&
|
|
236
244
|
(!('read' in source) ||
|
|
@@ -252,6 +260,11 @@ async function* queryAppendBatches(
|
|
|
252
260
|
) {
|
|
253
261
|
throw new Error('Query source must support table reads.');
|
|
254
262
|
}
|
|
263
|
+
if (metadata?.hasDefaultRowWindow) {
|
|
264
|
+
throw new Error(
|
|
265
|
+
'Query source has a default offset or limit. Remove the source defaults and put offset and limit in the logical query.'
|
|
266
|
+
);
|
|
267
|
+
}
|
|
255
268
|
const sourceSchema = inMemory ? inMemory.schema : convertSchemaToArrow(metadata!.schema);
|
|
256
269
|
const names = sourceSchema.fields.map(field => field.name);
|
|
257
270
|
const {select, where, ...controls} = logicalQuery;
|
|
@@ -356,7 +369,7 @@ async function* queryAppendBatches(
|
|
|
356
369
|
options.signal?.throwIfAborted();
|
|
357
370
|
let emitted = false;
|
|
358
371
|
/** Adapts physical batches without pulling ahead of the query consumer. */
|
|
359
|
-
async function* inputs(): AsyncIterable<
|
|
372
|
+
async function* inputs(): AsyncIterable<arrow.Table> {
|
|
360
373
|
sourcesRead = 1;
|
|
361
374
|
const batches: AsyncIterable<unknown> = pushedPlan
|
|
362
375
|
? pushedPlan.read({signal: options.signal})
|
|
@@ -369,22 +382,27 @@ async function* queryAppendBatches(
|
|
|
369
382
|
if (
|
|
370
383
|
!pushedPlan &&
|
|
371
384
|
comparisonInputSchema &&
|
|
372
|
-
!arrow.util.compareSchemas(
|
|
385
|
+
!arrow.util.compareSchemas(
|
|
386
|
+
comparisonInputSchema,
|
|
387
|
+
convertSchemaToArrow(convertArrowToSchema(batch.schema))
|
|
388
|
+
)
|
|
373
389
|
) {
|
|
374
390
|
// A source may return a wider or differently ordered projection than requested.
|
|
375
|
-
|
|
376
|
-
batch = {...batch, ...wrapBatch(data)};
|
|
391
|
+
batch = batch.select(inputSchema.names);
|
|
377
392
|
if (
|
|
378
|
-
!arrow.util.compareSchemas(
|
|
393
|
+
!arrow.util.compareSchemas(
|
|
394
|
+
comparisonInputSchema,
|
|
395
|
+
convertSchemaToArrow(convertArrowToSchema(batch.schema))
|
|
396
|
+
)
|
|
379
397
|
)
|
|
380
398
|
throw new Error('Query input schema does not match source metadata.');
|
|
381
399
|
}
|
|
382
400
|
batchesRead++;
|
|
383
|
-
rowsRead += batch.
|
|
401
|
+
rowsRead += batch.numRows;
|
|
384
402
|
yield batch;
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
|
-
for await (const value of executeTableScanBatches(
|
|
405
|
+
for await (const value of executeTableScanBatches<arrow.Table>(
|
|
388
406
|
() => inputs(),
|
|
389
407
|
{
|
|
390
408
|
predicate: pushedPlan ? undefined : residual,
|
|
@@ -396,46 +414,40 @@ async function* queryAppendBatches(
|
|
|
396
414
|
{
|
|
397
415
|
filter: (batch, predicate, signal) => {
|
|
398
416
|
if (pushedPlan) return batch;
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
? filterArrowTable(input.data, predicate, {signal})
|
|
411
|
-
: input.data;
|
|
412
|
-
return {...input, ...wrapBatch(data)};
|
|
417
|
+
if (compiledFilter) {
|
|
418
|
+
return filterArrowRows(
|
|
419
|
+
batch,
|
|
420
|
+
recordBatch => {
|
|
421
|
+
const matches = compiledFilter.evaluate(recordBatch, {signal});
|
|
422
|
+
return index => matches.get(index) === true;
|
|
423
|
+
},
|
|
424
|
+
{signal}
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
return predicate ? filterArrowTable(batch, predicate, {signal}) : batch;
|
|
413
428
|
},
|
|
414
|
-
project: batch =>
|
|
415
|
-
const input = batch as ArrowTableBatch;
|
|
416
|
-
return pushedPlan || computedProjection
|
|
417
|
-
? input
|
|
418
|
-
: {...input, ...wrapBatch(project(input.data))};
|
|
419
|
-
}
|
|
429
|
+
project: batch => (pushedPlan || computedProjection ? batch : project(batch))
|
|
420
430
|
}
|
|
421
431
|
)) {
|
|
422
|
-
const input = value as ArrowTableBatch;
|
|
423
432
|
const finishProjection = pushedPlan
|
|
424
433
|
? pushedPlan.project
|
|
425
434
|
: computedProjection
|
|
426
435
|
? project
|
|
427
436
|
: undefined;
|
|
428
|
-
const batch = finishProjection
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
437
|
+
const batch = finishProjection ? finishProjection(value) : value;
|
|
438
|
+
if (
|
|
439
|
+
!arrow.util.compareSchemas(
|
|
440
|
+
comparisonSchema,
|
|
441
|
+
convertSchemaToArrow(convertArrowToSchema(batch.schema))
|
|
442
|
+
)
|
|
443
|
+
)
|
|
432
444
|
throw new Error('Query output schema does not match source metadata.');
|
|
433
445
|
emitted = true;
|
|
434
|
-
rowsReturned += batch.
|
|
446
|
+
rowsReturned += batch.numRows;
|
|
435
447
|
yield batch;
|
|
436
448
|
}
|
|
437
449
|
// An empty schema-bearing batch makes collected and streaming empty results identical.
|
|
438
|
-
if (!emitted) yield
|
|
450
|
+
if (!emitted) yield empty;
|
|
439
451
|
if (normalized.limit !== undefined && rowsReturned >= normalized.limit)
|
|
440
452
|
earlyTerminationReason = 'limit';
|
|
441
453
|
status = earlyTerminationReason ? 'early-terminated' : 'completed';
|
|
@@ -487,40 +499,25 @@ async function normalizeTypedQuery(query: Query): Promise<SQLQuery | TableQuery>
|
|
|
487
499
|
}
|
|
488
500
|
|
|
489
501
|
/** Emits original Arrow RecordBatches without copying their buffers. */
|
|
490
|
-
async function* memoryBatches(data: arrow.Table): AsyncIterable<
|
|
491
|
-
for (const batch of data.batches) yield
|
|
502
|
+
async function* memoryBatches(data: arrow.Table): AsyncIterable<arrow.Table> {
|
|
503
|
+
for (const batch of data.batches) yield new arrow.Table(data.schema, [batch]);
|
|
492
504
|
}
|
|
493
505
|
|
|
494
506
|
/** Converts supported native table batches to Arrow while preserving their declared schema. */
|
|
495
|
-
function normalizeBatch(value: unknown, fallbackSchema: Schema):
|
|
507
|
+
function normalizeBatch(value: unknown, fallbackSchema: Schema): arrow.Table {
|
|
496
508
|
if (!value || typeof value !== 'object') throw new Error('Unsupported query batch.');
|
|
497
509
|
if ('numRows' in value) {
|
|
498
510
|
const batch = value as arrow.RecordBatch;
|
|
499
|
-
return
|
|
511
|
+
return new arrow.Table(batch.schema, [batch]);
|
|
500
512
|
}
|
|
501
513
|
if (!('shape' in value)) throw new Error('Unsupported query batch.');
|
|
502
514
|
const input = value as TableBatch;
|
|
503
515
|
const batch = {...input, schema: input.schema ?? fallbackSchema} as TableBatch;
|
|
504
|
-
if (
|
|
505
|
-
!['arrow-table', 'object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape)
|
|
506
|
-
)
|
|
516
|
+
if (!['object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape))
|
|
507
517
|
throw new Error(`Unsupported query batch shape: ${batch.shape}`);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
: convertTableToArrow(batch);
|
|
512
|
-
return {...batch, ...wrapBatch(data)} as ArrowTableBatch;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/** Wraps Arrow data in the standard batch envelope. */
|
|
516
|
-
function wrapBatch(data: arrow.Table): ArrowTableBatch {
|
|
517
|
-
return {
|
|
518
|
-
shape: 'arrow-table',
|
|
519
|
-
data,
|
|
520
|
-
schema: convertArrowToSchema(data.schema),
|
|
521
|
-
batchType: 'data',
|
|
522
|
-
length: data.numRows
|
|
523
|
-
} as ArrowTableBatch;
|
|
518
|
+
return batch.length === 0 && batch.schema
|
|
519
|
+
? new arrow.Table(convertSchemaToArrow(batch.schema))
|
|
520
|
+
: convertTableToArrow(batch);
|
|
524
521
|
}
|
|
525
522
|
|
|
526
523
|
/** Checks predicate tree bounds and detects casts that require Arrow execution. */
|
|
@@ -591,7 +588,7 @@ function isUnsupportedQueryExpression(value: unknown): boolean {
|
|
|
591
588
|
);
|
|
592
589
|
}
|
|
593
590
|
|
|
594
|
-
export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/
|
|
591
|
+
export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/sql/parser';
|
|
595
592
|
|
|
596
593
|
export {createSQLCatalog} from './sql-catalog';
|
|
597
594
|
export type {SQLCatalog, SQLCatalogQuery, SQLCatalogSource, SQLCatalogTable} from './sql-catalog';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {RecordBatch, Table} from 'apache-arrow';
|
|
6
6
|
import {makeArrowMetadataBatch} from '@loaders.gl/core/schema-utils';
|
|
7
|
-
import
|
|
7
|
+
import {isArrowTable} from '../lib/loader-utils/native-arrow';
|
|
8
8
|
import {convertArrowToSchema} from '@loaders.gl/core/schema-utils';
|
|
9
9
|
import type {
|
|
10
10
|
GetFeaturesParameters,
|
|
@@ -61,7 +61,7 @@ export abstract class AddressedVectorTableScanSource {
|
|
|
61
61
|
/** Spatial extent of the bound physical selection. */
|
|
62
62
|
readonly spatial?: ScanSpatialMetadata;
|
|
63
63
|
|
|
64
|
-
private tablePromise: Promise<
|
|
64
|
+
private tablePromise: Promise<Table> | null = null;
|
|
65
65
|
|
|
66
66
|
/** Creates a table-scan view over one immutable physical selection. */
|
|
67
67
|
protected constructor(
|
|
@@ -79,12 +79,12 @@ export abstract class AddressedVectorTableScanSource {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/** Loads the physically addressed data as one Arrow table. */
|
|
82
|
-
protected abstract loadTable(signal?: AbortSignal): Promise<
|
|
82
|
+
protected abstract loadTable(signal?: AbortSignal): Promise<Table | null>;
|
|
83
83
|
|
|
84
84
|
/** Discovers the addressed result schema and portable residual-query capabilities. */
|
|
85
85
|
async getQueryMetadata(options: ScanQueryMetadataOptions = {}): Promise<ScanQueryMetadata> {
|
|
86
86
|
const table = await this.getTable(options.signal);
|
|
87
|
-
const schema =
|
|
87
|
+
const schema = convertArrowToSchema(table.schema);
|
|
88
88
|
return createScanQueryMetadata({
|
|
89
89
|
sourceType: this.sourceType,
|
|
90
90
|
queryType: 'table',
|
|
@@ -99,20 +99,20 @@ export abstract class AddressedVectorTableScanSource {
|
|
|
99
99
|
},
|
|
100
100
|
columnRoles: inferVectorColumnRoles(schema.fields.map(field => field.name)),
|
|
101
101
|
spatial: this.spatial,
|
|
102
|
-
statistics: {rowCount: table.
|
|
102
|
+
statistics: {rowCount: table.numRows}
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/** Applies the portable Arrow query to the addressed feature table. */
|
|
107
107
|
async query(options: ArrowQueryOptions = {}): Promise<Table> {
|
|
108
108
|
const table = await this.getTable(options.signal);
|
|
109
|
-
return queryArrowTable(table
|
|
109
|
+
return queryArrowTable(table, options);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/** Explains the residual Arrow plan after resolving the addressed feature table. */
|
|
113
113
|
async explain(options: ArrowQueryOptions = {}): Promise<TableQueryExplain<SQLPredicate>> {
|
|
114
114
|
const table = await this.getTable(options.signal);
|
|
115
|
-
return explainArrowTableQuery(table
|
|
115
|
+
return explainArrowTableQuery(table, options);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/** Emits the portable query result as one bounded Arrow batch. */
|
|
@@ -128,7 +128,7 @@ export abstract class AddressedVectorTableScanSource {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/** Resolves and caches the addressed table while allowing failed loads to be retried. */
|
|
131
|
-
private async getTable(signal?: AbortSignal): Promise<
|
|
131
|
+
private async getTable(signal?: AbortSignal): Promise<Table> {
|
|
132
132
|
throwIfAborted(signal);
|
|
133
133
|
if (!this.tablePromise) {
|
|
134
134
|
this.tablePromise = this.loadTable()
|
|
@@ -136,11 +136,6 @@ export abstract class AddressedVectorTableScanSource {
|
|
|
136
136
|
if (!table) {
|
|
137
137
|
throw new Error('The addressed vector selection did not return a feature table.');
|
|
138
138
|
}
|
|
139
|
-
if (table.shape !== 'arrow-table') {
|
|
140
|
-
throw new Error(
|
|
141
|
-
'The addressed vector selection must return an Arrow table. Configure the source with shape "arrow".'
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
139
|
return table;
|
|
145
140
|
})
|
|
146
141
|
.catch(error => {
|
|
@@ -183,12 +178,12 @@ export class VectorTileTableScanSource extends AddressedVectorTableScanSource {
|
|
|
183
178
|
}
|
|
184
179
|
|
|
185
180
|
/** Loads the bound vector tile using the source's requested Arrow output shape. */
|
|
186
|
-
protected loadTable(signal?: AbortSignal): Promise<
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
181
|
+
protected async loadTable(signal?: AbortSignal): Promise<Table | null> {
|
|
182
|
+
const tile = await this.source.getVectorTile({...this.tile, signal});
|
|
183
|
+
if (tile === null || isArrowTable(tile)) return tile;
|
|
184
|
+
throw new Error(
|
|
185
|
+
'The addressed vector selection must return an Arrow table. Configure the source with shape "arrow".'
|
|
186
|
+
);
|
|
192
187
|
}
|
|
193
188
|
}
|
|
194
189
|
|
|
@@ -232,9 +227,9 @@ export class VectorFeatureTableScanSource extends AddressedVectorTableScanSource
|
|
|
232
227
|
}
|
|
233
228
|
|
|
234
229
|
/** Loads the bound service request through the source's Arrow feature output. */
|
|
235
|
-
protected async loadTable(signal?: AbortSignal): Promise<
|
|
230
|
+
protected async loadTable(signal?: AbortSignal): Promise<Table | null> {
|
|
236
231
|
const data = await this.source.getFeatures({...this.request, format: 'arrow', signal});
|
|
237
|
-
return
|
|
232
|
+
return isArrowTable(data) ? data : null;
|
|
238
233
|
}
|
|
239
234
|
}
|
|
240
235
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {Schema} from '../types/schema';
|
|
6
6
|
import type {TypedArray} from '../types/types';
|
|
7
|
-
import type {ColumnarTable
|
|
7
|
+
import type {ColumnarTable} from './category-table';
|
|
8
8
|
import * as arrow from 'apache-arrow';
|
|
9
9
|
|
|
10
10
|
/** Mesh as columnar table */
|
|
@@ -14,16 +14,8 @@ export interface MeshTable extends ColumnarTable {
|
|
|
14
14
|
indices?: MeshAttribute;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
export
|
|
19
|
-
// shape: 'mesh-arrow-table';
|
|
20
|
-
/** Mesh topology represented by the Arrow table rows and indices. */
|
|
21
|
-
topology: MeshTopology;
|
|
22
|
-
/** Optional top-level primitive indices accessor for indexed meshes. */
|
|
23
|
-
indices?: MeshAttribute;
|
|
24
|
-
/** Raw Apache Arrow table data for Mesh or IndexedMesh columns. */
|
|
25
|
-
data: MeshArrowTableData | IndexedMeshArrowTableData;
|
|
26
|
-
}
|
|
17
|
+
/** Native Apache Arrow table carrying mesh columns and topology metadata. */
|
|
18
|
+
export type MeshArrowTable = arrow.Table;
|
|
27
19
|
|
|
28
20
|
/** Apache Arrow columns for a mesh vertex table. */
|
|
29
21
|
export type MeshArrowColumns = {
|
|
@@ -5,16 +5,9 @@
|
|
|
5
5
|
import type {Schema} from '../types/schema';
|
|
6
6
|
import type {Batch} from '../types/batch';
|
|
7
7
|
import type {Feature} from './category-gis';
|
|
8
|
-
import type * as arrow from 'apache-arrow';
|
|
9
8
|
|
|
10
9
|
/** A general table */
|
|
11
|
-
export type Table =
|
|
12
|
-
| RowTable
|
|
13
|
-
| ArrayRowTable
|
|
14
|
-
| ObjectRowTable
|
|
15
|
-
| GeoJSONTable
|
|
16
|
-
| ColumnarTable
|
|
17
|
-
| ArrowTable;
|
|
10
|
+
export type Table = RowTable | ArrayRowTable | ObjectRowTable | GeoJSONTable | ColumnarTable;
|
|
18
11
|
|
|
19
12
|
/** A table organized as an array of rows */
|
|
20
13
|
export type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;
|
|
@@ -53,15 +46,6 @@ export type ColumnarTable = {
|
|
|
53
46
|
data: {[columnName: string]: ArrayLike<unknown>};
|
|
54
47
|
};
|
|
55
48
|
|
|
56
|
-
/**
|
|
57
|
-
* A table that wraps an Apache Arrow table
|
|
58
|
-
*/
|
|
59
|
-
export type ArrowTable = {
|
|
60
|
-
shape: 'arrow-table';
|
|
61
|
-
schema?: Schema;
|
|
62
|
-
data: arrow.Table;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
49
|
/** A collection of tables */
|
|
66
50
|
export type Tables<TableType = Table> = {
|
|
67
51
|
shape: 'tables';
|
|
@@ -75,8 +59,7 @@ export type TableBatch =
|
|
|
75
59
|
| ArrayRowTableBatch
|
|
76
60
|
| ObjectRowTableBatch
|
|
77
61
|
| GeoJSONTableBatch
|
|
78
|
-
| ColumnarTableBatch
|
|
79
|
-
| ArrowTableBatch;
|
|
62
|
+
| ColumnarTableBatch;
|
|
80
63
|
|
|
81
64
|
/** Batch for a table organized as an array of rows, each row is an array of values */
|
|
82
65
|
export type ArrayRowTableBatch<MetadataT = unknown> = Batch<MetadataT> & {
|
|
@@ -114,12 +97,3 @@ export type ColumnarTableBatch<MetadataT = unknown> = Batch<MetadataT> & {
|
|
|
114
97
|
data: {[columnName: string]: ArrayLike<unknown>};
|
|
115
98
|
length: number;
|
|
116
99
|
};
|
|
117
|
-
|
|
118
|
-
/** Batch that wraps an Apache Arrow RecordBatch */
|
|
119
|
-
export type ArrowTableBatch<MetadataT = unknown> = Batch<MetadataT> & {
|
|
120
|
-
shape: 'arrow-table';
|
|
121
|
-
schemaType?: 'explicit' | 'deduced';
|
|
122
|
-
schema?: Schema;
|
|
123
|
-
data: arrow.Table; // RecordBatch wrapped in Table
|
|
124
|
-
length: number;
|
|
125
|
-
};
|
|
@@ -10,7 +10,7 @@ import type {BinaryGeometryType} from './binary-geometries';
|
|
|
10
10
|
export type ArrowBinaryFeatureTable = {
|
|
11
11
|
/** Geometry family stored in this table. */
|
|
12
12
|
type: BinaryGeometryType;
|
|
13
|
-
/** Arrow table
|
|
13
|
+
/** Native Arrow table for the family. */
|
|
14
14
|
table: arrow.Table;
|
|
15
15
|
/** Original feature-level properties sidecar from the binary feature collection. */
|
|
16
16
|
properties: BinaryProperties['properties'];
|
package/src/schema/index.ts
CHANGED
|
@@ -62,7 +62,6 @@ export type {
|
|
|
62
62
|
ObjectRowTable,
|
|
63
63
|
GeoJSONTable,
|
|
64
64
|
ColumnarTable,
|
|
65
|
-
ArrowTable,
|
|
66
65
|
Tables
|
|
67
66
|
} from './categories/category-table';
|
|
68
67
|
export type {
|
|
@@ -70,8 +69,7 @@ export type {
|
|
|
70
69
|
ArrayRowTableBatch,
|
|
71
70
|
ObjectRowTableBatch,
|
|
72
71
|
GeoJSONTableBatch,
|
|
73
|
-
ColumnarTableBatch
|
|
74
|
-
ArrowTableBatch
|
|
72
|
+
ColumnarTableBatch
|
|
75
73
|
} from './categories/category-table';
|
|
76
74
|
|
|
77
75
|
// MESH CATEGORY
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Schema} from './schema';
|
|
6
|
-
// import type {RecordBatch} from 'apache-arrow';
|
|
7
|
-
|
|
8
|
-
type ApacheRecordBatch = unknown;
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* A batch of data (or metadata/schema), from a streaming loader
|
|
@@ -23,8 +20,6 @@ export type Batch<MetadataT = unknown> = {
|
|
|
23
20
|
schema?: Schema;
|
|
24
21
|
/** Data in this batch */
|
|
25
22
|
data?: unknown;
|
|
26
|
-
/** If this is an arrow table. @deprecated Use `data` */
|
|
27
|
-
recordBatch?: ApacheRecordBatch;
|
|
28
23
|
/** Length of data in this batch */
|
|
29
24
|
length: number;
|
|
30
25
|
|
|
@@ -29,11 +29,6 @@ export type {
|
|
|
29
29
|
export {getArrowViewTypeSupport} from './lib/schema/convert-arrow-schema';
|
|
30
30
|
export {getDataTypeFromArray} from './lib/schema/data-type';
|
|
31
31
|
|
|
32
|
-
export {
|
|
33
|
-
convertArrowTable,
|
|
34
|
-
convertArrowTableBatch
|
|
35
|
-
} from './lib/table/tables/convert-arrow-table-wrapper';
|
|
36
|
-
|
|
37
32
|
// TABLE CATEGORY UTILS
|
|
38
33
|
|
|
39
34
|
export {deduceTableSchema} from './lib/schema/deduce-table-schema';
|
|
@@ -67,8 +62,7 @@ export {
|
|
|
67
62
|
isArrayRowTable,
|
|
68
63
|
isObjectRowTable,
|
|
69
64
|
isColumnarTable,
|
|
70
|
-
isGeoJSONTable
|
|
71
|
-
isArrowTable
|
|
65
|
+
isGeoJSONTable
|
|
72
66
|
} from './lib/table/tables/table-types';
|
|
73
67
|
|
|
74
68
|
export {
|
|
@@ -98,7 +92,7 @@ export {ArrowLikeTable} from './lib/table/arrow-api/arrow-like-table';
|
|
|
98
92
|
export {getMeshSize, getMeshBoundingBox} from './lib/mesh/mesh-utils';
|
|
99
93
|
export {
|
|
100
94
|
convertMeshToTable,
|
|
101
|
-
|
|
95
|
+
convertMeshToArrowTable,
|
|
102
96
|
makeMeshArrowTable
|
|
103
97
|
} from './lib/mesh/convert-mesh-to-table';
|
|
104
98
|
export type {MeshArrowTableOptions} from './lib/mesh/convert-mesh-to-table';
|
|
@@ -171,10 +165,10 @@ export {
|
|
|
171
165
|
snapshotArrowSchema,
|
|
172
166
|
mergeArrowSchemas,
|
|
173
167
|
updateArrowTableSchema,
|
|
174
|
-
|
|
168
|
+
updateNativeArrowTableMetadata,
|
|
175
169
|
makeArrowMetadataBatch,
|
|
176
170
|
makeArrowTableFromBatches
|
|
177
171
|
} from './lib/arrow/arrow-metadata';
|
|
178
172
|
export {refineArrowTableBatches} from './lib/arrow/arrow-metadata';
|
|
179
173
|
|
|
180
|
-
export {
|
|
174
|
+
export {isArrowRecordBatch, isArrowTable} from '../lib/loader-utils/native-arrow';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
-
import type {Field, DataType
|
|
6
|
+
import type {Field, DataType} from '@loaders.gl/core/schema';
|
|
7
7
|
import {serializeArrowSchema, deserializeArrowSchema} from '../schema/convert-arrow-schema';
|
|
8
8
|
|
|
9
9
|
/** Copies a schema, including nested field metadata, without retaining mutable metadata maps. */
|
|
@@ -55,13 +55,24 @@ function mergeTypeMetadata(previous: DataType, next: DataType): DataType {
|
|
|
55
55
|
return next;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/** Snapshots a batch's schema and metadata while retaining its data buffers and row count. */
|
|
59
|
+
function snapshotArrowBatch(batch: arrow.RecordBatch, schema: arrow.Schema): arrow.RecordBatch {
|
|
60
|
+
const snapshot = new arrow.RecordBatch(
|
|
61
|
+
snapshotArrowSchema(schema),
|
|
62
|
+
batch.data,
|
|
63
|
+
new Map(batch.metadata)
|
|
64
|
+
);
|
|
65
|
+
// Arrow reconstructs the Struct length from its columns, which are absent in zero-column batches.
|
|
66
|
+
if (snapshot.numRows !== batch.numRows) {
|
|
67
|
+
Object.defineProperty(snapshot, 'data', {value: batch.data});
|
|
68
|
+
}
|
|
69
|
+
return snapshot;
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
/** Applies a table schema snapshot to its batches while retaining batch-local custom metadata. */
|
|
59
73
|
export function updateArrowTableSchema(table: arrow.Table, schema: arrow.Schema): arrow.Table {
|
|
60
74
|
const snapshot = snapshotArrowSchema(schema);
|
|
61
|
-
const batches = table.batches.map(
|
|
62
|
-
batch =>
|
|
63
|
-
new arrow.RecordBatch(snapshotArrowSchema(snapshot), batch.data, new Map(batch.metadata))
|
|
64
|
-
);
|
|
75
|
+
const batches = table.batches.map(batch => snapshotArrowBatch(batch, snapshot));
|
|
65
76
|
// Preserve declared schemas even for schema-only empty tables.
|
|
66
77
|
return new arrow.Table(
|
|
67
78
|
snapshot,
|
|
@@ -69,17 +80,16 @@ export function updateArrowTableSchema(table: arrow.Table, schema: arrow.Schema)
|
|
|
69
80
|
);
|
|
70
81
|
}
|
|
71
82
|
|
|
72
|
-
/** Updates
|
|
73
|
-
export function
|
|
74
|
-
table:
|
|
83
|
+
/** Updates native Arrow metadata while preserving independent batch snapshots. */
|
|
84
|
+
export function updateNativeArrowTableMetadata(
|
|
85
|
+
table: arrow.Table,
|
|
75
86
|
metadata: Record<string, string>
|
|
76
|
-
):
|
|
87
|
+
): arrow.Table {
|
|
77
88
|
const schema = new arrow.Schema(
|
|
78
|
-
table.
|
|
79
|
-
new Map([...table.
|
|
89
|
+
table.schema.fields,
|
|
90
|
+
new Map([...table.schema.metadata, ...Object.entries(metadata)])
|
|
80
91
|
);
|
|
81
|
-
|
|
82
|
-
return {...table, data, schema: serializeArrowSchema(data.schema)};
|
|
92
|
+
return updateArrowTableSchema(table, schema);
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
/** Creates a zero-row metadata update retaining the complete declared schema. */
|
|
@@ -95,27 +105,20 @@ export async function makeArrowTableFromBatches(
|
|
|
95
105
|
const collected: arrow.RecordBatch[] = [];
|
|
96
106
|
for await (const batch of batches) {
|
|
97
107
|
schema = mergeArrowSchemas(schema, batch.schema);
|
|
98
|
-
collected.push(
|
|
99
|
-
new arrow.RecordBatch(snapshotArrowSchema(batch.schema), batch.data, new Map(batch.metadata))
|
|
100
|
-
);
|
|
108
|
+
collected.push(snapshotArrowBatch(batch, batch.schema));
|
|
101
109
|
}
|
|
102
110
|
return schema ? new arrow.Table(schema, collected) : null;
|
|
103
111
|
}
|
|
104
112
|
|
|
105
|
-
/**
|
|
106
|
-
export async function* refineArrowTableBatches
|
|
107
|
-
batches: AsyncIterable<
|
|
108
|
-
): AsyncIterable<
|
|
113
|
+
/** Snapshots native Arrow schemas, accumulating bounds and retaining local batch bounds. */
|
|
114
|
+
export async function* refineArrowTableBatches(
|
|
115
|
+
batches: AsyncIterable<arrow.Table> | Iterable<arrow.Table>
|
|
116
|
+
): AsyncIterable<arrow.Table> {
|
|
109
117
|
let schema: arrow.Schema | undefined;
|
|
110
118
|
let bounds: number[][] | undefined;
|
|
111
|
-
for await (const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
yield batch;
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
const localBounds = table.data.schema.metadata.get('boundingBox');
|
|
118
|
-
const nextSchema = snapshotArrowSchema(table.data.schema);
|
|
119
|
+
for await (const table of batches) {
|
|
120
|
+
const localBounds = table.schema.metadata.get('boundingBox');
|
|
121
|
+
const nextSchema = snapshotArrowSchema(table.schema);
|
|
119
122
|
if (localBounds) {
|
|
120
123
|
const nextBounds = JSON.parse(localBounds) as number[][];
|
|
121
124
|
bounds = bounds
|
|
@@ -127,10 +130,10 @@ export async function* refineArrowTableBatches<T>(
|
|
|
127
130
|
nextSchema.metadata.set('boundingBox', JSON.stringify(bounds));
|
|
128
131
|
}
|
|
129
132
|
schema = mergeArrowSchemas(schema, nextSchema);
|
|
130
|
-
const data = updateArrowTableSchema(table
|
|
133
|
+
const data = updateArrowTableSchema(table, schema);
|
|
131
134
|
if (localBounds) {
|
|
132
135
|
for (const recordBatch of data.batches) recordBatch.metadata.set('boundingBox', localBounds);
|
|
133
136
|
}
|
|
134
|
-
yield
|
|
137
|
+
yield data;
|
|
135
138
|
}
|
|
136
139
|
}
|