@loaders.gl/core 5.0.0-beta.6 → 5.0.0-beta.8
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/dist/arrow-geometry/geojson-table.cjs +26 -15
- package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
- package/dist/arrow-geometry/geojson-table.d.ts +8 -1
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +18 -9
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/cluster-source.cjs +78 -8
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/dist.dev.js +354 -319
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +187 -179
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.d.ts.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
- package/dist/index.cjs +351 -281
- 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/create-data-source.d.ts +14 -9
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +55 -45
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +11 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +3 -2
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +3 -3
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +14 -18
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +7 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +11 -64
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +5 -3
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +12 -7
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +5 -3
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +14 -3
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +5 -3
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +8 -6
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +5 -3
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +26 -15
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts +4 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +43 -40
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +1 -1
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +2 -37
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +2 -63
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +11 -0
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
- package/dist/lib/loader-utils/native-arrow.js +52 -0
- package/dist/lib/loader-utils/native-arrow.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.js +2 -2
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +21 -10
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/loader-utils/index.cjs +143 -42
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +2 -2
- 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.d.ts +24 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +32 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +5 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +13 -5
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +5 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -1
- 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 +27 -20
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +3 -3
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +15 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +102 -27
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/source-types.d.ts +5 -5
- package/dist/loader-utils/source-types.d.ts.map +1 -1
- package/dist/loader-utils/source-types.js +5 -1
- package/dist/loader-utils/source-types.js.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/polyfills/index.cjs +3 -2
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +2 -2
- package/dist/polyfills/index.js.map +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +110 -0
- package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
- package/dist/scan/arrow-execution/expressions.d.ts +9 -0
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
- package/dist/scan/arrow-execution/expressions.js +60 -0
- package/dist/scan/arrow-execution/expressions.js.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +15 -3
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +2 -2
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +2 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +10 -2
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/index.cjs +21 -6
- 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 +1 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +1 -7
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -307
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-progressive.cjs +191 -0
- package/dist/scan/query-progressive.cjs.map +7 -0
- package/dist/scan/query-progressive.d.ts +39 -0
- package/dist/scan/query-progressive.d.ts.map +1 -0
- package/dist/scan/query-progressive.js +174 -0
- package/dist/scan/query-progressive.js.map +1 -0
- package/dist/scan/query.cjs +143 -22
- package/dist/scan/query.cjs.map +3 -3
- package/dist/scan/query.d.ts +27 -9
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +180 -18
- package/dist/scan/query.js.map +1 -1
- package/dist/schema-utils/index.cjs +262 -241
- package/dist/schema-utils/index.cjs.map +2 -2
- package/dist/schema-utils/index.d.ts +1 -0
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +1 -0
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +28 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +26 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +12 -4
- package/dist/vector-table-scan-source.cjs.map +1 -1
- package/dist/worker-utils/index.cjs +49 -9
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +2 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/package.json +8 -7
- package/src/arrow-geometry/geojson-table.ts +27 -17
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
- package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
- package/src/index.ts +1 -1
- package/src/lib/api/create-data-source.ts +136 -58
- package/src/lib/api/encode.ts +14 -3
- package/src/lib/api/load-in-batches.ts +15 -7
- package/src/lib/api/load-loader.ts +21 -20
- package/src/lib/api/load.ts +49 -121
- package/src/lib/api/parse-file.ts +42 -23
- package/src/lib/api/parse-in-batches.ts +49 -12
- package/src/lib/api/parse-sync.ts +37 -19
- package/src/lib/api/parse.ts +51 -30
- package/src/lib/api/select-loader.ts +56 -53
- package/src/lib/api/select-source.ts +7 -1
- package/src/lib/loader-utils/loggers.ts +2 -70
- package/src/lib/loader-utils/native-arrow.ts +70 -0
- package/src/lib/loader-utils/option-defaults.ts +2 -2
- package/src/lib/loader-utils/option-utils.ts +21 -10
- package/src/loader-utils/index.ts +2 -1
- package/src/loader-utils/lib/log-utils/log.ts +39 -1
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +18 -8
- package/src/loader-utils/lib/scan-utils/table-query.ts +10 -1
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +36 -25
- package/src/loader-utils/lib/sources/data-source.ts +3 -3
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +16 -1
- package/src/loader-utils/loader-types.ts +168 -43
- package/src/loader-utils/source-types.ts +12 -6
- package/src/polyfills/index.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +86 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +19 -3
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +8 -367
- package/src/scan/query-progressive.ts +231 -0
- package/src/scan/query.ts +247 -24
- package/src/schema-utils/index.ts +5 -0
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +58 -0
- package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
- package/src/worker-utils/lib/library-utils/library-utils.ts +2 -1
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
- package/dist/scan/parse-sql-query.cjs +0 -70
- package/dist/scan/parse-sql-query.cjs.map +0 -7
- package/dist/scan/parse-sql-query.d.ts +0 -5
- package/dist/scan/parse-sql-query.d.ts.map +0 -1
- package/dist/scan/parse-sql-query.js +0 -49
- package/dist/scan/parse-sql-query.js.map +0 -1
- package/dist/scan/parse-sql-select.cjs +0 -215
- package/dist/scan/parse-sql-select.cjs.map +0 -7
- package/dist/scan/parse-sql-select.d.ts +0 -38
- package/dist/scan/parse-sql-select.d.ts.map +0 -1
- package/dist/scan/parse-sql-select.js +0 -208
- package/dist/scan/parse-sql-select.js.map +0 -1
- package/src/scan/parse-sql-query.ts +0 -53
- package/src/scan/parse-sql-select.ts +0 -220
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import * as arrow from 'apache-arrow';
|
|
5
|
+
import { convertArrowToTable } from '@loaders.gl/core/schema-utils';
|
|
6
|
+
import { queryInBatches } from "./query.js";
|
|
7
|
+
const MAX_SAFE_COUNT = Number.MAX_SAFE_INTEGER;
|
|
8
|
+
/**
|
|
9
|
+
* Consumes Arrow batches without retaining input rows. Group state is O(number of groups).
|
|
10
|
+
* Snapshot creation is O(number of groups × number of aggregates) and can be throttled
|
|
11
|
+
* with emitEveryBatches. Consumer early return closes the underlying source iterator.
|
|
12
|
+
*/
|
|
13
|
+
export async function* executeProgressiveQuery(query, options) {
|
|
14
|
+
validateQuery(query, options);
|
|
15
|
+
const { emitEveryBatches = 1, ...queryOptions } = options;
|
|
16
|
+
const inputs = new Set();
|
|
17
|
+
if (query.groupBy)
|
|
18
|
+
inputs.add(query.groupBy);
|
|
19
|
+
for (const aggregate of query.aggregates)
|
|
20
|
+
if (aggregate.column)
|
|
21
|
+
inputs.add(aggregate.column);
|
|
22
|
+
const columns = [...inputs];
|
|
23
|
+
const groups = new Map();
|
|
24
|
+
let sourceSchema;
|
|
25
|
+
let rowsProcessed = 0;
|
|
26
|
+
let batchesSinceEmission = 0;
|
|
27
|
+
if (query.groupBy === undefined)
|
|
28
|
+
groups.set(null, makeAggregateStates(query.aggregates.length));
|
|
29
|
+
// A COUNT(*) request can have no input columns, but the query pipeline still needs
|
|
30
|
+
// a source column to preserve row counts. The absence of select means all source
|
|
31
|
+
// columns are read; no source data is retained beyond each batch.
|
|
32
|
+
const tableQuery = {
|
|
33
|
+
...(query.from === undefined ? {} : { from: query.from }),
|
|
34
|
+
...(query.where === undefined ? {} : { where: query.where }),
|
|
35
|
+
...(columns.length ? { select: columns } : {})
|
|
36
|
+
};
|
|
37
|
+
for await (const batch of queryInBatches(tableQuery, { ...queryOptions, queryOutput: undefined })) {
|
|
38
|
+
options.signal?.throwIfAborted();
|
|
39
|
+
sourceSchema ??= batch.data.schema;
|
|
40
|
+
if (batch.length === 0)
|
|
41
|
+
continue;
|
|
42
|
+
const keyVector = query.groupBy ? batch.data.getChild(query.groupBy) : undefined;
|
|
43
|
+
const aggregateVectors = query.aggregates.map(aggregate => aggregate.column ? batch.data.getChild(aggregate.column) : undefined);
|
|
44
|
+
for (let row = 0; row < batch.length; row++) {
|
|
45
|
+
if ((row & 1023) === 0)
|
|
46
|
+
options.signal?.throwIfAborted();
|
|
47
|
+
const key = keyVector ? normalizeKey(keyVector.get(row)) : null;
|
|
48
|
+
let group = groups.get(key);
|
|
49
|
+
if (!group) {
|
|
50
|
+
group = makeAggregateStates(query.aggregates.length);
|
|
51
|
+
groups.set(key, group);
|
|
52
|
+
}
|
|
53
|
+
for (let index = 0; index < query.aggregates.length; index++) {
|
|
54
|
+
const operation = query.aggregates[index];
|
|
55
|
+
const value = aggregateVectors[index]?.get(row);
|
|
56
|
+
if (operation.function === 'count') {
|
|
57
|
+
if (!operation.column || (value !== null && value !== undefined)) {
|
|
58
|
+
increaseCount(group[index]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (value !== null && value !== undefined) {
|
|
62
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
63
|
+
throw new Error(`Progressive ${operation.function} requires finite numeric values in column ${operation.column}`);
|
|
64
|
+
}
|
|
65
|
+
updateNumeric(group[index], value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
rowsProcessed += batch.length;
|
|
70
|
+
if (++batchesSinceEmission >= emitEveryBatches) {
|
|
71
|
+
yield { table: createSnapshot(groups, query, sourceSchema), rowsProcessed, final: false };
|
|
72
|
+
batchesSinceEmission = 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// The terminal snapshot is always emitted, including empty inputs and when the
|
|
76
|
+
// previous provisional snapshot already has the same values.
|
|
77
|
+
yield {
|
|
78
|
+
table: createSnapshot(groups, query, sourceSchema),
|
|
79
|
+
rowsProcessed,
|
|
80
|
+
final: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function validateQuery(query, options) {
|
|
84
|
+
if (!query || typeof query !== 'object' || Array.isArray(query)) {
|
|
85
|
+
throw new Error('Progressive query must be an object.');
|
|
86
|
+
}
|
|
87
|
+
if (Object.keys(query).some(key => !['from', 'where', 'groupBy', 'aggregates'].includes(key))) {
|
|
88
|
+
throw new Error('Unsupported progressive query field.');
|
|
89
|
+
}
|
|
90
|
+
if (query.groupBy !== undefined && (typeof query.groupBy !== 'string' || !query.groupBy)) {
|
|
91
|
+
throw new Error('Progressive groupBy must be a nonempty column name.');
|
|
92
|
+
}
|
|
93
|
+
if (!Array.isArray(query.aggregates) || !query.aggregates.length) {
|
|
94
|
+
throw new Error('Progressive query requires at least one aggregate.');
|
|
95
|
+
}
|
|
96
|
+
const names = new Set(query.groupBy ? [query.groupBy] : []);
|
|
97
|
+
for (const aggregate of query.aggregates) {
|
|
98
|
+
if (!aggregate || !['count', 'sum', 'avg', 'min', 'max'].includes(aggregate.function)) {
|
|
99
|
+
throw new Error('Unsupported progressive aggregate function.');
|
|
100
|
+
}
|
|
101
|
+
if (Object.keys(aggregate).some(key => !['function', 'column', 'as'].includes(key))) {
|
|
102
|
+
throw new Error('Unsupported progressive aggregate field.');
|
|
103
|
+
}
|
|
104
|
+
if (!aggregate.as || typeof aggregate.as !== 'string' || names.has(aggregate.as)) {
|
|
105
|
+
throw new Error('Progressive aggregate aliases must be unique nonempty output names.');
|
|
106
|
+
}
|
|
107
|
+
if (aggregate.column !== undefined &&
|
|
108
|
+
(typeof aggregate.column !== 'string' || !aggregate.column)) {
|
|
109
|
+
throw new Error('Progressive aggregate column must be nonempty.');
|
|
110
|
+
}
|
|
111
|
+
if (aggregate.function !== 'count' && !aggregate.column) {
|
|
112
|
+
throw new Error(`Progressive ${aggregate.function} requires an input column.`);
|
|
113
|
+
}
|
|
114
|
+
names.add(aggregate.as);
|
|
115
|
+
}
|
|
116
|
+
const interval = options.emitEveryBatches ?? 1;
|
|
117
|
+
if (!Number.isSafeInteger(interval) || interval <= 0) {
|
|
118
|
+
throw new Error('emitEveryBatches must be a positive safe integer.');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Initializes the independent aggregate state for one group. */
|
|
122
|
+
function makeAggregateStates(length) {
|
|
123
|
+
return Array.from({ length }, () => ({ count: 0, sum: 0, min: null, max: null }));
|
|
124
|
+
}
|
|
125
|
+
function normalizeKey(value) {
|
|
126
|
+
if (value === null || value === undefined)
|
|
127
|
+
return null;
|
|
128
|
+
if (typeof value === 'string' || typeof value === 'boolean')
|
|
129
|
+
return value;
|
|
130
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
131
|
+
return value;
|
|
132
|
+
throw new Error('Progressive GROUP BY supports finite numeric, string, boolean, and null keys.');
|
|
133
|
+
}
|
|
134
|
+
function increaseCount(state) {
|
|
135
|
+
if (state.count >= MAX_SAFE_COUNT)
|
|
136
|
+
throw new Error('Progressive aggregate count exceeds safe integer range.');
|
|
137
|
+
state.count++;
|
|
138
|
+
}
|
|
139
|
+
function updateNumeric(state, value) {
|
|
140
|
+
increaseCount(state);
|
|
141
|
+
state.sum += value;
|
|
142
|
+
state.min = state.min === null ? value : Math.min(state.min, value);
|
|
143
|
+
state.max = state.max === null ? value : Math.max(state.max, value);
|
|
144
|
+
}
|
|
145
|
+
function createSnapshot(groups, query, sourceSchema) {
|
|
146
|
+
const resultColumns = {};
|
|
147
|
+
if (query.groupBy) {
|
|
148
|
+
const field = sourceSchema?.fields.find(candidate => candidate.name === query.groupBy);
|
|
149
|
+
if (!field)
|
|
150
|
+
throw new Error(`Progressive group column not found: ${query.groupBy}`);
|
|
151
|
+
resultColumns[query.groupBy] = arrow.vectorFromArray([...groups.keys()], field.type);
|
|
152
|
+
}
|
|
153
|
+
for (let index = 0; index < query.aggregates.length; index++) {
|
|
154
|
+
const aggregate = query.aggregates[index];
|
|
155
|
+
const values = [...groups.values()].map(group => {
|
|
156
|
+
const state = group[index];
|
|
157
|
+
switch (aggregate.function) {
|
|
158
|
+
case 'count':
|
|
159
|
+
return state.count;
|
|
160
|
+
case 'sum':
|
|
161
|
+
return state.count ? state.sum : null;
|
|
162
|
+
case 'avg':
|
|
163
|
+
return state.count ? state.sum / state.count : null;
|
|
164
|
+
case 'min':
|
|
165
|
+
return state.min;
|
|
166
|
+
case 'max':
|
|
167
|
+
return state.max;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
resultColumns[aggregate.as] = arrow.vectorFromArray(values, new arrow.Float64());
|
|
171
|
+
}
|
|
172
|
+
return convertArrowToTable(new arrow.Table(resultColumns), 'arrow-table');
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=query-progressive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-progressive.js","sourceRoot":"","sources":["../../src/scan/query-progressive.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAC,mBAAmB,EAAC,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAC,cAAc,EAAoB,mBAAgB;AA4C1D,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,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CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;gBACxC,KAAK,KAAK;oBACR,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;gBACtD,KAAK,KAAK;oBACR,OAAO,KAAK,CAAC,GAAG,CAAC;gBACnB,KAAK,KAAK;oBACR,OAAO,KAAK,CAAC,GAAG,CAAC;YACrB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,mBAAmB,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/scan/query.cjs
CHANGED
|
@@ -31,25 +31,26 @@ 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_sql.parseSQLQuery,
|
|
35
|
+
parseSQLSelect: () => import_sql.parseSQLSelect,
|
|
36
36
|
query: () => query,
|
|
37
|
-
queryInBatches: () => queryInBatches
|
|
37
|
+
queryInBatches: () => queryInBatches,
|
|
38
|
+
queryProgressive: () => queryProgressive
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(query_exports);
|
|
40
41
|
var arrow = __toESM(require("apache-arrow"), 1);
|
|
41
42
|
var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
42
43
|
var import_schema_utils = require("@loaders.gl/core/schema-utils");
|
|
43
44
|
var import_arrow_execution = require("./arrow-execution.cjs");
|
|
45
|
+
var import_filter_arrow_table = require("./arrow-execution/filter-arrow-table.cjs");
|
|
44
46
|
var import_catalog_query_source = require("./catalog-query-source.cjs");
|
|
45
47
|
var import_resolve_query_source = require("./resolve-query-source.cjs");
|
|
46
|
-
var
|
|
47
|
-
var import_parse_sql_select = require("./parse-sql-select.cjs");
|
|
48
|
+
var import_sql = require("@math.gl/expressions/sql");
|
|
48
49
|
var import_sql_catalog = require("./sql-catalog.cjs");
|
|
49
50
|
async function query(tableQuery, options) {
|
|
50
51
|
let schema;
|
|
51
52
|
const batches = [];
|
|
52
|
-
for await (const batch of queryInBatches(tableQuery, options)) {
|
|
53
|
+
for await (const batch of queryInBatches(tableQuery, { ...options, queryOutput: void 0 })) {
|
|
53
54
|
schema = batch.data.schema;
|
|
54
55
|
batches.push(...batch.data.batches);
|
|
55
56
|
}
|
|
@@ -57,6 +58,34 @@ async function query(tableQuery, options) {
|
|
|
57
58
|
return { shape: "arrow-table", schema: (0, import_schema_utils.convertArrowToSchema)(data.schema), data };
|
|
58
59
|
}
|
|
59
60
|
async function* queryInBatches(tableQuery, options) {
|
|
61
|
+
if (options.queryOutput === "snapshots") {
|
|
62
|
+
if (!tableQuery || typeof tableQuery !== "object" || !("aggregates" in tableQuery) || !Array.isArray(tableQuery.aggregates)) {
|
|
63
|
+
throw new Error("Snapshot query output currently requires a structured aggregate query.");
|
|
64
|
+
}
|
|
65
|
+
for await (const snapshot of queryProgressive(tableQuery, options)) {
|
|
66
|
+
yield* snapshot.table.data.batches;
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (options.queryOutput !== void 0 && options.queryOutput !== "batches") {
|
|
71
|
+
throw new Error("Unsupported queryOutput; expected batches or snapshots.");
|
|
72
|
+
}
|
|
73
|
+
if (typeof tableQuery === "object" && tableQuery && "aggregates" in tableQuery) {
|
|
74
|
+
throw new Error("Aggregate queries require queryOutput: snapshots.");
|
|
75
|
+
}
|
|
76
|
+
for await (const batch of queryAppendBatches(tableQuery, options)) {
|
|
77
|
+
if (options.queryOutput === "batches") {
|
|
78
|
+
yield* batch.data.batches;
|
|
79
|
+
} else {
|
|
80
|
+
yield batch;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function* queryProgressive(query2, options) {
|
|
85
|
+
const { executeProgressiveQuery } = await import("./query-progressive.cjs");
|
|
86
|
+
yield* executeProgressiveQuery(query2, options);
|
|
87
|
+
}
|
|
88
|
+
async function* queryAppendBatches(tableQuery, options) {
|
|
60
89
|
const startedAt = Date.now();
|
|
61
90
|
let status = "early-terminated";
|
|
62
91
|
let rowsRead = 0;
|
|
@@ -79,6 +108,7 @@ async function* queryInBatches(tableQuery, options) {
|
|
|
79
108
|
} else parsedQuery = tableQuery;
|
|
80
109
|
if (!parsedQuery || typeof parsedQuery !== "object" || Array.isArray(parsedQuery))
|
|
81
110
|
throw new Error("Table query must be an object.");
|
|
111
|
+
const castPredicate = "command" in parsedQuery ? false : validatePredicateOperands(parsedQuery.where);
|
|
82
112
|
let logicalQuery;
|
|
83
113
|
let source;
|
|
84
114
|
if ("command" in parsedQuery) {
|
|
@@ -108,25 +138,47 @@ async function* queryInBatches(tableQuery, options) {
|
|
|
108
138
|
}
|
|
109
139
|
const sourceSchema = inMemory ? source.data.schema : (0, import_schema_utils.convertSchemaToArrow)(metadata.schema);
|
|
110
140
|
const names = sourceSchema.fields.map((field) => field.name);
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
141
|
+
const { select, where, ...controls } = logicalQuery;
|
|
142
|
+
const computedProjection = Array.isArray(select) && select.some(
|
|
143
|
+
(selection) => selection && typeof selection === "object" && ("expression" in selection || "array" in selection)
|
|
144
|
+
);
|
|
145
|
+
const expressionFilter = where && typeof where === "object" && "expression" in where ? where : void 0;
|
|
146
|
+
const portablePredicate = expressionFilter ? void 0 : where;
|
|
147
|
+
const normalized = (0, import_loader_utils.normalizeTableQuery)(names, {
|
|
148
|
+
...controls,
|
|
149
|
+
select: computedProjection ? void 0 : select,
|
|
150
|
+
where: castPredicate ? void 0 : portablePredicate
|
|
151
|
+
});
|
|
152
|
+
const expressionTools = computedProjection || expressionFilter || castPredicate ? await import("./arrow-execution/expressions.cjs") : void 0;
|
|
153
|
+
const outputColumns = computedProjection ? expressionTools.getProjectionColumns(select) : normalized.select.map((selection) => selection.column);
|
|
154
|
+
const expressionColumns = expressionFilter ? expressionTools.getExpressionColumns(expressionFilter.expression) : castPredicate && portablePredicate ? (0, import_loader_utils.getColumnarPredicateColumns)(portablePredicate) : [];
|
|
155
|
+
const required = [.../* @__PURE__ */ new Set([...outputColumns, ...expressionColumns])];
|
|
156
|
+
const plan = (0, import_loader_utils.planTableQuery)(names, {
|
|
157
|
+
// A literal-only projection still needs a physical column to retain row counts.
|
|
158
|
+
columns: required.length ? required : names.slice(0, 1),
|
|
159
|
+
predicate: normalized.where
|
|
160
|
+
});
|
|
114
161
|
const requiredColumns = plan[0].kind === "scan" ? plan[0].columns : names;
|
|
115
162
|
const capabilities = metadata?.capabilities.table;
|
|
116
163
|
const delegatePredicate = Boolean(
|
|
117
164
|
normalized.where && capabilities && ["pushdown", "pushdown+residual"].includes(capabilities.predicate)
|
|
118
165
|
);
|
|
119
166
|
const residual = delegatePredicate ? void 0 : normalized.where;
|
|
167
|
+
const requestedRows = normalized.limit === void 0 ? void 0 : (normalized.offset ?? 0) + normalized.limit;
|
|
120
168
|
const readOptions = {
|
|
121
169
|
signal: options.signal,
|
|
122
170
|
...capabilities && capabilities.projection !== "unsupported" ? { columns: requiredColumns } : {},
|
|
123
171
|
...delegatePredicate ? { predicate: normalized.where } : {},
|
|
124
|
-
...!residual && capabilities && ["pushdown", "pushdown+residual"].includes(capabilities.limit) ? { limit:
|
|
172
|
+
...!residual && !expressionFilter && !castPredicate && requestedRows !== void 0 && Number.isSafeInteger(requestedRows) && capabilities && ["pushdown", "pushdown+residual"].includes(capabilities.limit) ? { limit: requestedRows } : {}
|
|
125
173
|
};
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
const
|
|
174
|
+
const inputSchema = readOptions.columns ? sourceSchema.select([...readOptions.columns]) : sourceSchema;
|
|
175
|
+
const readSchema = (0, import_schema_utils.convertArrowToSchema)(inputSchema);
|
|
176
|
+
const comparisonInputSchema = expressionTools ? (0, import_schema_utils.convertSchemaToArrow)(readSchema) : void 0;
|
|
177
|
+
const compiledFilter = expressionFilter ? expressionTools.compileArrowExpression(expressionFilter.expression, { inputSchema }) : castPredicate && portablePredicate ? expressionTools.compileArrowPredicate(portablePredicate, { inputSchema }) : void 0;
|
|
178
|
+
if (compiledFilter && !arrow.DataType.isBool(compiledFilter.outputField.type))
|
|
179
|
+
throw new Error("SQL WHERE expression must return Boolean.");
|
|
180
|
+
const project = computedProjection ? expressionTools.compileArrowProjection(inputSchema, select, options.signal) : (data) => (0, import_arrow_execution.projectArrowTable)(data, normalized.select);
|
|
181
|
+
const empty = project(new arrow.Table(inputSchema));
|
|
130
182
|
const comparisonSchema = (0, import_schema_utils.convertSchemaToArrow)((0, import_schema_utils.convertArrowToSchema)(empty.schema));
|
|
131
183
|
let emitted = false;
|
|
132
184
|
async function* inputs() {
|
|
@@ -134,7 +186,13 @@ async function* queryInBatches(tableQuery, options) {
|
|
|
134
186
|
const batches = inMemory ? memoryBatches(source.data) : source.read(readOptions);
|
|
135
187
|
for await (const value of batches) {
|
|
136
188
|
options.signal?.throwIfAborted();
|
|
137
|
-
|
|
189
|
+
let batch = normalizeBatch(value, readSchema);
|
|
190
|
+
if (comparisonInputSchema && !arrow.util.compareSchemas(comparisonInputSchema, (0, import_schema_utils.convertSchemaToArrow)(batch.schema))) {
|
|
191
|
+
const data = batch.data.select(inputSchema.names);
|
|
192
|
+
batch = { ...batch, ...wrapBatch(data) };
|
|
193
|
+
if (!arrow.util.compareSchemas(comparisonInputSchema, (0, import_schema_utils.convertSchemaToArrow)(batch.schema)))
|
|
194
|
+
throw new Error("Query input schema does not match source metadata.");
|
|
195
|
+
}
|
|
138
196
|
batchesRead++;
|
|
139
197
|
rowsRead += batch.length;
|
|
140
198
|
yield batch;
|
|
@@ -144,22 +202,32 @@ async function* queryInBatches(tableQuery, options) {
|
|
|
144
202
|
() => inputs(),
|
|
145
203
|
{
|
|
146
204
|
predicate: residual,
|
|
205
|
+
offset: normalized.offset,
|
|
147
206
|
limit: normalized.limit,
|
|
207
|
+
skipEmptyBatches: true,
|
|
148
208
|
signal: options.signal
|
|
149
209
|
},
|
|
150
210
|
{
|
|
151
211
|
filter: (batch, predicate, signal) => {
|
|
152
212
|
const input = batch;
|
|
153
|
-
const data =
|
|
213
|
+
const data = compiledFilter ? (0, import_filter_arrow_table.filterArrowRows)(
|
|
214
|
+
input.data,
|
|
215
|
+
(batch2) => {
|
|
216
|
+
const matches = compiledFilter.evaluate(batch2, { signal });
|
|
217
|
+
return (index) => matches.get(index) === true;
|
|
218
|
+
},
|
|
219
|
+
{ signal }
|
|
220
|
+
) : predicate ? (0, import_arrow_execution.filterArrowTable)(input.data, predicate, { signal }) : input.data;
|
|
154
221
|
return { ...input, ...wrapBatch(data) };
|
|
155
222
|
},
|
|
156
223
|
project: (batch) => {
|
|
157
224
|
const input = batch;
|
|
158
|
-
return { ...input, ...wrapBatch((
|
|
225
|
+
return computedProjection ? input : { ...input, ...wrapBatch(project(input.data)) };
|
|
159
226
|
}
|
|
160
227
|
}
|
|
161
228
|
)) {
|
|
162
|
-
const
|
|
229
|
+
const input = value;
|
|
230
|
+
const batch = computedProjection ? { ...input, ...wrapBatch(project(input.data)) } : input;
|
|
163
231
|
if (!arrow.util.compareSchemas(comparisonSchema, (0, import_schema_utils.convertSchemaToArrow)(batch.schema)))
|
|
164
232
|
throw new Error("Query output schema does not match source metadata.");
|
|
165
233
|
emitted = true;
|
|
@@ -228,9 +296,10 @@ function wrapBatch(data) {
|
|
|
228
296
|
}
|
|
229
297
|
async function openQuerySource(options) {
|
|
230
298
|
const candidates = Array.isArray(options.loaders) ? options.loaders : [options.loaders];
|
|
231
|
-
if (!candidates.length || candidates.
|
|
299
|
+
if (!candidates.length || !candidates.every(import_loader_utils.isSourceLoader) || candidates.some((loader) => !loader.fromUrl)) {
|
|
232
300
|
throw new Error("Query source must specify explicit URL-capable source loaders for a URL.");
|
|
233
|
-
|
|
301
|
+
}
|
|
302
|
+
const { source, sources, loaders, sqlParser, onQueryComplete, queryOutput, ...sourceOptions } = options;
|
|
234
303
|
const url = source;
|
|
235
304
|
const selected = candidates.length === 1 ? candidates[0] : candidates.find((loader) => loader.testURL(url));
|
|
236
305
|
if (!selected) throw new Error("No explicit source loader matches the query URL.");
|
|
@@ -244,7 +313,58 @@ async function openQuerySource(options) {
|
|
|
244
313
|
{ ...sourceOptions, core: { ...sourceOptions.core, ignoreRegisteredLoaders: true } }
|
|
245
314
|
);
|
|
246
315
|
options.signal?.throwIfAborted();
|
|
247
|
-
return implementation.
|
|
316
|
+
return implementation.createDataSourceSync(url, authenticatedOptions);
|
|
317
|
+
}
|
|
318
|
+
function validatePredicateOperands(where) {
|
|
319
|
+
if (where && typeof where === "object" && "expression" in where) {
|
|
320
|
+
if (Object.keys(where).some((key) => key !== "expression"))
|
|
321
|
+
throw new Error("Unsupported computed WHERE field.");
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
let castPredicate = false;
|
|
325
|
+
const pending = where ? [{ value: where }] : [];
|
|
326
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
327
|
+
let nodes = 0;
|
|
328
|
+
while (pending.length) {
|
|
329
|
+
const frame = pending.pop();
|
|
330
|
+
const candidate = frame.value;
|
|
331
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) continue;
|
|
332
|
+
if (frame.exit) {
|
|
333
|
+
visited.delete(candidate);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (visited.has(candidate) || ++nodes > 4096)
|
|
337
|
+
throw new Error("Query predicate must be an acyclic tree of at most 4096 nodes.");
|
|
338
|
+
visited.add(candidate);
|
|
339
|
+
if (isUnsupportedQueryExpression(candidate))
|
|
340
|
+
throw new Error("CAST and computed WHERE operands are not supported by this query executor.");
|
|
341
|
+
const predicate = candidate;
|
|
342
|
+
if (!Array.isArray(predicate.args)) continue;
|
|
343
|
+
if (predicate.op === "and" || predicate.op === "or" || predicate.op === "not") {
|
|
344
|
+
if (predicate.args.length > 4096 - nodes)
|
|
345
|
+
throw new Error("Query predicate exceeds 4096 nodes.");
|
|
346
|
+
pending.push({ value: candidate, exit: true });
|
|
347
|
+
pending.push(...predicate.args.map((value) => ({ value })));
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
visited.delete(candidate);
|
|
351
|
+
for (const [index, operand] of predicate.args.entries()) {
|
|
352
|
+
if (index === 0 && operand && typeof operand === "object" && typeof operand.property === "string" && "casts" in operand) {
|
|
353
|
+
castPredicate = true;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (isUnsupportedQueryExpression(operand) || Array.isArray(operand) && operand.some(isUnsupportedQueryExpression))
|
|
357
|
+
throw new Error(
|
|
358
|
+
"CAST and computed WHERE operands are not supported by this query executor."
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return castPredicate;
|
|
363
|
+
}
|
|
364
|
+
function isUnsupportedQueryExpression(value) {
|
|
365
|
+
if (!value || typeof value !== "object") return false;
|
|
366
|
+
if ("casts" in value || "expression" in value) return true;
|
|
367
|
+
return "type" in value && typeof value.type === "string" && /Expression$|^(Identifier|Literal|Compound)$/.test(value.type);
|
|
248
368
|
}
|
|
249
369
|
// Annotate the CommonJS export names for ESM import in node:
|
|
250
370
|
0 && (module.exports = {
|
|
@@ -252,6 +372,7 @@ async function openQuerySource(options) {
|
|
|
252
372
|
parseSQLQuery,
|
|
253
373
|
parseSQLSelect,
|
|
254
374
|
query,
|
|
255
|
-
queryInBatches
|
|
375
|
+
queryInBatches,
|
|
376
|
+
queryProgressive
|
|
256
377
|
});
|
|
257
378
|
//# sourceMappingURL=query.cjs.map
|
package/dist/scan/query.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scan/query.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport type {ArrowTable, ArrowTableBatch, TableBatch, Schema} from '@loaders.gl/core/schema';\nimport {\n normalizeTableQuery,\n executeTableScanBatches,\n planTableQuery,\n emitQueryComplete,\n type TableQuery,\n type TableQueryExecutionOptions,\n type TableQueryExecutionSummary,\n type TableScanSource,\n type TableScanReadOptions,\n type LoaderOptions,\n type DataSourceOptions,\n type SourceLoader,\n resolveLoaderAuthenticationOptions,\n isSourceLoader\n} from '@loaders.gl/core/loader-utils';\nimport {\n convertArrowToSchema,\n convertSchemaToArrow,\n convertTableToArrow\n} from '@loaders.gl/core/schema-utils';\nimport {projectArrowTable, filterArrowTable} from './arrow-execution';\nimport {createCatalogQuerySource} from './catalog-query-source';\nimport type {SQLCatalogQuery} from './sql-catalog';\nimport {resolveQuerySource} from './resolve-query-source';\nimport type {DataSource} from '@loaders.gl/core/loader-utils';\n\n/** Logical table or metadata request. */\nexport type Query = TableQuery | SQLCatalogQuery;\n\n/** Injected SQL parser; core validates and executes the returned logical query. */\nexport type SQLQueryParser = (sql: string) => Query | Promise<Query>;\n\n/** Input and execution controls for one public asynchronous table query. */\nexport type QueryOptions = TableQueryExecutionOptions &\n LoaderOptions &\n Readonly<{\n /** Source construction options, including an explicit core.name. */\n core?: DataSourceOptions['core'];\n /** Named caller-owned data sources used by FROM and metadata commands. */\n sources?: readonly DataSource<unknown, DataSourceOptions>[];\n /** Parser or lazy parser promise, required only for SQL string input. */\n sqlParser?: SQLQueryParser | Promise<SQLQueryParser>;\n }> &\n Readonly<\n | {\n /** Already loaded Arrow table or caller-owned table scan source. */\n source: ArrowTable | TableScanSource;\n /** URL loader selection is only used with URL sources. */\n loaders?: never;\n }\n | {\n /** FROM chooses a source from the named registry when no default source is supplied. */\n source?: undefined;\n /** Named sources available for FROM resolution. */\n sources: readonly DataSource<unknown, DataSourceOptions>[];\n /** URL loader selection requires a URL source. */\n loaders?: never;\n }\n | {\n /** URL opened lazily with the explicitly supplied source loaders. */\n source: string;\n /** URL-capable source loaders; registered loaders are never selected implicitly. */\n loaders: SourceLoader | SourceLoader[];\n }\n >;\n\n/** Collects the same ordered Arrow batch pipeline exposed by queryInBatches. */\nexport async function query(\n tableQuery: Query | string,\n options: QueryOptions\n): Promise<ArrowTable> {\n let schema: arrow.Schema | undefined;\n const batches: arrow.RecordBatch[] = [];\n for await (const batch of queryInBatches(tableQuery, options)) {\n schema = batch.data.schema;\n batches.push(...batch.data.batches);\n }\n const data = new arrow.Table(schema!, batches);\n return {shape: 'arrow-table', schema: convertArrowToSchema(data.schema), data};\n}\n\n/** Executes one logical query with bounded batch buffering and cooperative cancellation. */\nexport async function* queryInBatches(\n tableQuery: Query | string,\n options: QueryOptions\n): AsyncIterable<ArrowTableBatch> {\n const startedAt = Date.now();\n let status: TableQueryExecutionSummary['status'] = 'early-terminated';\n let rowsRead = 0;\n let rowsReturned = 0;\n let batchesRead = 0;\n let sourcesRead = 0;\n let error: unknown;\n let ownedSource: {close?: () => void | Promise<void>} | undefined;\n let earlyTerminationReason: TableQueryExecutionSummary['earlyTerminationReason'];\n try {\n options.signal?.throwIfAborted();\n let parsedQuery: Query;\n if (typeof tableQuery === 'string') {\n const parser = await options.sqlParser;\n options.signal?.throwIfAborted();\n if (typeof parser !== 'function')\n throw new Error('SQL queries require a sqlParser function or promise.');\n parsedQuery = await parser(tableQuery);\n options.signal?.throwIfAborted();\n } else parsedQuery = tableQuery;\n if (!parsedQuery || typeof parsedQuery !== 'object' || Array.isArray(parsedQuery))\n throw new Error('Table query must be an object.');\n let logicalQuery: TableQuery;\n let source: unknown;\n if ('command' in parsedQuery) {\n logicalQuery = {};\n source = createCatalogQuerySource(parsedQuery, options.sources);\n } else {\n logicalQuery = parsedQuery;\n source =\n logicalQuery.from === undefined\n ? options.source\n : await resolveQuerySource(logicalQuery.from, options.sources, options.signal);\n }\n if (logicalQuery.from === undefined && typeof source === 'string') {\n const opened = await openQuerySource(options);\n if (\n opened &&\n typeof opened === 'object' &&\n 'close' in opened &&\n typeof opened.close === 'function'\n )\n ownedSource = opened as {close: () => void | Promise<void>};\n source = opened;\n }\n options.signal?.throwIfAborted();\n if (!source || typeof source !== 'object')\n throw new Error('Query source must be an Arrow table or table scan source.');\n const inMemory = 'shape' in source && source.shape === 'arrow-table';\n if (\n !inMemory &&\n (!('read' in source) ||\n typeof source.read !== 'function' ||\n !('getQueryMetadata' in source) ||\n typeof source.getQueryMetadata !== 'function')\n ) {\n throw new Error('Query source must be an Arrow table or table scan source.');\n }\n const metadata = inMemory\n ? undefined\n : await (source as TableScanSource).getQueryMetadata({signal: options.signal});\n options.signal?.throwIfAborted();\n if (\n metadata &&\n (metadata.queryType !== 'table' ||\n metadata.execution.status !== 'supported' ||\n metadata.execution.method !== 'read')\n ) {\n throw new Error('Query source must support table reads.');\n }\n const sourceSchema = inMemory\n ? (source as ArrowTable).data.schema\n : convertSchemaToArrow(metadata!.schema);\n const names = sourceSchema.fields.map(field => field.name);\n const normalized = normalizeTableQuery(names, logicalQuery);\n const outputColumns = [...new Set(normalized.select.map(selection => selection.column))];\n const plan = planTableQuery(names, {columns: outputColumns, predicate: normalized.where});\n const requiredColumns = plan[0].kind === 'scan' ? plan[0].columns : names;\n const capabilities = metadata?.capabilities.table;\n // read() must perform exact filtering when it advertises pushdown+residual, not only pruning.\n const delegatePredicate = Boolean(\n normalized.where &&\n capabilities &&\n ['pushdown', 'pushdown+residual'].includes(capabilities.predicate)\n );\n const residual = delegatePredicate ? undefined : normalized.where;\n const readOptions: TableScanReadOptions = {\n signal: options.signal,\n ...(capabilities && capabilities.projection !== 'unsupported'\n ? {columns: requiredColumns}\n : {}),\n ...(delegatePredicate ? {predicate: normalized.where} : {}),\n ...(!residual &&\n capabilities &&\n ['pushdown', 'pushdown+residual'].includes(capabilities.limit)\n ? {limit: normalized.limit}\n : {})\n };\n const readSchema = convertArrowToSchema(\n readOptions.columns ? sourceSchema.select([...readOptions.columns]) : sourceSchema\n );\n const empty = projectArrowTable(new arrow.Table(sourceSchema), normalized.select);\n const comparisonSchema = convertSchemaToArrow(convertArrowToSchema(empty.schema));\n let emitted = false;\n /** Adapts physical batches without pulling ahead of the query consumer. */\n async function* inputs(): AsyncIterable<ArrowTableBatch> {\n sourcesRead = 1;\n const batches: AsyncIterable<unknown> = inMemory\n ? memoryBatches((source as ArrowTable).data)\n : (source as TableScanSource).read(readOptions);\n for await (const value of batches) {\n options.signal?.throwIfAborted();\n const batch = normalizeBatch(value, readSchema);\n batchesRead++;\n rowsRead += batch.length;\n yield batch;\n }\n }\n for await (const value of executeTableScanBatches(\n () => inputs(),\n {\n predicate: residual,\n limit: normalized.limit,\n signal: options.signal\n },\n {\n filter: (batch, predicate, signal) => {\n const input = batch as ArrowTableBatch;\n const data = predicate ? filterArrowTable(input.data, predicate, {signal}) : input.data;\n return {...input, ...wrapBatch(data)};\n },\n project: batch => {\n const input = batch as ArrowTableBatch;\n return {...input, ...wrapBatch(projectArrowTable(input.data, normalized.select))};\n }\n }\n )) {\n const batch = value as ArrowTableBatch;\n if (!arrow.util.compareSchemas(comparisonSchema, convertSchemaToArrow(batch.schema!)))\n throw new Error('Query output schema does not match source metadata.');\n emitted = true;\n rowsReturned += batch.length;\n yield batch;\n }\n // An empty schema-bearing batch makes collected and streaming empty results identical.\n if (!emitted) yield wrapBatch(empty);\n if (normalized.limit !== undefined && rowsReturned >= normalized.limit)\n earlyTerminationReason = 'limit';\n status = earlyTerminationReason ? 'early-terminated' : 'completed';\n } catch (failure) {\n error = failure;\n status = options.signal?.aborted ? 'cancelled' : 'failed';\n throw failure;\n } finally {\n if (status === 'early-terminated' && !earlyTerminationReason)\n earlyTerminationReason = 'consumer-return';\n try {\n await ownedSource?.close?.();\n } catch (failure) {\n if (error === undefined) {\n error = failure;\n status = options.signal?.aborted ? 'cancelled' : 'failed';\n earlyTerminationReason = undefined;\n throw failure;\n }\n } finally {\n emitQueryComplete(\n options.onQueryComplete,\n Object.freeze({\n status,\n sourcesPlanned: 1,\n sourcesRead,\n batchesRead,\n rowsRead,\n rowsReturned,\n durationMilliseconds: Date.now() - startedAt,\n ...(earlyTerminationReason ? {earlyTerminationReason} : {}),\n ...(error === undefined ? {} : {error})\n })\n );\n }\n }\n}\n\n/** Emits original Arrow RecordBatches without copying their buffers. */\nasync function* memoryBatches(data: arrow.Table): AsyncIterable<ArrowTableBatch> {\n for (const batch of data.batches) yield wrapBatch(new arrow.Table(data.schema, [batch]));\n}\n\n/** Converts supported native table batches to Arrow while preserving their declared schema. */\nfunction normalizeBatch(value: unknown, fallbackSchema: Schema): ArrowTableBatch {\n if (!value || typeof value !== 'object' || !('shape' in value))\n throw new Error('Query source returned an unsupported batch.');\n const input = value as TableBatch;\n const batch = {...input, schema: input.schema ?? fallbackSchema} as TableBatch;\n if (\n !['arrow-table', 'object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape)\n )\n throw new Error(`Unsupported query batch shape: ${batch.shape}`);\n const data =\n batch.length === 0 && batch.schema\n ? new arrow.Table(convertSchemaToArrow(batch.schema))\n : convertTableToArrow(batch);\n return {...batch, ...wrapBatch(data)} as ArrowTableBatch;\n}\n\n/** Wraps Arrow data in the standard batch envelope. */\nfunction wrapBatch(data: arrow.Table): ArrowTableBatch {\n return {\n shape: 'arrow-table',\n data,\n schema: convertArrowToSchema(data.schema),\n batchType: 'data',\n length: data.numRows\n } as ArrowTableBatch;\n}\n\n/** Opens only explicit URL source loaders; the public query owns the returned source. */\nasync function openQuerySource(options: QueryOptions): Promise<unknown> {\n const candidates = Array.isArray(options.loaders) ? options.loaders : [options.loaders];\n if (!candidates.length || candidates.some(loader => !isSourceLoader(loader) || !loader.fromUrl))\n throw new Error('Query source must specify explicit URL-capable source loaders for a URL.');\n const {source, sources, loaders, sqlParser, onQueryComplete, ...sourceOptions} = options;\n const url = source as string;\n const selected =\n candidates.length === 1 ? candidates[0]! : candidates.find(loader => loader!.testURL(url));\n if (!selected) throw new Error('No explicit source loader matches the query URL.');\n const implementation = selected.preload ? await selected.preload(url, sourceOptions) : selected;\n options.signal?.throwIfAborted();\n if (!isSourceLoader(implementation) || !implementation.fromUrl)\n throw new Error('Query source preload did not return a URL-capable source loader.');\n const authenticatedOptions = await resolveLoaderAuthenticationOptions(\n selected.getAuthentications ? selected : implementation,\n url,\n {...sourceOptions, core: {...sourceOptions.core, ignoreRegisteredLoaders: true}}\n );\n options.signal?.throwIfAborted();\n return implementation.createDataSource(url, authenticatedOptions as DataSourceOptions);\n}\n\nexport {parseSQLQuery} from './parse-sql-query';\nexport {parseSQLSelect} from './parse-sql-select';\nexport type {SQLSelectParserOptions} from './parse-sql-select';\n\nexport {createSQLCatalog} from './sql-catalog';\nexport type {SQLCatalog, SQLCatalogQuery, SQLCatalogSource, SQLCatalogTable} from './sql-catalog';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,YAAuB;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport type {\n ProgressiveAggregateQuery,\n ProgressiveQueryOptions,\n ProgressiveQuerySnapshot\n} from './query-progressive';\nimport type {SQLQuery} from '@math.gl/expressions/sql';\nimport type {ArrowTable, ArrowTableBatch, TableBatch, Schema} from '@loaders.gl/core/schema';\nimport {\n normalizeTableQuery,\n getColumnarPredicateColumns,\n executeTableScanBatches,\n planTableQuery,\n emitQueryComplete,\n type TableQuery,\n type TableQueryExecutionOptions,\n type TableQueryExecutionSummary,\n type TableScanSource,\n type TableScanReadOptions,\n type LoaderOptions,\n type DataSourceOptions,\n type Loader,\n resolveLoaderAuthenticationOptions,\n isSourceLoader\n} from '@loaders.gl/core/loader-utils';\nimport {\n convertArrowToSchema,\n convertSchemaToArrow,\n convertTableToArrow\n} from '@loaders.gl/core/schema-utils';\nimport {projectArrowTable, filterArrowTable} from './arrow-execution';\nimport {filterArrowRows} from './arrow-execution/filter-arrow-table';\nimport {createCatalogQuerySource} from './catalog-query-source';\nimport type {SQLCatalogQuery} from './sql-catalog';\nimport {resolveQuerySource} from './resolve-query-source';\nimport type {DataSource} from '@loaders.gl/core/loader-utils';\n\n/** Logical table or metadata request. */\nexport type Query = TableQuery | SQLQuery;\n\n/** Injected SQL parser; core validates and executes the returned logical query. */\nexport type SQLQueryParser = (sql: string) => Query | Promise<Query>;\n\n/** Input and execution controls for one public asynchronous table query. */\nexport type QueryOptions = TableQueryExecutionOptions &\n LoaderOptions &\n Readonly<{\n /** Source construction options, including an explicit core.name. */\n core?: DataSourceOptions['core'];\n /** Named caller-owned data sources used by FROM and metadata commands. */\n sources?: readonly DataSource<unknown, DataSourceOptions>[];\n /** Parser or lazy parser promise, required only for SQL string input. */\n sqlParser?: SQLQueryParser | Promise<SQLQueryParser>;\n /** Append-only batches (default), or complete progressive replacement snapshots. */\n queryOutput?: 'batches' | 'snapshots';\n }> &\n Readonly<\n | {\n /** Already loaded Arrow table or caller-owned table scan source. */\n source: ArrowTable | TableScanSource;\n /** URL loader selection is only used with URL sources. */\n loaders?: never;\n }\n | {\n /** FROM chooses a source from the named registry when no default source is supplied. */\n source?: undefined;\n /** Named sources available for FROM resolution. */\n sources: readonly DataSource<unknown, DataSourceOptions>[];\n /** URL loader selection requires a URL source. */\n loaders?: never;\n }\n | {\n /** URL opened lazily with the explicitly supplied source loaders. */\n source: string;\n /** URL-capable source loaders; registered loaders are never selected implicitly. */\n loaders: Loader | Loader[];\n }\n >;\n\n/** Collects the same ordered Arrow batch pipeline exposed by queryInBatches. */\nexport async function query(\n tableQuery: Query | string,\n options: QueryOptions\n): Promise<ArrowTable> {\n let schema: arrow.Schema | undefined;\n const batches: arrow.RecordBatch[] = [];\n for await (const batch of queryInBatches(tableQuery, {...options, queryOutput: undefined})) {\n schema = batch.data.schema;\n batches.push(...batch.data.batches);\n }\n const data = new arrow.Table(schema!, batches);\n return {shape: 'arrow-table', schema: convertArrowToSchema(data.schema), data};\n}\n\n/**\n * Without queryOutput, preserves the legacy loaders.gl ArrowTableBatch envelope.\n * With queryOutput, yields pure Arrow RecordBatch objects. Each snapshot replaces\n * all earlier snapshots; batches are append-only.\n */\nexport function queryInBatches(\n tableQuery: ProgressiveAggregateQuery,\n options: QueryOptions & {queryOutput: 'snapshots'; emitEveryBatches?: number}\n): AsyncIterable<arrow.RecordBatch>;\nexport function queryInBatches(\n tableQuery: Query | string,\n options: QueryOptions & {queryOutput: 'batches'}\n): AsyncIterable<arrow.RecordBatch>;\nexport function queryInBatches(\n tableQuery: Query | string,\n options: QueryOptions & {queryOutput?: undefined}\n): AsyncIterable<ArrowTableBatch>;\nexport function queryInBatches(\n tableQuery: Query | string | ProgressiveAggregateQuery,\n options: QueryOptions\n): AsyncIterable<ArrowTableBatch | arrow.RecordBatch>;\nexport async function* queryInBatches(\n tableQuery: Query | string | ProgressiveAggregateQuery,\n options: QueryOptions\n): AsyncIterable<ArrowTableBatch | arrow.RecordBatch> {\n if (options.queryOutput === 'snapshots') {\n if (\n !tableQuery ||\n typeof tableQuery !== 'object' ||\n !('aggregates' in tableQuery) ||\n !Array.isArray(tableQuery.aggregates)\n ) {\n throw new Error('Snapshot query output currently requires a structured aggregate query.');\n }\n for await (const snapshot of queryProgressive(tableQuery, options)) {\n yield* snapshot.table.data.batches;\n }\n return;\n }\n if (options.queryOutput !== undefined && options.queryOutput !== 'batches') {\n throw new Error('Unsupported queryOutput; expected batches or snapshots.');\n }\n if (typeof tableQuery === 'object' && tableQuery && 'aggregates' in tableQuery) {\n throw new Error('Aggregate queries require queryOutput: snapshots.');\n }\n for await (const batch of queryAppendBatches(tableQuery as Query | string, options)) {\n if (options.queryOutput === 'batches') {\n yield* batch.data.batches;\n } else {\n yield batch;\n }\n }\n}\n\n/** Streams complete aggregate snapshots and loads the grouped executor on demand. */\nexport async function* queryProgressive(\n query: ProgressiveAggregateQuery,\n options: ProgressiveQueryOptions\n): AsyncIterable<ProgressiveQuerySnapshot> {\n const {executeProgressiveQuery} = await import('./query-progressive');\n yield* executeProgressiveQuery(query, options);\n}\n\n/** Executes one logical query with bounded batch buffering and cooperative cancellation. */\nasync function* queryAppendBatches(\n tableQuery: Query | string,\n options: QueryOptions\n): AsyncIterable<ArrowTableBatch> {\n const startedAt = Date.now();\n let status: TableQueryExecutionSummary['status'] = 'early-terminated';\n let rowsRead = 0;\n let rowsReturned = 0;\n let batchesRead = 0;\n let sourcesRead = 0;\n let error: unknown;\n let ownedSource: {close?: () => void | Promise<void>} | undefined;\n let earlyTerminationReason: TableQueryExecutionSummary['earlyTerminationReason'];\n try {\n options.signal?.throwIfAborted();\n let parsedQuery: Query;\n if (typeof tableQuery === 'string') {\n const parser = await options.sqlParser;\n options.signal?.throwIfAborted();\n if (typeof parser !== 'function')\n throw new Error('SQL queries require a sqlParser function or promise.');\n parsedQuery = await parser(tableQuery);\n options.signal?.throwIfAborted();\n } else parsedQuery = tableQuery;\n if (!parsedQuery || typeof parsedQuery !== 'object' || Array.isArray(parsedQuery))\n throw new Error('Table query must be an object.');\n const castPredicate =\n 'command' in parsedQuery ? false : validatePredicateOperands(parsedQuery.where);\n let logicalQuery: TableQuery | Exclude<SQLQuery, SQLCatalogQuery>;\n let source: unknown;\n if ('command' in parsedQuery) {\n logicalQuery = {};\n source = createCatalogQuerySource(parsedQuery, options.sources);\n } else {\n logicalQuery = parsedQuery;\n source =\n logicalQuery.from === undefined\n ? options.source\n : await resolveQuerySource(logicalQuery.from, options.sources, options.signal);\n }\n if (logicalQuery.from === undefined && typeof source === 'string') {\n const opened = await openQuerySource(options);\n if (\n opened &&\n typeof opened === 'object' &&\n 'close' in opened &&\n typeof opened.close === 'function'\n )\n ownedSource = opened as {close: () => void | Promise<void>};\n source = opened;\n }\n options.signal?.throwIfAborted();\n if (!source || typeof source !== 'object')\n throw new Error('Query source must be an Arrow table or table scan source.');\n const inMemory = 'shape' in source && source.shape === 'arrow-table';\n if (\n !inMemory &&\n (!('read' in source) ||\n typeof source.read !== 'function' ||\n !('getQueryMetadata' in source) ||\n typeof source.getQueryMetadata !== 'function')\n ) {\n throw new Error('Query source must be an Arrow table or table scan source.');\n }\n const metadata = inMemory\n ? undefined\n : await (source as TableScanSource).getQueryMetadata({signal: options.signal});\n options.signal?.throwIfAborted();\n if (\n metadata &&\n (metadata.queryType !== 'table' ||\n metadata.execution.status !== 'supported' ||\n metadata.execution.method !== 'read')\n ) {\n throw new Error('Query source must support table reads.');\n }\n const sourceSchema = inMemory\n ? (source as ArrowTable).data.schema\n : convertSchemaToArrow(metadata!.schema);\n const names = sourceSchema.fields.map(field => field.name);\n const {select, where, ...controls} = logicalQuery;\n const computedProjection =\n Array.isArray(select) &&\n select.some(\n selection =>\n selection &&\n typeof selection === 'object' &&\n ('expression' in selection || 'array' in selection)\n );\n const expressionFilter =\n where && typeof where === 'object' && 'expression' in where ? where : undefined;\n const portablePredicate = expressionFilter ? undefined : (where as TableQuery['where']);\n const normalized = normalizeTableQuery(names, {\n ...controls,\n select: computedProjection ? undefined : (select as TableQuery['select']),\n where: castPredicate ? undefined : portablePredicate\n });\n const expressionTools =\n computedProjection || expressionFilter || castPredicate\n ? await import('./arrow-execution/expressions')\n : undefined;\n const outputColumns = computedProjection\n ? expressionTools!.getProjectionColumns(select!)\n : normalized.select.map(selection => selection.column);\n const expressionColumns = expressionFilter\n ? expressionTools!.getExpressionColumns(expressionFilter.expression)\n : castPredicate && portablePredicate\n ? getColumnarPredicateColumns(portablePredicate)\n : [];\n const required = [...new Set([...outputColumns, ...expressionColumns])];\n const plan = planTableQuery(names, {\n // A literal-only projection still needs a physical column to retain row counts.\n columns: required.length ? required : names.slice(0, 1),\n predicate: normalized.where\n });\n const requiredColumns = plan[0].kind === 'scan' ? plan[0].columns : names;\n const capabilities = metadata?.capabilities.table;\n // read() must perform exact filtering when it advertises pushdown+residual, not only pruning.\n const delegatePredicate = Boolean(\n normalized.where &&\n capabilities &&\n ['pushdown', 'pushdown+residual'].includes(capabilities.predicate)\n );\n const residual = delegatePredicate ? undefined : normalized.where;\n const requestedRows =\n normalized.limit === undefined ? undefined : (normalized.offset ?? 0) + normalized.limit;\n const readOptions: TableScanReadOptions = {\n signal: options.signal,\n ...(capabilities && capabilities.projection !== 'unsupported'\n ? {columns: requiredColumns}\n : {}),\n ...(delegatePredicate ? {predicate: normalized.where} : {}),\n ...(!residual &&\n !expressionFilter &&\n !castPredicate &&\n requestedRows !== undefined &&\n Number.isSafeInteger(requestedRows) &&\n capabilities &&\n ['pushdown', 'pushdown+residual'].includes(capabilities.limit)\n ? {limit: requestedRows}\n : {})\n };\n const inputSchema = readOptions.columns\n ? sourceSchema.select([...readOptions.columns])\n : sourceSchema;\n const readSchema = convertArrowToSchema(inputSchema);\n const comparisonInputSchema = expressionTools ? convertSchemaToArrow(readSchema) : undefined;\n const compiledFilter = expressionFilter\n ? expressionTools!.compileArrowExpression(expressionFilter.expression, {inputSchema})\n : castPredicate && portablePredicate\n ? expressionTools!.compileArrowPredicate(portablePredicate, {inputSchema})\n : undefined;\n if (compiledFilter && !arrow.DataType.isBool(compiledFilter.outputField.type))\n throw new Error('SQL WHERE expression must return Boolean.');\n const project = computedProjection\n ? expressionTools!.compileArrowProjection(inputSchema, select!, options.signal)\n : (data: arrow.Table) => projectArrowTable(data, normalized.select);\n const empty = project(new arrow.Table(inputSchema));\n const comparisonSchema = convertSchemaToArrow(convertArrowToSchema(empty.schema));\n let emitted = false;\n /** Adapts physical batches without pulling ahead of the query consumer. */\n async function* inputs(): AsyncIterable<ArrowTableBatch> {\n sourcesRead = 1;\n const batches: AsyncIterable<unknown> = inMemory\n ? memoryBatches((source as ArrowTable).data)\n : (source as TableScanSource).read(readOptions);\n for await (const value of batches) {\n options.signal?.throwIfAborted();\n let batch = normalizeBatch(value, readSchema);\n if (\n comparisonInputSchema &&\n !arrow.util.compareSchemas(comparisonInputSchema, convertSchemaToArrow(batch.schema!))\n ) {\n // A source may return a wider or differently ordered projection than requested.\n const data = batch.data.select(inputSchema.names);\n batch = {...batch, ...wrapBatch(data)};\n if (\n !arrow.util.compareSchemas(comparisonInputSchema, convertSchemaToArrow(batch.schema!))\n )\n throw new Error('Query input schema does not match source metadata.');\n }\n batchesRead++;\n rowsRead += batch.length;\n yield batch;\n }\n }\n for await (const value of executeTableScanBatches(\n () => inputs(),\n {\n predicate: residual,\n offset: normalized.offset,\n limit: normalized.limit,\n skipEmptyBatches: true,\n signal: options.signal\n },\n {\n filter: (batch, predicate, signal) => {\n const input = batch as ArrowTableBatch;\n const data = compiledFilter\n ? filterArrowRows(\n input.data,\n batch => {\n const matches = compiledFilter.evaluate(batch, {signal});\n return index => matches.get(index) === true;\n },\n {signal}\n )\n : predicate\n ? filterArrowTable(input.data, predicate, {signal})\n : input.data;\n return {...input, ...wrapBatch(data)};\n },\n project: batch => {\n const input = batch as ArrowTableBatch;\n return computedProjection ? input : {...input, ...wrapBatch(project(input.data))};\n }\n }\n )) {\n const input = value as ArrowTableBatch;\n const batch = computedProjection ? {...input, ...wrapBatch(project(input.data))} : input;\n if (!arrow.util.compareSchemas(comparisonSchema, convertSchemaToArrow(batch.schema!)))\n throw new Error('Query output schema does not match source metadata.');\n emitted = true;\n rowsReturned += batch.length;\n yield batch;\n }\n // An empty schema-bearing batch makes collected and streaming empty results identical.\n if (!emitted) yield wrapBatch(empty);\n if (normalized.limit !== undefined && rowsReturned >= normalized.limit)\n earlyTerminationReason = 'limit';\n status = earlyTerminationReason ? 'early-terminated' : 'completed';\n } catch (failure) {\n error = failure;\n status = options.signal?.aborted ? 'cancelled' : 'failed';\n throw failure;\n } finally {\n if (status === 'early-terminated' && !earlyTerminationReason)\n earlyTerminationReason = 'consumer-return';\n try {\n await ownedSource?.close?.();\n } catch (failure) {\n if (error === undefined) {\n error = failure;\n status = options.signal?.aborted ? 'cancelled' : 'failed';\n earlyTerminationReason = undefined;\n throw failure;\n }\n } finally {\n emitQueryComplete(\n options.onQueryComplete,\n Object.freeze({\n status,\n sourcesPlanned: 1,\n sourcesRead,\n batchesRead,\n rowsRead,\n rowsReturned,\n durationMilliseconds: Date.now() - startedAt,\n ...(earlyTerminationReason ? {earlyTerminationReason} : {}),\n ...(error === undefined ? {} : {error})\n })\n );\n }\n }\n}\n\n/** Emits original Arrow RecordBatches without copying their buffers. */\nasync function* memoryBatches(data: arrow.Table): AsyncIterable<ArrowTableBatch> {\n for (const batch of data.batches) yield wrapBatch(new arrow.Table(data.schema, [batch]));\n}\n\n/** Converts supported native table batches to Arrow while preserving their declared schema. */\nfunction normalizeBatch(value: unknown, fallbackSchema: Schema): ArrowTableBatch {\n if (!value || typeof value !== 'object' || !('shape' in value))\n throw new Error('Query source returned an unsupported batch.');\n const input = value as TableBatch;\n const batch = {...input, schema: input.schema ?? fallbackSchema} as TableBatch;\n if (\n !['arrow-table', 'object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape)\n )\n throw new Error(`Unsupported query batch shape: ${batch.shape}`);\n const data =\n batch.length === 0 && batch.schema\n ? new arrow.Table(convertSchemaToArrow(batch.schema))\n : convertTableToArrow(batch);\n return {...batch, ...wrapBatch(data)} as ArrowTableBatch;\n}\n\n/** Wraps Arrow data in the standard batch envelope. */\nfunction wrapBatch(data: arrow.Table): ArrowTableBatch {\n return {\n shape: 'arrow-table',\n data,\n schema: convertArrowToSchema(data.schema),\n batchType: 'data',\n length: data.numRows\n } as ArrowTableBatch;\n}\n\n/** Opens only explicit URL source loaders; the public query owns the returned source. */\nasync function openQuerySource(options: QueryOptions): Promise<unknown> {\n const candidates = Array.isArray(options.loaders) ? options.loaders : [options.loaders];\n if (\n !candidates.length ||\n !candidates.every(isSourceLoader) ||\n candidates.some(loader => !loader.fromUrl)\n ) {\n throw new Error('Query source must specify explicit URL-capable source loaders for a URL.');\n }\n const {source, sources, loaders, sqlParser, onQueryComplete, queryOutput, ...sourceOptions} =\n options;\n const url = source as string;\n const selected =\n candidates.length === 1 ? candidates[0]! : candidates.find(loader => loader!.testURL(url));\n if (!selected) throw new Error('No explicit source loader matches the query URL.');\n const implementation = selected.preload ? await selected.preload(url, sourceOptions) : selected;\n options.signal?.throwIfAborted();\n if (!isSourceLoader(implementation) || !implementation.fromUrl)\n throw new Error('Query source preload did not return a URL-capable source loader.');\n const authenticatedOptions = await resolveLoaderAuthenticationOptions(\n selected.getAuthentications ? selected : implementation,\n url,\n {...sourceOptions, core: {...sourceOptions.core, ignoreRegisteredLoaders: true}}\n );\n options.signal?.throwIfAborted();\n return implementation.createDataSourceSync(url, authenticatedOptions as DataSourceOptions);\n}\n\nexport {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/expressions/sql';\n\nexport {createSQLCatalog} from './sql-catalog';\nexport type {SQLCatalog, SQLCatalogQuery, SQLCatalogSource, SQLCatalogTable} from './sql-catalog';\n\n/** Checks predicate tree bounds and detects casts that require Arrow execution. */\nfunction validatePredicateOperands(where: unknown): boolean {\n if (where && typeof where === 'object' && 'expression' in where) {\n if (Object.keys(where).some(key => key !== 'expression'))\n throw new Error('Unsupported computed WHERE field.');\n return false;\n }\n let castPredicate = false;\n const pending: {value: unknown; exit?: boolean}[] = where ? [{value: where}] : [];\n const visited = new WeakSet<object>();\n let nodes = 0;\n while (pending.length) {\n const frame = pending.pop()!;\n const candidate = frame.value;\n if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate)) continue;\n if (frame.exit) {\n visited.delete(candidate);\n continue;\n }\n if (visited.has(candidate) || ++nodes > 4096)\n throw new Error('Query predicate must be an acyclic tree of at most 4096 nodes.');\n visited.add(candidate);\n if (isUnsupportedQueryExpression(candidate))\n throw new Error('CAST and computed WHERE operands are not supported by this query executor.');\n const predicate = candidate as {op?: unknown; args?: unknown};\n if (!Array.isArray(predicate.args)) continue;\n if (predicate.op === 'and' || predicate.op === 'or' || predicate.op === 'not') {\n if (predicate.args.length > 4096 - nodes)\n throw new Error('Query predicate exceeds 4096 nodes.');\n pending.push({value: candidate, exit: true});\n pending.push(...predicate.args.map(value => ({value})));\n continue;\n }\n visited.delete(candidate);\n for (const [index, operand] of predicate.args.entries()) {\n if (\n index === 0 &&\n operand &&\n typeof operand === 'object' &&\n typeof operand.property === 'string' &&\n 'casts' in operand\n ) {\n castPredicate = true;\n continue;\n }\n if (\n isUnsupportedQueryExpression(operand) ||\n (Array.isArray(operand) && operand.some(isUnsupportedQueryExpression))\n )\n throw new Error(\n 'CAST and computed WHERE operands are not supported by this query executor.'\n );\n }\n }\n return castPredicate;\n}\n\n/** Identifies newer portable operands and raw expression ASTs without interpreting scalar values. */\nfunction isUnsupportedQueryExpression(value: unknown): boolean {\n if (!value || typeof value !== 'object') return false;\n if ('casts' in value || 'expression' in value) return true;\n return (\n 'type' in value &&\n typeof value.type === 'string' &&\n /Expression$|^(Identifier|Literal|Compound)$/.test(value.type)\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,YAAuB;AAQvB,0BAgBO;AACP,0BAIO;AACP,6BAAkD;AAClD,gCAA8B;AAC9B,kCAAuC;AAEvC,kCAAiC;AAocjC,iBAAyE;AAEzE,yBAA+B;AAxZ/B,eAAsB,MACpB,YACA,SACqB;AACrB,MAAI;AACJ,QAAM,UAA+B,CAAC;AACtC,mBAAiB,SAAS,eAAe,YAAY,EAAC,GAAG,SAAS,aAAa,OAAS,CAAC,GAAG;AAC1F,aAAS,MAAM,KAAK;AACpB,YAAQ,KAAK,GAAG,MAAM,KAAK,OAAO;AAAA,EACpC;A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