@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Table, type Schema } from 'apache-arrow';
|
|
2
|
-
import type { SQLQuery } from '@math.gl/
|
|
2
|
+
import type { SQLQuery } from '@math.gl/sql/parser';
|
|
3
3
|
import type { TableQueryCapabilities, TableScanSource, TableQueryPushdownPlan } from '@loaders.gl/core/loader-utils';
|
|
4
4
|
/** Source plan with an optional final Arrow projection. */
|
|
5
5
|
type NegotiatedQueryPlan = TableQueryPushdownPlan & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-pushdown.d.ts","sourceRoot":"","sources":["../../src/scan/query-pushdown.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,EAAQ,KAAK,MAAM,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"query-pushdown.d.ts","sourceRoot":"","sources":["../../src/scan/query-pushdown.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,EAAQ,KAAK,MAAM,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACvB,MAAM,+BAA+B,CAAC;AAEvC,2DAA2D;AAC3D,KAAK,mBAAmB,GAAG,sBAAsB,GAAG;IAClD,kFAAkF;IAClF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC;CACnC,CAAC;AAEF,iGAAiG;AACjG,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CAAC,EAC5C,YAAY,EAAE,sBAAsB,GAAG,SAAS,EAChD,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAUrC"}
|
|
@@ -30,17 +30,14 @@ function validatePushdownPlan(plan, outputSchema, limit, signal) {
|
|
|
30
30
|
let rowsReturned = 0;
|
|
31
31
|
for await (const batch of plan.read(options)) {
|
|
32
32
|
options.signal?.throwIfAborted();
|
|
33
|
-
|
|
34
|
-
const schema = native ? batch.schema : batch.data.schema;
|
|
35
|
-
const rowCount = native ? batch.numRows : batch.data.numRows;
|
|
36
|
-
if (!util.compareSchemas(outputSchema, convertSchemaToArrow(convertArrowToSchema(schema)))) {
|
|
33
|
+
if (!util.compareSchemas(outputSchema, convertSchemaToArrow(convertArrowToSchema(batch.schema)))) {
|
|
37
34
|
throw new Error('Query pushdown batch schema does not match the logical output schema.');
|
|
38
35
|
}
|
|
39
|
-
rowsReturned +=
|
|
36
|
+
rowsReturned += batch.numRows;
|
|
40
37
|
if (limit !== undefined && rowsReturned > limit) {
|
|
41
38
|
throw new Error('Query pushdown returned more rows than the requested limit.');
|
|
42
39
|
}
|
|
43
|
-
yield
|
|
40
|
+
yield batch;
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46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,MAAM;YAEjD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/scan/query-scales.ts
|
|
21
|
+
var query_scales_exports = {};
|
|
22
|
+
__export(query_scales_exports, {
|
|
23
|
+
queryScales: () => queryScales,
|
|
24
|
+
queryScalesInBatches: () => queryScalesInBatches,
|
|
25
|
+
queryScalesProgressive: () => queryScalesProgressive
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(query_scales_exports);
|
|
28
|
+
var import_apache_arrow = require("apache-arrow");
|
|
29
|
+
var import_arrow_scales = require("@math.gl/sql/arrow-scales");
|
|
30
|
+
var import_scales = require("@math.gl/sql/scales");
|
|
31
|
+
var import_schema_utils = require("@loaders.gl/core/schema-utils");
|
|
32
|
+
var import_query = require("./query.cjs");
|
|
33
|
+
async function queryScales(input, projections, options) {
|
|
34
|
+
options.signal?.throwIfAborted();
|
|
35
|
+
const parsed = parseScaleProjections(projections);
|
|
36
|
+
const table = await (0, import_query.query)(input, options);
|
|
37
|
+
options.signal?.throwIfAborted();
|
|
38
|
+
return evaluateScaleProjections(table, (0, import_arrow_scales.compileArrowScales)(table, parsed), options.signal);
|
|
39
|
+
}
|
|
40
|
+
function evaluateScaleProjections(table, compiled, signal) {
|
|
41
|
+
const names = Object.keys(compiled);
|
|
42
|
+
const columns = {};
|
|
43
|
+
const scales = {};
|
|
44
|
+
for (const name of names) {
|
|
45
|
+
signal?.throwIfAborted();
|
|
46
|
+
const scale = compiled[name];
|
|
47
|
+
Object.defineProperty(columns, name, { value: scale.evaluate(table), enumerable: true });
|
|
48
|
+
Object.defineProperty(scales, name, { value: scale.scale, enumerable: true });
|
|
49
|
+
}
|
|
50
|
+
return { table, columns, scales };
|
|
51
|
+
}
|
|
52
|
+
function parseScaleProjections(projections) {
|
|
53
|
+
return Object.fromEntries(
|
|
54
|
+
Object.entries(projections).map(([name, expression]) => [
|
|
55
|
+
name,
|
|
56
|
+
typeof expression === "string" ? (0, import_scales.parseSQLScaleExpression)(expression) : expression
|
|
57
|
+
])
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
async function* queryScalesInBatches(input, projections, options) {
|
|
61
|
+
options.signal?.throwIfAborted();
|
|
62
|
+
const parsed = parseScaleProjections(projections);
|
|
63
|
+
if (Object.values(parsed).some(({ scale }) => scale.domain.type !== "fixed")) {
|
|
64
|
+
throw new Error("Append-only scale projections require fixed domains.");
|
|
65
|
+
}
|
|
66
|
+
let compiled;
|
|
67
|
+
for await (const batch of (0, import_query.queryInBatches)(input, { ...options, queryOutput: "batches" })) {
|
|
68
|
+
options.signal?.throwIfAborted();
|
|
69
|
+
compiled ??= (0, import_arrow_scales.compileArrowScales)(new import_apache_arrow.Table(batch.schema), parsed);
|
|
70
|
+
yield evaluateScaleProjections(new import_apache_arrow.Table(batch.schema, [batch]), compiled, options.signal);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function* queryScalesProgressive(input, projections, options) {
|
|
74
|
+
const { emitEveryBatches = 16, maxRetainedRows = 1e5, quantileCapacity, signal } = options;
|
|
75
|
+
signal?.throwIfAborted();
|
|
76
|
+
if (!Number.isSafeInteger(emitEveryBatches) || emitEveryBatches < 1 || !Number.isSafeInteger(maxRetainedRows) || maxRetainedRows < 1) {
|
|
77
|
+
throw new Error("Scale snapshot interval and row limit must be positive integers.");
|
|
78
|
+
}
|
|
79
|
+
const parsed = parseScaleProjections(projections);
|
|
80
|
+
const entries = Object.entries(parsed);
|
|
81
|
+
if (entries.some(([, { scale }]) => scale.type === "quantile")) {
|
|
82
|
+
throw new Error("Progressive quantile classification requires a resolved Arrow scale binder.");
|
|
83
|
+
}
|
|
84
|
+
const accumulator = (0, import_arrow_scales.createStreamingDomainAccumulator)(
|
|
85
|
+
entries.map(([, { scale }]) => scale.domain),
|
|
86
|
+
{ quantileCapacity }
|
|
87
|
+
);
|
|
88
|
+
const batches = [];
|
|
89
|
+
let retainedRows = 0;
|
|
90
|
+
let batchesSinceEmission = 0;
|
|
91
|
+
let last;
|
|
92
|
+
async function snapshot(final2 = false) {
|
|
93
|
+
const domains = accumulator.result();
|
|
94
|
+
if (domains.some((domain) => domain.length === 0)) return void 0;
|
|
95
|
+
if (!final2 && entries.some(
|
|
96
|
+
([, { scale }], index) => scale.type === "quantize" && scale.range.type === "palette" && (scale.range.count ?? 0) > 2 && domains[index][0] === domains[index][1]
|
|
97
|
+
))
|
|
98
|
+
return void 0;
|
|
99
|
+
const table = await (0, import_schema_utils.makeArrowTableFromBatches)(batches);
|
|
100
|
+
signal?.throwIfAborted();
|
|
101
|
+
if (!table) return void 0;
|
|
102
|
+
const schemaOnly = new import_apache_arrow.Table(table.schema);
|
|
103
|
+
const compiled = Object.fromEntries(
|
|
104
|
+
entries.map(([name, expression], index) => [
|
|
105
|
+
name,
|
|
106
|
+
(0, import_arrow_scales.compileArrowScale)(schemaOnly, expression, domains[index])
|
|
107
|
+
])
|
|
108
|
+
);
|
|
109
|
+
return evaluateScaleProjections(table, compiled, signal);
|
|
110
|
+
}
|
|
111
|
+
for await (const batch of (0, import_query.queryInBatches)(input, { ...options, queryOutput: "batches" })) {
|
|
112
|
+
signal?.throwIfAborted();
|
|
113
|
+
retainedRows += batch.numRows;
|
|
114
|
+
if (retainedRows > maxRetainedRows) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
`Progressive scale query exceeded its retained row limit (${maxRetainedRows}).`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
batches.push(batch);
|
|
120
|
+
if (batch.numRows === 0) continue;
|
|
121
|
+
accumulator.update(batch);
|
|
122
|
+
if (++batchesSinceEmission < emitEveryBatches) continue;
|
|
123
|
+
last = await snapshot();
|
|
124
|
+
if (last) {
|
|
125
|
+
batchesSinceEmission = 0;
|
|
126
|
+
yield { ...last, final: false };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
signal?.throwIfAborted();
|
|
130
|
+
const final = last && batchesSinceEmission === 0 ? last : await snapshot(true);
|
|
131
|
+
if (!final) throw new Error("Progressive scale query could not resolve its domain.");
|
|
132
|
+
yield { ...final, final: true };
|
|
133
|
+
}
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
queryScales,
|
|
137
|
+
queryScalesInBatches,
|
|
138
|
+
queryScalesProgressive
|
|
139
|
+
});
|
|
140
|
+
//# sourceMappingURL=query-scales.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/scan/query-scales.ts"],
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Table, type RecordBatch, type Vector} from 'apache-arrow';\nimport {\n compileArrowScale,\n compileArrowScales,\n createStreamingDomainAccumulator,\n type CompiledArrowScale\n} from '@math.gl/sql/arrow-scales';\nimport {\n parseSQLScaleExpression,\n type ParsedSQLScale,\n type ResolvedScale\n} from '@math.gl/sql/scales';\nimport {makeArrowTableFromBatches} from '@loaders.gl/core/schema-utils';\nimport {query, queryInBatches, type Query, type QueryOptions} from './query';\n\n/** Named row-preserving scale expressions applied to an input query result. */\nexport type ScaleProjections<Name extends string = string> = Readonly<\n Record<Name, string | ParsedSQLScale>\n>;\n\n/** Filtered input rows and scale outputs in the same row order. */\nexport type ScaleQueryResult<Name extends string = string> = Readonly<{\n /** Input rows after applying the table query, including any filter and row window. */\n table: Table;\n /** Arrow vectors keyed by scale projection name. */\n columns: Readonly<Record<Name, Vector>>;\n /** Scale evaluators and serializable descriptors shared with legend consumers. */\n scales: Readonly<Record<Name, ResolvedScale>>;\n}>;\n\n/** Resolves data-derived domains jointly, then evaluates each scale over the same rows. */\nexport async function queryScales<Name extends string>(\n input: Query | string,\n projections: ScaleProjections<Name>,\n options: QueryOptions\n): Promise<ScaleQueryResult<Name>> {\n options.signal?.throwIfAborted();\n const parsed = parseScaleProjections(projections);\n const table = await query(input, options);\n options.signal?.throwIfAborted();\n return evaluateScaleProjections(table, compileArrowScales(table, parsed), options.signal);\n}\n\n/** Evaluates pre-bound scales and exposes their authoritative descriptors. */\nfunction evaluateScaleProjections<Name extends string>(\n table: Table,\n compiled: Record<Name, CompiledArrowScale>,\n signal?: AbortSignal\n): ScaleQueryResult<Name> {\n const names = Object.keys(compiled) as Name[];\n const columns = {} as Record<Name, Vector>;\n const scales = {} as Record<Name, ResolvedScale>;\n for (const name of names) {\n signal?.throwIfAborted();\n const scale = compiled[name];\n Object.defineProperty(columns, name, {value: scale.evaluate(table), enumerable: true});\n Object.defineProperty(scales, name, {value: scale.scale, enumerable: true});\n }\n return {table, columns, scales};\n}\n\n/** Parses scale expressions before starting a read and preserves projection names. */\nfunction parseScaleProjections<Name extends string>(\n projections: ScaleProjections<Name>\n): Record<Name, ParsedSQLScale> {\n return Object.fromEntries(\n Object.entries<string | ParsedSQLScale>(projections).map(([name, expression]) => [\n name,\n typeof expression === 'string' ? parseSQLScaleExpression(expression) : expression\n ])\n ) as Record<Name, ParsedSQLScale>;\n}\n\n/** Emits append-only scale projections using caller-supplied fixed domains. */\nexport async function* queryScalesInBatches<Name extends string>(\n input: Query | string,\n projections: ScaleProjections<Name>,\n options: QueryOptions\n): AsyncIterable<ScaleQueryResult<Name>> {\n options.signal?.throwIfAborted();\n const parsed = parseScaleProjections(projections);\n if (Object.values<ParsedSQLScale>(parsed).some(({scale}) => scale.domain.type !== 'fixed')) {\n throw new Error('Append-only scale projections require fixed domains.');\n }\n /** Scales compiled once, using the schema from the first batch. */\n let compiled: Record<Name, CompiledArrowScale> | undefined;\n for await (const batch of queryInBatches(input, {...options, queryOutput: 'batches'})) {\n options.signal?.throwIfAborted();\n compiled ??= compileArrowScales(new Table(batch.schema), parsed);\n yield evaluateScaleProjections(new Table(batch.schema, [batch]), compiled, options.signal);\n }\n}\n\n/** Controls the cadence and retained row count of complete scale snapshots. */\nexport type ProgressiveScaleQueryOptions = QueryOptions &\n Readonly<{\n /** Emit a provisional snapshot after this many nonempty batches. Defaults to 16. */\n emitEveryBatches?: number;\n /** Maximum retained input rows for recoloring. Defaults to 100,000. */\n maxRetainedRows?: number;\n /** Retained samples per percentile column in the upstream quantile sketch. */\n quantileCapacity?: number;\n }>;\n\n/** Complete scale outputs that replace the previous snapshot. */\nexport type ProgressiveScaleSnapshot<Name extends string = string> = ScaleQueryResult<Name> &\n Readonly<{\n /** Whether the source finished and the resolved domains are final. */\n final: boolean;\n }>;\n\n/** Resolves progressive domains from one source pass and recolors retained rows on publication. */\nexport async function* queryScalesProgressive<Name extends string>(\n input: Query | string,\n projections: ScaleProjections<Name>,\n options: ProgressiveScaleQueryOptions\n): AsyncIterable<ProgressiveScaleSnapshot<Name>> {\n const {emitEveryBatches = 16, maxRetainedRows = 100_000, quantileCapacity, signal} = options;\n signal?.throwIfAborted();\n if (\n !Number.isSafeInteger(emitEveryBatches) ||\n emitEveryBatches < 1 ||\n !Number.isSafeInteger(maxRetainedRows) ||\n maxRetainedRows < 1\n ) {\n throw new Error('Scale snapshot interval and row limit must be positive integers.');\n }\n const parsed = parseScaleProjections(projections);\n const entries = Object.entries<ParsedSQLScale>(parsed) as [Name, ParsedSQLScale][];\n if (entries.some(([, {scale}]) => scale.type === 'quantile')) {\n throw new Error('Progressive quantile classification requires a resolved Arrow scale binder.');\n }\n const accumulator = createStreamingDomainAccumulator(\n entries.map(([, {scale}]) => scale.domain),\n {quantileCapacity}\n );\n const batches: RecordBatch[] = [];\n let retainedRows = 0;\n let batchesSinceEmission = 0;\n let last: ScaleQueryResult<Name> | undefined;\n\n /** Binds the current statistics and evaluates the selected snapshot. */\n async function snapshot(final = false): Promise<ScaleQueryResult<Name> | undefined> {\n const domains = accumulator.result();\n if (domains.some(domain => domain.length === 0)) return undefined;\n // math.gl beta.11 cannot bind repeated quantize breaks. Defer publication\n // until the extent grows, while still surfacing final domain errors.\n if (\n !final &&\n entries.some(\n ([, {scale}], index) =>\n scale.type === 'quantize' &&\n scale.range.type === 'palette' &&\n (scale.range.count ?? 0) > 2 &&\n domains[index][0] === domains[index][1]\n )\n )\n return undefined;\n\n const table = await makeArrowTableFromBatches(batches);\n signal?.throwIfAborted();\n if (!table) return undefined;\n const schemaOnly = new Table(table.schema);\n const compiled = Object.fromEntries(\n entries.map(([name, expression], index) => [\n name,\n compileArrowScale(schemaOnly, expression, domains[index])\n ])\n ) as Record<Name, CompiledArrowScale>;\n return evaluateScaleProjections(table, compiled, signal);\n }\n\n for await (const batch of queryInBatches(input, {...options, queryOutput: 'batches'})) {\n signal?.throwIfAborted();\n retainedRows += batch.numRows;\n if (retainedRows > maxRetainedRows) {\n throw new Error(\n `Progressive scale query exceeded its retained row limit (${maxRetainedRows}).`\n );\n }\n batches.push(batch);\n if (batch.numRows === 0) continue;\n accumulator.update(batch);\n if (++batchesSinceEmission < emitEveryBatches) continue;\n last = await snapshot();\n if (last) {\n batchesSinceEmission = 0;\n yield {...last, final: false};\n }\n }\n signal?.throwIfAborted();\n const final = last && batchesSinceEmission === 0 ? last : await snapshot(true);\n if (!final) throw new Error('Progressive scale query could not resolve its domain.');\n yield {...final, final: true};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAmD;AACnD,0BAKO;AACP,oBAIO;AACP,0BAAwC;AACxC,mBAAmE;AAkBnE,eAAsB,YACpB,OACA,aACA,SACiC;AACjC,UAAQ,QAAQ,eAAe;AAC/B,QAAM,SAAS,sBAAsB,WAAW;AAChD,QAAM,QAAQ,UAAM,oBAAM,OAAO,OAAO;AACxC,UAAQ,QAAQ,eAAe;AAC/B,SAAO,yBAAyB,WAAO,wCAAmB,OAAO,MAAM,GAAG,QAAQ,MAAM;AAC1F;AAGA,SAAS,yBACP,OACA,UACA,QACwB;AACxB,QAAM,QAAQ,OAAO,KAAK,QAAQ;AAClC,QAAM,UAAU,CAAC;AACjB,QAAM,SAAS,CAAC;AAChB,aAAW,QAAQ,OAAO;AACxB,YAAQ,eAAe;AACvB,UAAM,QAAQ,SAAS,IAAI;AAC3B,WAAO,eAAe,SAAS,MAAM,EAAC,OAAO,MAAM,SAAS,KAAK,GAAG,YAAY,KAAI,CAAC;AACrF,WAAO,eAAe,QAAQ,MAAM,EAAC,OAAO,MAAM,OAAO,YAAY,KAAI,CAAC;AAAA,EAC5E;AACA,SAAO,EAAC,OAAO,SAAS,OAAM;AAChC;AAGA,SAAS,sBACP,aAC8B;AAC9B,SAAO,OAAO;AAAA,IACZ,OAAO,QAAiC,WAAW,EAAE,IAAI,CAAC,CAAC,MAAM,UAAU,MAAM;AAAA,MAC/E;AAAA,MACA,OAAO,eAAe,eAAW,uCAAwB,UAAU,IAAI;AAAA,IACzE,CAAC;AAAA,E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MAAM,SAAS,IAAI;AAC7E,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,uDAAuD;AACnF,QAAM,EAAC,GAAG,OAAO,OAAO,KAAI;AAC9B;",
|
|
6
|
+
"names": ["final"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Table, type Vector } from 'apache-arrow';
|
|
2
|
+
import { type ParsedSQLScale, type ResolvedScale } from '@math.gl/sql/scales';
|
|
3
|
+
import { type Query, type QueryOptions } from "./query.js";
|
|
4
|
+
/** Named row-preserving scale expressions applied to an input query result. */
|
|
5
|
+
export type ScaleProjections<Name extends string = string> = Readonly<Record<Name, string | ParsedSQLScale>>;
|
|
6
|
+
/** Filtered input rows and scale outputs in the same row order. */
|
|
7
|
+
export type ScaleQueryResult<Name extends string = string> = Readonly<{
|
|
8
|
+
/** Input rows after applying the table query, including any filter and row window. */
|
|
9
|
+
table: Table;
|
|
10
|
+
/** Arrow vectors keyed by scale projection name. */
|
|
11
|
+
columns: Readonly<Record<Name, Vector>>;
|
|
12
|
+
/** Scale evaluators and serializable descriptors shared with legend consumers. */
|
|
13
|
+
scales: Readonly<Record<Name, ResolvedScale>>;
|
|
14
|
+
}>;
|
|
15
|
+
/** Resolves data-derived domains jointly, then evaluates each scale over the same rows. */
|
|
16
|
+
export declare function queryScales<Name extends string>(input: Query | string, projections: ScaleProjections<Name>, options: QueryOptions): Promise<ScaleQueryResult<Name>>;
|
|
17
|
+
/** Emits append-only scale projections using caller-supplied fixed domains. */
|
|
18
|
+
export declare function queryScalesInBatches<Name extends string>(input: Query | string, projections: ScaleProjections<Name>, options: QueryOptions): AsyncIterable<ScaleQueryResult<Name>>;
|
|
19
|
+
/** Controls the cadence and retained row count of complete scale snapshots. */
|
|
20
|
+
export type ProgressiveScaleQueryOptions = QueryOptions & Readonly<{
|
|
21
|
+
/** Emit a provisional snapshot after this many nonempty batches. Defaults to 16. */
|
|
22
|
+
emitEveryBatches?: number;
|
|
23
|
+
/** Maximum retained input rows for recoloring. Defaults to 100,000. */
|
|
24
|
+
maxRetainedRows?: number;
|
|
25
|
+
/** Retained samples per percentile column in the upstream quantile sketch. */
|
|
26
|
+
quantileCapacity?: number;
|
|
27
|
+
}>;
|
|
28
|
+
/** Complete scale outputs that replace the previous snapshot. */
|
|
29
|
+
export type ProgressiveScaleSnapshot<Name extends string = string> = ScaleQueryResult<Name> & Readonly<{
|
|
30
|
+
/** Whether the source finished and the resolved domains are final. */
|
|
31
|
+
final: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
/** Resolves progressive domains from one source pass and recolors retained rows on publication. */
|
|
34
|
+
export declare function queryScalesProgressive<Name extends string>(input: Query | string, projections: ScaleProjections<Name>, options: ProgressiveScaleQueryOptions): AsyncIterable<ProgressiveScaleSnapshot<Name>>;
|
|
35
|
+
//# sourceMappingURL=query-scales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-scales.d.ts","sourceRoot":"","sources":["../../src/scan/query-scales.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,EAAoB,KAAK,MAAM,EAAC,MAAM,cAAc,CAAC;AAOlE,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAwB,KAAK,KAAK,EAAE,KAAK,YAAY,EAAC,mBAAgB;AAE7E,+EAA+E;AAC/E,MAAM,MAAM,gBAAgB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CACnE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,CACtC,CAAC;AAEF,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CAAC;IACpE,sFAAsF;IACtF,KAAK,EAAE,KAAK,CAAC;IACb,oDAAoD;IACpD,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CA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A8E/C"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { Table } from 'apache-arrow';
|
|
5
|
+
import { compileArrowScale, compileArrowScales, createStreamingDomainAccumulator } from '@math.gl/sql/arrow-scales';
|
|
6
|
+
import { parseSQLScaleExpression } from '@math.gl/sql/scales';
|
|
7
|
+
import { makeArrowTableFromBatches } from '@loaders.gl/core/schema-utils';
|
|
8
|
+
import { query, queryInBatches } from "./query.js";
|
|
9
|
+
/** Resolves data-derived domains jointly, then evaluates each scale over the same rows. */
|
|
10
|
+
export async function queryScales(input, projections, options) {
|
|
11
|
+
options.signal?.throwIfAborted();
|
|
12
|
+
const parsed = parseScaleProjections(projections);
|
|
13
|
+
const table = await query(input, options);
|
|
14
|
+
options.signal?.throwIfAborted();
|
|
15
|
+
return evaluateScaleProjections(table, compileArrowScales(table, parsed), options.signal);
|
|
16
|
+
}
|
|
17
|
+
/** Evaluates pre-bound scales and exposes their authoritative descriptors. */
|
|
18
|
+
function evaluateScaleProjections(table, compiled, signal) {
|
|
19
|
+
const names = Object.keys(compiled);
|
|
20
|
+
const columns = {};
|
|
21
|
+
const scales = {};
|
|
22
|
+
for (const name of names) {
|
|
23
|
+
signal?.throwIfAborted();
|
|
24
|
+
const scale = compiled[name];
|
|
25
|
+
Object.defineProperty(columns, name, { value: scale.evaluate(table), enumerable: true });
|
|
26
|
+
Object.defineProperty(scales, name, { value: scale.scale, enumerable: true });
|
|
27
|
+
}
|
|
28
|
+
return { table, columns, scales };
|
|
29
|
+
}
|
|
30
|
+
/** Parses scale expressions before starting a read and preserves projection names. */
|
|
31
|
+
function parseScaleProjections(projections) {
|
|
32
|
+
return Object.fromEntries(Object.entries(projections).map(([name, expression]) => [
|
|
33
|
+
name,
|
|
34
|
+
typeof expression === 'string' ? parseSQLScaleExpression(expression) : expression
|
|
35
|
+
]));
|
|
36
|
+
}
|
|
37
|
+
/** Emits append-only scale projections using caller-supplied fixed domains. */
|
|
38
|
+
export async function* queryScalesInBatches(input, projections, options) {
|
|
39
|
+
options.signal?.throwIfAborted();
|
|
40
|
+
const parsed = parseScaleProjections(projections);
|
|
41
|
+
if (Object.values(parsed).some(({ scale }) => scale.domain.type !== 'fixed')) {
|
|
42
|
+
throw new Error('Append-only scale projections require fixed domains.');
|
|
43
|
+
}
|
|
44
|
+
/** Scales compiled once, using the schema from the first batch. */
|
|
45
|
+
let compiled;
|
|
46
|
+
for await (const batch of queryInBatches(input, { ...options, queryOutput: 'batches' })) {
|
|
47
|
+
options.signal?.throwIfAborted();
|
|
48
|
+
compiled ??= compileArrowScales(new Table(batch.schema), parsed);
|
|
49
|
+
yield evaluateScaleProjections(new Table(batch.schema, [batch]), compiled, options.signal);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Resolves progressive domains from one source pass and recolors retained rows on publication. */
|
|
53
|
+
export async function* queryScalesProgressive(input, projections, options) {
|
|
54
|
+
const { emitEveryBatches = 16, maxRetainedRows = 100_000, quantileCapacity, signal } = options;
|
|
55
|
+
signal?.throwIfAborted();
|
|
56
|
+
if (!Number.isSafeInteger(emitEveryBatches) ||
|
|
57
|
+
emitEveryBatches < 1 ||
|
|
58
|
+
!Number.isSafeInteger(maxRetainedRows) ||
|
|
59
|
+
maxRetainedRows < 1) {
|
|
60
|
+
throw new Error('Scale snapshot interval and row limit must be positive integers.');
|
|
61
|
+
}
|
|
62
|
+
const parsed = parseScaleProjections(projections);
|
|
63
|
+
const entries = Object.entries(parsed);
|
|
64
|
+
if (entries.some(([, { scale }]) => scale.type === 'quantile')) {
|
|
65
|
+
throw new Error('Progressive quantile classification requires a resolved Arrow scale binder.');
|
|
66
|
+
}
|
|
67
|
+
const accumulator = createStreamingDomainAccumulator(entries.map(([, { scale }]) => scale.domain), { quantileCapacity });
|
|
68
|
+
const batches = [];
|
|
69
|
+
let retainedRows = 0;
|
|
70
|
+
let batchesSinceEmission = 0;
|
|
71
|
+
let last;
|
|
72
|
+
/** Binds the current statistics and evaluates the selected snapshot. */
|
|
73
|
+
async function snapshot(final = false) {
|
|
74
|
+
const domains = accumulator.result();
|
|
75
|
+
if (domains.some(domain => domain.length === 0))
|
|
76
|
+
return undefined;
|
|
77
|
+
// math.gl beta.11 cannot bind repeated quantize breaks. Defer publication
|
|
78
|
+
// until the extent grows, while still surfacing final domain errors.
|
|
79
|
+
if (!final &&
|
|
80
|
+
entries.some(([, { scale }], index) => scale.type === 'quantize' &&
|
|
81
|
+
scale.range.type === 'palette' &&
|
|
82
|
+
(scale.range.count ?? 0) > 2 &&
|
|
83
|
+
domains[index][0] === domains[index][1]))
|
|
84
|
+
return undefined;
|
|
85
|
+
const table = await makeArrowTableFromBatches(batches);
|
|
86
|
+
signal?.throwIfAborted();
|
|
87
|
+
if (!table)
|
|
88
|
+
return undefined;
|
|
89
|
+
const schemaOnly = new Table(table.schema);
|
|
90
|
+
const compiled = Object.fromEntries(entries.map(([name, expression], index) => [
|
|
91
|
+
name,
|
|
92
|
+
compileArrowScale(schemaOnly, expression, domains[index])
|
|
93
|
+
]));
|
|
94
|
+
return evaluateScaleProjections(table, compiled, signal);
|
|
95
|
+
}
|
|
96
|
+
for await (const batch of queryInBatches(input, { ...options, queryOutput: 'batches' })) {
|
|
97
|
+
signal?.throwIfAborted();
|
|
98
|
+
retainedRows += batch.numRows;
|
|
99
|
+
if (retainedRows > maxRetainedRows) {
|
|
100
|
+
throw new Error(`Progressive scale query exceeded its retained row limit (${maxRetainedRows}).`);
|
|
101
|
+
}
|
|
102
|
+
batches.push(batch);
|
|
103
|
+
if (batch.numRows === 0)
|
|
104
|
+
continue;
|
|
105
|
+
accumulator.update(batch);
|
|
106
|
+
if (++batchesSinceEmission < emitEveryBatches)
|
|
107
|
+
continue;
|
|
108
|
+
last = await snapshot();
|
|
109
|
+
if (last) {
|
|
110
|
+
batchesSinceEmission = 0;
|
|
111
|
+
yield { ...last, final: false };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
signal?.throwIfAborted();
|
|
115
|
+
const final = last && batchesSinceEmission === 0 ? last : await snapshot(true);
|
|
116
|
+
if (!final)
|
|
117
|
+
throw new Error('Progressive scale query could not resolve its domain.');
|
|
118
|
+
yield { ...final, final: true };
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=query-scales.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-scales.js","sourceRoot":"","sources":["../../src/scan/query-scales.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,KAAK,EAAgC,MAAM,cAAc,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gCAAgC,EAEjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,EAGxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,yBAAyB,EAAC,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAC,KAAK,EAAE,cAAc,EAAgC,mBAAgB;AAiB7E,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAqB,EACrB,WAAmC,EACnC,OAAqB;IAErB,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1C,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AAC5F,CAAC;AAED,8EAA8E;AAC9E,SAAS,wBAAwB,CAC/B,KAAY,EACZ,QAA0C,EAC1C,MAAoB;IAEpB,MAAM,KAAK,GAAG,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GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC;QAChC,CAAC;IACH,CAAC;IACD,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,IAAI,IAAI,oBAAoB,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/E,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IACrF,MAAM,EAAC,GAAG,KAAK,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;AAChC,CAAC"}
|
package/dist/scan/query.cjs
CHANGED
|
@@ -31,8 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var query_exports = {};
|
|
32
32
|
__export(query_exports, {
|
|
33
33
|
createSQLCatalog: () => import_sql_catalog.createSQLCatalog,
|
|
34
|
-
parseSQLQuery: () =>
|
|
35
|
-
parseSQLSelect: () =>
|
|
34
|
+
parseSQLQuery: () => import_parser.parseSQLQuery,
|
|
35
|
+
parseSQLSelect: () => import_parser.parseSQLSelect,
|
|
36
36
|
query: () => query,
|
|
37
37
|
queryInBatches: () => queryInBatches,
|
|
38
38
|
queryProgressive: () => queryProgressive
|
|
@@ -43,7 +43,7 @@ var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
|
43
43
|
var import_schema_utils = require("@loaders.gl/core/schema-utils");
|
|
44
44
|
var import_arrow_execution = require("./arrow-execution.cjs");
|
|
45
45
|
var import_filter_arrow_table = require("./arrow-execution/filter-arrow-table.cjs");
|
|
46
|
-
var
|
|
46
|
+
var import_parser = require("@math.gl/sql/parser");
|
|
47
47
|
var import_sql_catalog = require("./sql-catalog.cjs");
|
|
48
48
|
async function query(tableQuery, options) {
|
|
49
49
|
return await (0, import_schema_utils.makeArrowTableFromBatches)(
|
|
@@ -66,9 +66,9 @@ async function* queryInBatches(tableQuery, options) {
|
|
|
66
66
|
if (typeof tableQuery === "object" && tableQuery && "aggregates" in tableQuery) {
|
|
67
67
|
throw new Error("Aggregates require snapshots.");
|
|
68
68
|
}
|
|
69
|
-
for await (const
|
|
70
|
-
if (
|
|
71
|
-
else yield (0, import_schema_utils.makeArrowMetadataBatch)(
|
|
69
|
+
for await (const table of queryAppendBatches(tableQuery, options)) {
|
|
70
|
+
if (table.batches.length) yield* table.batches;
|
|
71
|
+
else yield (0, import_schema_utils.makeArrowMetadataBatch)(table.schema);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
async function* queryProgressive(query2, options) {
|
|
@@ -87,6 +87,10 @@ async function* queryAppendBatches(tableQuery, options) {
|
|
|
87
87
|
let earlyTerminationReason;
|
|
88
88
|
try {
|
|
89
89
|
options.signal?.throwIfAborted();
|
|
90
|
+
const scan = options._scan;
|
|
91
|
+
if (options.offset !== void 0 || options.limit !== void 0 || scan?.limit !== void 0 || scan && "offset" in scan && scan.offset !== void 0) {
|
|
92
|
+
throw new Error("Put offset and limit in the logical query, not the execution options.");
|
|
93
|
+
}
|
|
90
94
|
let parsedQuery;
|
|
91
95
|
if (typeof tableQuery === "string") {
|
|
92
96
|
const parser = await options.sqlParser;
|
|
@@ -124,7 +128,7 @@ async function* queryAppendBatches(tableQuery, options) {
|
|
|
124
128
|
options.signal?.throwIfAborted();
|
|
125
129
|
if (!source || typeof source !== "object")
|
|
126
130
|
throw new Error("Expected an Arrow table or table scan source.");
|
|
127
|
-
const inMemory = "batches" in source ? source :
|
|
131
|
+
const inMemory = "batches" in source ? source : null;
|
|
128
132
|
if (!inMemory && (!("read" in source) || typeof source.read !== "function" || !("getQueryMetadata" in source) || typeof source.getQueryMetadata !== "function")) {
|
|
129
133
|
throw new Error("Expected an Arrow table or table scan source.");
|
|
130
134
|
}
|
|
@@ -133,6 +137,11 @@ async function* queryAppendBatches(tableQuery, options) {
|
|
|
133
137
|
if (metadata && (metadata.queryType !== "table" || metadata.execution.status !== "supported" || metadata.execution.method !== "read")) {
|
|
134
138
|
throw new Error("Query source must support table reads.");
|
|
135
139
|
}
|
|
140
|
+
if (metadata?.hasDefaultRowWindow) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
"Query source has a default offset or limit. Remove the source defaults and put offset and limit in the logical query."
|
|
143
|
+
);
|
|
144
|
+
}
|
|
136
145
|
const sourceSchema = inMemory ? inMemory.schema : (0, import_schema_utils.convertSchemaToArrow)(metadata.schema);
|
|
137
146
|
const names = sourceSchema.fields.map((field) => field.name);
|
|
138
147
|
const { select, where, ...controls } = logicalQuery;
|
|
@@ -199,14 +208,19 @@ async function* queryAppendBatches(tableQuery, options) {
|
|
|
199
208
|
for await (const value of batches) {
|
|
200
209
|
options.signal?.throwIfAborted();
|
|
201
210
|
let batch = normalizeBatch(value, pushedPlan?.schema ?? readSchema);
|
|
202
|
-
if (!pushedPlan && comparisonInputSchema && !arrow.util.compareSchemas(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
if (!pushedPlan && comparisonInputSchema && !arrow.util.compareSchemas(
|
|
212
|
+
comparisonInputSchema,
|
|
213
|
+
(0, import_schema_utils.convertSchemaToArrow)((0, import_schema_utils.convertArrowToSchema)(batch.schema))
|
|
214
|
+
)) {
|
|
215
|
+
batch = batch.select(inputSchema.names);
|
|
216
|
+
if (!arrow.util.compareSchemas(
|
|
217
|
+
comparisonInputSchema,
|
|
218
|
+
(0, import_schema_utils.convertSchemaToArrow)((0, import_schema_utils.convertArrowToSchema)(batch.schema))
|
|
219
|
+
))
|
|
206
220
|
throw new Error("Query input schema does not match source metadata.");
|
|
207
221
|
}
|
|
208
222
|
batchesRead++;
|
|
209
|
-
rowsRead += batch.
|
|
223
|
+
rowsRead += batch.numRows;
|
|
210
224
|
yield batch;
|
|
211
225
|
}
|
|
212
226
|
}
|
|
@@ -222,33 +236,33 @@ async function* queryAppendBatches(tableQuery, options) {
|
|
|
222
236
|
{
|
|
223
237
|
filter: (batch, predicate, signal) => {
|
|
224
238
|
if (pushedPlan) return batch;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
239
|
+
if (compiledFilter) {
|
|
240
|
+
return (0, import_filter_arrow_table.filterArrowRows)(
|
|
241
|
+
batch,
|
|
242
|
+
(recordBatch) => {
|
|
243
|
+
const matches = compiledFilter.evaluate(recordBatch, { signal });
|
|
244
|
+
return (index) => matches.get(index) === true;
|
|
245
|
+
},
|
|
246
|
+
{ signal }
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
return predicate ? (0, import_arrow_execution.filterArrowTable)(batch, predicate, { signal }) : batch;
|
|
235
250
|
},
|
|
236
|
-
project: (batch) =>
|
|
237
|
-
const input = batch;
|
|
238
|
-
return pushedPlan || computedProjection ? input : { ...input, ...wrapBatch(project(input.data)) };
|
|
239
|
-
}
|
|
251
|
+
project: (batch) => pushedPlan || computedProjection ? batch : project(batch)
|
|
240
252
|
}
|
|
241
253
|
)) {
|
|
242
|
-
const input = value;
|
|
243
254
|
const finishProjection = pushedPlan ? pushedPlan.project : computedProjection ? project : void 0;
|
|
244
|
-
const batch = finishProjection ?
|
|
245
|
-
if (!arrow.util.compareSchemas(
|
|
255
|
+
const batch = finishProjection ? finishProjection(value) : value;
|
|
256
|
+
if (!arrow.util.compareSchemas(
|
|
257
|
+
comparisonSchema,
|
|
258
|
+
(0, import_schema_utils.convertSchemaToArrow)((0, import_schema_utils.convertArrowToSchema)(batch.schema))
|
|
259
|
+
))
|
|
246
260
|
throw new Error("Query output schema does not match source metadata.");
|
|
247
261
|
emitted = true;
|
|
248
|
-
rowsReturned += batch.
|
|
262
|
+
rowsReturned += batch.numRows;
|
|
249
263
|
yield batch;
|
|
250
264
|
}
|
|
251
|
-
if (!emitted) yield
|
|
265
|
+
if (!emitted) yield empty;
|
|
252
266
|
if (normalized.limit !== void 0 && rowsReturned >= normalized.limit)
|
|
253
267
|
earlyTerminationReason = "limit";
|
|
254
268
|
status = earlyTerminationReason ? "early-terminated" : "completed";
|
|
@@ -293,30 +307,20 @@ async function normalizeTypedQuery(query2) {
|
|
|
293
307
|
return (await import("./arrow-execution/expressions.cjs")).normalizeTypedProjection(query2);
|
|
294
308
|
}
|
|
295
309
|
async function* memoryBatches(data) {
|
|
296
|
-
for (const batch of data.batches) yield
|
|
310
|
+
for (const batch of data.batches) yield new arrow.Table(data.schema, [batch]);
|
|
297
311
|
}
|
|
298
312
|
function normalizeBatch(value, fallbackSchema) {
|
|
299
313
|
if (!value || typeof value !== "object") throw new Error("Unsupported query batch.");
|
|
300
314
|
if ("numRows" in value) {
|
|
301
315
|
const batch2 = value;
|
|
302
|
-
return
|
|
316
|
+
return new arrow.Table(batch2.schema, [batch2]);
|
|
303
317
|
}
|
|
304
318
|
if (!("shape" in value)) throw new Error("Unsupported query batch.");
|
|
305
319
|
const input = value;
|
|
306
320
|
const batch = { ...input, schema: input.schema ?? fallbackSchema };
|
|
307
|
-
if (!["
|
|
321
|
+
if (!["object-row-table", "array-row-table", "columnar-table"].includes(batch.shape))
|
|
308
322
|
throw new Error(`Unsupported query batch shape: ${batch.shape}`);
|
|
309
|
-
|
|
310
|
-
return { ...batch, ...wrapBatch(data) };
|
|
311
|
-
}
|
|
312
|
-
function wrapBatch(data) {
|
|
313
|
-
return {
|
|
314
|
-
shape: "arrow-table",
|
|
315
|
-
data,
|
|
316
|
-
schema: (0, import_schema_utils.convertArrowToSchema)(data.schema),
|
|
317
|
-
batchType: "data",
|
|
318
|
-
length: data.numRows
|
|
319
|
-
};
|
|
323
|
+
return batch.length === 0 && batch.schema ? new arrow.Table((0, import_schema_utils.convertSchemaToArrow)(batch.schema)) : (0, import_schema_utils.convertTableToArrow)(batch);
|
|
320
324
|
}
|
|
321
325
|
function validatePredicateOperands(where) {
|
|
322
326
|
if (where && typeof where === "object" && "expression" in where) {
|