@loaders.gl/core 5.0.0-beta.5 → 5.0.0-beta.7
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/cluster-source.cjs +45 -1
- package/dist/cluster-source.cjs.map +1 -1
- package/dist/dist.min.js +2 -2
- package/dist/federated-table-scan-source.cjs +279 -201
- package/dist/federated-table-scan-source.cjs.map +3 -3
- package/dist/index.cjs +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/loader-utils/index.cjs +233 -12
- package/dist/loader-utils/index.cjs.map +2 -2
- package/dist/loader-utils/index.d.ts +8 -4
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +3 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.d.ts +4 -0
- package/dist/loader-utils/lib/files/http-file-transport.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.js +45 -1
- package/dist/loader-utils/lib/files/http-file-transport.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-types.d.ts +2 -0
- package/dist/loader-utils/lib/files/http-file-types.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/read-range-response.d.ts +3 -0
- package/dist/loader-utils/lib/files/read-range-response.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/read-range-response.js +62 -0
- package/dist/loader-utils/lib/files/read-range-response.js.map +1 -0
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +38 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +96 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/{experimental-scan-options.d.ts → query-options.d.ts} +5 -8
- package/dist/loader-utils/lib/scan-utils/query-options.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/{experimental-scan-options.js → query-options.js} +1 -1
- package/dist/loader-utils/lib/scan-utils/query-options.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +12 -17
- 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 +5 -5
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +33 -3
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +2 -2
- 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 +11 -3
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts +4 -0
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +50 -1
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +30 -0
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/table-source-collection.js +5 -0
- package/dist/loader-utils/lib/sources/table-source-collection.js.map +1 -0
- package/dist/loader-utils/loader-types.d.ts +5 -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 +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 +266 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +18 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js +230 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs +70 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +8 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.js +39 -0
- package/dist/scan/arrow-execution/project-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution.cjs +34 -0
- package/dist/scan/arrow-execution.cjs.map +7 -0
- package/dist/scan/arrow-execution.d.ts +4 -0
- package/dist/scan/arrow-execution.d.ts.map +1 -0
- package/dist/scan/arrow-execution.js +6 -0
- package/dist/scan/arrow-execution.js.map +1 -0
- package/dist/scan/arrow-query.cjs.map +1 -1
- package/dist/scan/arrow-query.d.ts +1 -1
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/catalog-query-source.cjs +122 -0
- package/dist/scan/catalog-query-source.cjs.map +7 -0
- package/dist/scan/catalog-query-source.d.ts +6 -0
- package/dist/scan/catalog-query-source.d.ts.map +1 -0
- package/dist/scan/catalog-query-source.js +115 -0
- package/dist/scan/catalog-query-source.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +4 -4
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts +1 -1
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +4 -4
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +188 -4
- package/dist/scan/index.cjs.map +4 -4
- package/dist/scan/index.d.ts +9 -2
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +4 -0
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +6 -9
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -314
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.cjs +65 -0
- package/dist/scan/query-arrow-table-in-batches.cjs.map +7 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts +8 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.js +44 -0
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -0
- package/dist/scan/query-arrow-table.cjs +52 -179
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +4 -37
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +37 -188
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query.cjs +344 -0
- package/dist/scan/query.cjs.map +7 -0
- package/dist/scan/query.d.ts +42 -0
- package/dist/scan/query.d.ts.map +1 -0
- package/dist/scan/query.js +367 -0
- package/dist/scan/query.js.map +1 -0
- package/dist/scan/resolve-query-source.cjs +59 -0
- package/dist/scan/resolve-query-source.cjs.map +7 -0
- package/dist/scan/resolve-query-source.d.ts +6 -0
- package/dist/scan/resolve-query-source.d.ts.map +1 -0
- package/dist/scan/resolve-query-source.js +37 -0
- package/dist/scan/resolve-query-source.js.map +1 -0
- package/dist/scan/sql-catalog.cjs +110 -0
- package/dist/scan/sql-catalog.cjs.map +7 -0
- package/dist/scan/sql-catalog.d.ts +47 -0
- package/dist/scan/sql-catalog.d.ts.map +1 -0
- package/dist/scan/sql-catalog.js +97 -0
- package/dist/scan/sql-catalog.js.map +1 -0
- package/dist/scan/table-query.cjs.map +2 -2
- package/dist/scan/table-query.d.ts +4 -1
- package/dist/scan/table-query.d.ts.map +1 -1
- package/dist/scan/table-query.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +288 -193
- package/dist/vector-table-scan-source.cjs.map +3 -3
- package/dist/worker-utils/index.cjs +2 -1
- package/dist/worker-utils/index.cjs.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/package.json +17 -7
- package/src/loader-utils/index.ts +30 -6
- package/src/loader-utils/lib/files/http-file-transport.ts +65 -1
- package/src/loader-utils/lib/files/http-file-types.ts +2 -0
- package/src/loader-utils/lib/files/read-range-response.ts +66 -0
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +164 -0
- package/src/loader-utils/lib/scan-utils/query-options.ts +44 -0
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +17 -26
- package/src/loader-utils/lib/scan-utils/table-query.ts +49 -8
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +25 -9
- package/src/loader-utils/lib/sources/data-source.ts +54 -1
- package/src/loader-utils/lib/sources/table-source-collection.ts +38 -0
- package/src/loader-utils/loader-types.ts +5 -5
- package/src/scan/arrow-execution/expressions.ts +86 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +309 -0
- package/src/scan/arrow-execution/project-arrow-table.ts +53 -0
- package/src/scan/arrow-execution.ts +7 -0
- package/src/scan/arrow-query.ts +3 -0
- package/src/scan/catalog-query-source.ts +132 -0
- package/src/scan/federated-table-scan-source.ts +19 -19
- package/src/scan/index.ts +28 -4
- package/src/scan/parse-sql-predicate.ts +14 -367
- package/src/scan/query-arrow-table-in-batches.ts +58 -0
- package/src/scan/query-arrow-table.ts +60 -237
- package/src/scan/query.ts +480 -0
- package/src/scan/resolve-query-source.ts +47 -0
- package/src/scan/sql-catalog.ts +167 -0
- package/src/scan/table-query.ts +6 -1
- package/src/worker-utils/lib/library-utils/library-utils.ts +1 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.d.ts.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.js.map +0 -1
- package/src/loader-utils/lib/scan-utils/experimental-scan-options.ts +0 -46
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import * as arrow from 'apache-arrow';
|
|
5
|
+
import { normalizeTableQuery, getColumnarPredicateColumns, executeTableScanBatches, planTableQuery, emitQueryComplete, resolveLoaderAuthenticationOptions, isSourceLoader } from '@loaders.gl/core/loader-utils';
|
|
6
|
+
import { convertArrowToSchema, convertSchemaToArrow, convertTableToArrow } from '@loaders.gl/core/schema-utils';
|
|
7
|
+
import { projectArrowTable, filterArrowTable } from "./arrow-execution.js";
|
|
8
|
+
import { filterArrowRows } from "./arrow-execution/filter-arrow-table.js";
|
|
9
|
+
import { createCatalogQuerySource } from "./catalog-query-source.js";
|
|
10
|
+
import { resolveQuerySource } from "./resolve-query-source.js";
|
|
11
|
+
/** Collects the same ordered Arrow batch pipeline exposed by queryInBatches. */
|
|
12
|
+
export async function query(tableQuery, options) {
|
|
13
|
+
let schema;
|
|
14
|
+
const batches = [];
|
|
15
|
+
for await (const batch of queryInBatches(tableQuery, options)) {
|
|
16
|
+
schema = batch.data.schema;
|
|
17
|
+
batches.push(...batch.data.batches);
|
|
18
|
+
}
|
|
19
|
+
const data = new arrow.Table(schema, batches);
|
|
20
|
+
return { shape: 'arrow-table', schema: convertArrowToSchema(data.schema), data };
|
|
21
|
+
}
|
|
22
|
+
/** Executes one logical query with bounded batch buffering and cooperative cancellation. */
|
|
23
|
+
export async function* queryInBatches(tableQuery, options) {
|
|
24
|
+
const startedAt = Date.now();
|
|
25
|
+
let status = 'early-terminated';
|
|
26
|
+
let rowsRead = 0;
|
|
27
|
+
let rowsReturned = 0;
|
|
28
|
+
let batchesRead = 0;
|
|
29
|
+
let sourcesRead = 0;
|
|
30
|
+
let error;
|
|
31
|
+
let ownedSource;
|
|
32
|
+
let earlyTerminationReason;
|
|
33
|
+
try {
|
|
34
|
+
options.signal?.throwIfAborted();
|
|
35
|
+
let parsedQuery;
|
|
36
|
+
if (typeof tableQuery === 'string') {
|
|
37
|
+
const parser = await options.sqlParser;
|
|
38
|
+
options.signal?.throwIfAborted();
|
|
39
|
+
if (typeof parser !== 'function')
|
|
40
|
+
throw new Error('SQL queries require a sqlParser function or promise.');
|
|
41
|
+
parsedQuery = await parser(tableQuery);
|
|
42
|
+
options.signal?.throwIfAborted();
|
|
43
|
+
}
|
|
44
|
+
else
|
|
45
|
+
parsedQuery = tableQuery;
|
|
46
|
+
if (!parsedQuery || typeof parsedQuery !== 'object' || Array.isArray(parsedQuery))
|
|
47
|
+
throw new Error('Table query must be an object.');
|
|
48
|
+
const castPredicate = 'command' in parsedQuery ? false : validatePredicateOperands(parsedQuery.where);
|
|
49
|
+
let logicalQuery;
|
|
50
|
+
let source;
|
|
51
|
+
if ('command' in parsedQuery) {
|
|
52
|
+
logicalQuery = {};
|
|
53
|
+
source = createCatalogQuerySource(parsedQuery, options.sources);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
logicalQuery = parsedQuery;
|
|
57
|
+
source =
|
|
58
|
+
logicalQuery.from === undefined
|
|
59
|
+
? options.source
|
|
60
|
+
: await resolveQuerySource(logicalQuery.from, options.sources, options.signal);
|
|
61
|
+
}
|
|
62
|
+
if (logicalQuery.from === undefined && typeof source === 'string') {
|
|
63
|
+
const opened = await openQuerySource(options);
|
|
64
|
+
if (opened &&
|
|
65
|
+
typeof opened === 'object' &&
|
|
66
|
+
'close' in opened &&
|
|
67
|
+
typeof opened.close === 'function')
|
|
68
|
+
ownedSource = opened;
|
|
69
|
+
source = opened;
|
|
70
|
+
}
|
|
71
|
+
options.signal?.throwIfAborted();
|
|
72
|
+
if (!source || typeof source !== 'object')
|
|
73
|
+
throw new Error('Query source must be an Arrow table or table scan source.');
|
|
74
|
+
const inMemory = 'shape' in source && source.shape === 'arrow-table';
|
|
75
|
+
if (!inMemory &&
|
|
76
|
+
(!('read' in source) ||
|
|
77
|
+
typeof source.read !== 'function' ||
|
|
78
|
+
!('getQueryMetadata' in source) ||
|
|
79
|
+
typeof source.getQueryMetadata !== 'function')) {
|
|
80
|
+
throw new Error('Query source must be an Arrow table or table scan source.');
|
|
81
|
+
}
|
|
82
|
+
const metadata = inMemory
|
|
83
|
+
? undefined
|
|
84
|
+
: await source.getQueryMetadata({ signal: options.signal });
|
|
85
|
+
options.signal?.throwIfAborted();
|
|
86
|
+
if (metadata &&
|
|
87
|
+
(metadata.queryType !== 'table' ||
|
|
88
|
+
metadata.execution.status !== 'supported' ||
|
|
89
|
+
metadata.execution.method !== 'read')) {
|
|
90
|
+
throw new Error('Query source must support table reads.');
|
|
91
|
+
}
|
|
92
|
+
const sourceSchema = inMemory
|
|
93
|
+
? source.data.schema
|
|
94
|
+
: convertSchemaToArrow(metadata.schema);
|
|
95
|
+
const names = sourceSchema.fields.map(field => field.name);
|
|
96
|
+
const { select, where, ...controls } = logicalQuery;
|
|
97
|
+
const computedProjection = Array.isArray(select) &&
|
|
98
|
+
select.some(selection => selection &&
|
|
99
|
+
typeof selection === 'object' &&
|
|
100
|
+
('expression' in selection || 'array' in selection));
|
|
101
|
+
const expressionFilter = where && typeof where === 'object' && 'expression' in where ? where : undefined;
|
|
102
|
+
const portablePredicate = expressionFilter ? undefined : where;
|
|
103
|
+
const normalized = normalizeTableQuery(names, {
|
|
104
|
+
...controls,
|
|
105
|
+
select: computedProjection ? undefined : select,
|
|
106
|
+
where: castPredicate ? undefined : portablePredicate
|
|
107
|
+
});
|
|
108
|
+
const expressionTools = computedProjection || expressionFilter || castPredicate
|
|
109
|
+
? await import("./arrow-execution/expressions.js")
|
|
110
|
+
: undefined;
|
|
111
|
+
const outputColumns = computedProjection
|
|
112
|
+
? expressionTools.getProjectionColumns(select)
|
|
113
|
+
: normalized.select.map(selection => selection.column);
|
|
114
|
+
const expressionColumns = expressionFilter
|
|
115
|
+
? expressionTools.getExpressionColumns(expressionFilter.expression)
|
|
116
|
+
: castPredicate && portablePredicate
|
|
117
|
+
? getColumnarPredicateColumns(portablePredicate)
|
|
118
|
+
: [];
|
|
119
|
+
const required = [...new Set([...outputColumns, ...expressionColumns])];
|
|
120
|
+
const plan = planTableQuery(names, {
|
|
121
|
+
// A literal-only projection still needs a physical column to retain row counts.
|
|
122
|
+
columns: required.length ? required : names.slice(0, 1),
|
|
123
|
+
predicate: normalized.where
|
|
124
|
+
});
|
|
125
|
+
const requiredColumns = plan[0].kind === 'scan' ? plan[0].columns : names;
|
|
126
|
+
const capabilities = metadata?.capabilities.table;
|
|
127
|
+
// read() must perform exact filtering when it advertises pushdown+residual, not only pruning.
|
|
128
|
+
const delegatePredicate = Boolean(normalized.where &&
|
|
129
|
+
capabilities &&
|
|
130
|
+
['pushdown', 'pushdown+residual'].includes(capabilities.predicate));
|
|
131
|
+
const residual = delegatePredicate ? undefined : normalized.where;
|
|
132
|
+
const readOptions = {
|
|
133
|
+
signal: options.signal,
|
|
134
|
+
...(capabilities && capabilities.projection !== 'unsupported'
|
|
135
|
+
? { columns: requiredColumns }
|
|
136
|
+
: {}),
|
|
137
|
+
...(delegatePredicate ? { predicate: normalized.where } : {}),
|
|
138
|
+
...(!residual &&
|
|
139
|
+
!expressionFilter &&
|
|
140
|
+
!castPredicate &&
|
|
141
|
+
capabilities &&
|
|
142
|
+
['pushdown', 'pushdown+residual'].includes(capabilities.limit)
|
|
143
|
+
? { limit: normalized.limit }
|
|
144
|
+
: {})
|
|
145
|
+
};
|
|
146
|
+
const inputSchema = readOptions.columns
|
|
147
|
+
? sourceSchema.select([...readOptions.columns])
|
|
148
|
+
: sourceSchema;
|
|
149
|
+
const readSchema = convertArrowToSchema(inputSchema);
|
|
150
|
+
const comparisonInputSchema = expressionTools ? convertSchemaToArrow(readSchema) : undefined;
|
|
151
|
+
const compiledFilter = expressionFilter
|
|
152
|
+
? expressionTools.compileArrowExpression(expressionFilter.expression, { inputSchema })
|
|
153
|
+
: castPredicate && portablePredicate
|
|
154
|
+
? expressionTools.compileArrowPredicate(portablePredicate, { inputSchema })
|
|
155
|
+
: undefined;
|
|
156
|
+
if (compiledFilter && !arrow.DataType.isBool(compiledFilter.outputField.type))
|
|
157
|
+
throw new Error('SQL WHERE expression must return Boolean.');
|
|
158
|
+
const project = computedProjection
|
|
159
|
+
? expressionTools.compileArrowProjection(inputSchema, select, options.signal)
|
|
160
|
+
: (data) => projectArrowTable(data, normalized.select);
|
|
161
|
+
const empty = project(new arrow.Table(inputSchema));
|
|
162
|
+
const comparisonSchema = convertSchemaToArrow(convertArrowToSchema(empty.schema));
|
|
163
|
+
let emitted = false;
|
|
164
|
+
/** Adapts physical batches without pulling ahead of the query consumer. */
|
|
165
|
+
async function* inputs() {
|
|
166
|
+
sourcesRead = 1;
|
|
167
|
+
const batches = inMemory
|
|
168
|
+
? memoryBatches(source.data)
|
|
169
|
+
: source.read(readOptions);
|
|
170
|
+
for await (const value of batches) {
|
|
171
|
+
options.signal?.throwIfAborted();
|
|
172
|
+
let batch = normalizeBatch(value, readSchema);
|
|
173
|
+
if (comparisonInputSchema &&
|
|
174
|
+
!arrow.util.compareSchemas(comparisonInputSchema, convertSchemaToArrow(batch.schema))) {
|
|
175
|
+
// A source may return a wider or differently ordered projection than requested.
|
|
176
|
+
const data = batch.data.select(inputSchema.names);
|
|
177
|
+
batch = { ...batch, ...wrapBatch(data) };
|
|
178
|
+
if (!arrow.util.compareSchemas(comparisonInputSchema, convertSchemaToArrow(batch.schema)))
|
|
179
|
+
throw new Error('Query input schema does not match source metadata.');
|
|
180
|
+
}
|
|
181
|
+
batchesRead++;
|
|
182
|
+
rowsRead += batch.length;
|
|
183
|
+
yield batch;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for await (const value of executeTableScanBatches(() => inputs(), {
|
|
187
|
+
predicate: residual,
|
|
188
|
+
limit: normalized.limit,
|
|
189
|
+
signal: options.signal
|
|
190
|
+
}, {
|
|
191
|
+
filter: (batch, predicate, signal) => {
|
|
192
|
+
const input = batch;
|
|
193
|
+
const data = compiledFilter
|
|
194
|
+
? filterArrowRows(input.data, batch => {
|
|
195
|
+
const matches = compiledFilter.evaluate(batch, { signal });
|
|
196
|
+
return index => matches.get(index) === true;
|
|
197
|
+
}, { signal })
|
|
198
|
+
: predicate
|
|
199
|
+
? filterArrowTable(input.data, predicate, { signal })
|
|
200
|
+
: input.data;
|
|
201
|
+
return { ...input, ...wrapBatch(data) };
|
|
202
|
+
},
|
|
203
|
+
project: batch => {
|
|
204
|
+
const input = batch;
|
|
205
|
+
return computedProjection ? input : { ...input, ...wrapBatch(project(input.data)) };
|
|
206
|
+
}
|
|
207
|
+
})) {
|
|
208
|
+
const input = value;
|
|
209
|
+
const batch = computedProjection ? { ...input, ...wrapBatch(project(input.data)) } : input;
|
|
210
|
+
if (!arrow.util.compareSchemas(comparisonSchema, convertSchemaToArrow(batch.schema)))
|
|
211
|
+
throw new Error('Query output schema does not match source metadata.');
|
|
212
|
+
emitted = true;
|
|
213
|
+
rowsReturned += batch.length;
|
|
214
|
+
yield batch;
|
|
215
|
+
}
|
|
216
|
+
// An empty schema-bearing batch makes collected and streaming empty results identical.
|
|
217
|
+
if (!emitted)
|
|
218
|
+
yield wrapBatch(empty);
|
|
219
|
+
if (normalized.limit !== undefined && rowsReturned >= normalized.limit)
|
|
220
|
+
earlyTerminationReason = 'limit';
|
|
221
|
+
status = earlyTerminationReason ? 'early-terminated' : 'completed';
|
|
222
|
+
}
|
|
223
|
+
catch (failure) {
|
|
224
|
+
error = failure;
|
|
225
|
+
status = options.signal?.aborted ? 'cancelled' : 'failed';
|
|
226
|
+
throw failure;
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
if (status === 'early-terminated' && !earlyTerminationReason)
|
|
230
|
+
earlyTerminationReason = 'consumer-return';
|
|
231
|
+
try {
|
|
232
|
+
await ownedSource?.close?.();
|
|
233
|
+
}
|
|
234
|
+
catch (failure) {
|
|
235
|
+
if (error === undefined) {
|
|
236
|
+
error = failure;
|
|
237
|
+
status = options.signal?.aborted ? 'cancelled' : 'failed';
|
|
238
|
+
earlyTerminationReason = undefined;
|
|
239
|
+
throw failure;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
emitQueryComplete(options.onQueryComplete, Object.freeze({
|
|
244
|
+
status,
|
|
245
|
+
sourcesPlanned: 1,
|
|
246
|
+
sourcesRead,
|
|
247
|
+
batchesRead,
|
|
248
|
+
rowsRead,
|
|
249
|
+
rowsReturned,
|
|
250
|
+
durationMilliseconds: Date.now() - startedAt,
|
|
251
|
+
...(earlyTerminationReason ? { earlyTerminationReason } : {}),
|
|
252
|
+
...(error === undefined ? {} : { error })
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** Emits original Arrow RecordBatches without copying their buffers. */
|
|
258
|
+
async function* memoryBatches(data) {
|
|
259
|
+
for (const batch of data.batches)
|
|
260
|
+
yield wrapBatch(new arrow.Table(data.schema, [batch]));
|
|
261
|
+
}
|
|
262
|
+
/** Converts supported native table batches to Arrow while preserving their declared schema. */
|
|
263
|
+
function normalizeBatch(value, fallbackSchema) {
|
|
264
|
+
if (!value || typeof value !== 'object' || !('shape' in value))
|
|
265
|
+
throw new Error('Query source returned an unsupported batch.');
|
|
266
|
+
const input = value;
|
|
267
|
+
const batch = { ...input, schema: input.schema ?? fallbackSchema };
|
|
268
|
+
if (!['arrow-table', 'object-row-table', 'array-row-table', 'columnar-table'].includes(batch.shape))
|
|
269
|
+
throw new Error(`Unsupported query batch shape: ${batch.shape}`);
|
|
270
|
+
const data = batch.length === 0 && batch.schema
|
|
271
|
+
? new arrow.Table(convertSchemaToArrow(batch.schema))
|
|
272
|
+
: convertTableToArrow(batch);
|
|
273
|
+
return { ...batch, ...wrapBatch(data) };
|
|
274
|
+
}
|
|
275
|
+
/** Wraps Arrow data in the standard batch envelope. */
|
|
276
|
+
function wrapBatch(data) {
|
|
277
|
+
return {
|
|
278
|
+
shape: 'arrow-table',
|
|
279
|
+
data,
|
|
280
|
+
schema: convertArrowToSchema(data.schema),
|
|
281
|
+
batchType: 'data',
|
|
282
|
+
length: data.numRows
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/** Opens only explicit URL source loaders; the public query owns the returned source. */
|
|
286
|
+
async function openQuerySource(options) {
|
|
287
|
+
const candidates = Array.isArray(options.loaders) ? options.loaders : [options.loaders];
|
|
288
|
+
if (!candidates.length || candidates.some(loader => !isSourceLoader(loader) || !loader.fromUrl))
|
|
289
|
+
throw new Error('Query source must specify explicit URL-capable source loaders for a URL.');
|
|
290
|
+
const { source, sources, loaders, sqlParser, onQueryComplete, ...sourceOptions } = options;
|
|
291
|
+
const url = source;
|
|
292
|
+
const selected = candidates.length === 1 ? candidates[0] : candidates.find(loader => loader.testURL(url));
|
|
293
|
+
if (!selected)
|
|
294
|
+
throw new Error('No explicit source loader matches the query URL.');
|
|
295
|
+
const implementation = selected.preload ? await selected.preload(url, sourceOptions) : selected;
|
|
296
|
+
options.signal?.throwIfAborted();
|
|
297
|
+
if (!isSourceLoader(implementation) || !implementation.fromUrl)
|
|
298
|
+
throw new Error('Query source preload did not return a URL-capable source loader.');
|
|
299
|
+
const authenticatedOptions = await resolveLoaderAuthenticationOptions(selected.getAuthentications ? selected : implementation, url, { ...sourceOptions, core: { ...sourceOptions.core, ignoreRegisteredLoaders: true } });
|
|
300
|
+
options.signal?.throwIfAborted();
|
|
301
|
+
return implementation.createDataSource(url, authenticatedOptions);
|
|
302
|
+
}
|
|
303
|
+
export { parseSQLQuery, parseSQLSelect } from '@math.gl/core/sql';
|
|
304
|
+
export { createSQLCatalog } from "./sql-catalog.js";
|
|
305
|
+
/** Checks predicate tree bounds and detects casts that require Arrow execution. */
|
|
306
|
+
function validatePredicateOperands(where) {
|
|
307
|
+
if (where && typeof where === 'object' && 'expression' in where) {
|
|
308
|
+
if (Object.keys(where).some(key => key !== 'expression'))
|
|
309
|
+
throw new Error('Unsupported computed WHERE field.');
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
let castPredicate = false;
|
|
313
|
+
const pending = where ? [{ value: where }] : [];
|
|
314
|
+
const visited = new WeakSet();
|
|
315
|
+
let nodes = 0;
|
|
316
|
+
while (pending.length) {
|
|
317
|
+
const frame = pending.pop();
|
|
318
|
+
const candidate = frame.value;
|
|
319
|
+
if (!candidate || typeof candidate !== 'object' || Array.isArray(candidate))
|
|
320
|
+
continue;
|
|
321
|
+
if (frame.exit) {
|
|
322
|
+
visited.delete(candidate);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
if (visited.has(candidate) || ++nodes > 4096)
|
|
326
|
+
throw new Error('Query predicate must be an acyclic tree of at most 4096 nodes.');
|
|
327
|
+
visited.add(candidate);
|
|
328
|
+
if (isUnsupportedQueryExpression(candidate))
|
|
329
|
+
throw new Error('CAST and computed WHERE operands are not supported by this query executor.');
|
|
330
|
+
const predicate = candidate;
|
|
331
|
+
if (!Array.isArray(predicate.args))
|
|
332
|
+
continue;
|
|
333
|
+
if (predicate.op === 'and' || predicate.op === 'or' || predicate.op === 'not') {
|
|
334
|
+
if (predicate.args.length > 4096 - nodes)
|
|
335
|
+
throw new Error('Query predicate exceeds 4096 nodes.');
|
|
336
|
+
pending.push({ value: candidate, exit: true });
|
|
337
|
+
pending.push(...predicate.args.map(value => ({ value })));
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
visited.delete(candidate);
|
|
341
|
+
for (const [index, operand] of predicate.args.entries()) {
|
|
342
|
+
if (index === 0 &&
|
|
343
|
+
operand &&
|
|
344
|
+
typeof operand === 'object' &&
|
|
345
|
+
typeof operand.property === 'string' &&
|
|
346
|
+
'casts' in operand) {
|
|
347
|
+
castPredicate = true;
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (isUnsupportedQueryExpression(operand) ||
|
|
351
|
+
(Array.isArray(operand) && operand.some(isUnsupportedQueryExpression)))
|
|
352
|
+
throw new Error('CAST and computed WHERE operands are not supported by this query executor.');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return castPredicate;
|
|
356
|
+
}
|
|
357
|
+
/** Identifies newer portable operands and raw expression ASTs without interpreting scalar values. */
|
|
358
|
+
function isUnsupportedQueryExpression(value) {
|
|
359
|
+
if (!value || typeof value !== 'object')
|
|
360
|
+
return false;
|
|
361
|
+
if ('casts' in value || 'expression' in value)
|
|
362
|
+
return true;
|
|
363
|
+
return ('type' in value &&
|
|
364
|
+
typeof value.type === 'string' &&
|
|
365
|
+
/Expression$|^(Identifier|Literal|Compound)$/.test(value.type));
|
|
366
|
+
}
|
|
367
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/scan/query.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EASjB,kCAAkC,EAClC,cAAc,EACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,6BAA0B;AACtE,OAAO,EAAC,eAAe,EAAC,gDAA6C;AACrE,OAAO,EAAC,wBAAwB,EAAC,kCAA+B;AAEhE,OAAO,EAAC,kBAAkB,EAAC,kCAA+B;AA2C1D,gFAAgF;AAChF,MAAM,CAAC,K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AC;QACN,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,qGAAqG;AACrG,SAAS,4BAA4B,CAAC,KAAc;IAClD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,OAAO,IAAI,KAAK,IAAI,YAAY,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IAC3D,OAAO,CACL,MAAM,IAAI,KAAK;QACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,6CAA6C,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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/resolve-query-source.ts
|
|
21
|
+
var resolve_query_source_exports = {};
|
|
22
|
+
__export(resolve_query_source_exports, {
|
|
23
|
+
createSourceRegistry: () => createSourceRegistry,
|
|
24
|
+
resolveQuerySource: () => resolveQuerySource
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(resolve_query_source_exports);
|
|
27
|
+
var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
28
|
+
async function resolveQuerySource(reference, sources, signal) {
|
|
29
|
+
(0, import_loader_utils.validateTableReference)(reference);
|
|
30
|
+
const registry = createSourceRegistry(sources);
|
|
31
|
+
const name = typeof reference === "string" ? reference : reference.source;
|
|
32
|
+
const source = registry.get(name);
|
|
33
|
+
if (!source) throw new Error(`Unknown data source: ${name}`);
|
|
34
|
+
signal?.throwIfAborted();
|
|
35
|
+
if (typeof reference === "string") return source;
|
|
36
|
+
const collection = source;
|
|
37
|
+
if (typeof collection.getTable !== "function")
|
|
38
|
+
throw new Error(`Data source ${name} does not expose named tables.`);
|
|
39
|
+
const table = await collection.getTable(reference.table, { signal });
|
|
40
|
+
signal?.throwIfAborted();
|
|
41
|
+
return table;
|
|
42
|
+
}
|
|
43
|
+
function createSourceRegistry(sources) {
|
|
44
|
+
if (!Array.isArray(sources)) throw new Error("Query requires a sources array.");
|
|
45
|
+
const registry = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const source of sources) {
|
|
47
|
+
if (!source || typeof source.name !== "string" || !source.name.trim())
|
|
48
|
+
throw new Error("Registered data sources require non-empty names.");
|
|
49
|
+
if (registry.has(source.name)) throw new Error(`Duplicate data source name: ${source.name}`);
|
|
50
|
+
registry.set(source.name, source);
|
|
51
|
+
}
|
|
52
|
+
return registry;
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
createSourceRegistry,
|
|
57
|
+
resolveQuerySource
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=resolve-query-source.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/scan/resolve-query-source.ts"],
|
|
4
|
+
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {validateTableReference} from '@loaders.gl/core/loader-utils';\nimport type {\n DataSource,\n DataSourceOptions,\n TableReference,\n TableSourceCollection\n} from '@loaders.gl/core/loader-utils';\n\n/** Resolves one literal source/table reference without inspecting unrelated source data. */\nexport async function resolveQuerySource(\n reference: TableReference,\n sources: readonly DataSource<unknown, DataSourceOptions>[] | undefined,\n signal?: AbortSignal\n): Promise<unknown> {\n validateTableReference(reference);\n const registry = createSourceRegistry(sources);\n const name = typeof reference === 'string' ? reference : reference.source;\n const source = registry.get(name);\n if (!source) throw new Error(`Unknown data source: ${name}`);\n signal?.throwIfAborted();\n if (typeof reference === 'string') return source;\n const collection = source as unknown as Partial<TableSourceCollection>;\n if (typeof collection.getTable !== 'function')\n throw new Error(`Data source ${name} does not expose named tables.`);\n const table = await collection.getTable(reference.table, {signal});\n signal?.throwIfAborted();\n return table;\n}\n\n/** Snapshots source identities consistently for FROM and metadata queries. */\nexport function createSourceRegistry(\n sources: readonly DataSource<unknown, DataSourceOptions>[] | undefined\n): ReadonlyMap<string, DataSource<unknown, DataSourceOptions>> {\n if (!Array.isArray(sources)) throw new Error('Query requires a sources array.');\n const registry = new Map<string, DataSource<unknown, DataSourceOptions>>();\n for (const source of sources) {\n if (!source || typeof source.name !== 'string' || !source.name.trim())\n throw new Error('Registered data sources require non-empty names.');\n if (registry.has(source.name)) throw new Error(`Duplicate data source name: ${source.name}`);\n registry.set(source.name, source);\n }\n return registry;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAqC;AASrC,eAAsB,mBACpB,WACA,SACA,QACkB;AAClB,kDAAuB,SAAS;AAChC,QAAM,WAAW,qBAAqB,OAAO;AAC7C,QAAM,OAAO,OAAO,cAAc,WAAW,YAAY,UAAU;AACnE,QAAM,SAAS,SAAS,IAAI,IAAI;AAChC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,wBAAwB,IAAI,EAAE;AAC3D,UAAQ,eAAe;AACvB,MAAI,OAAO,cAAc,SAAU,QAAO;AAC1C,QAAM,aAAa;AACnB,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,IAAI,MAAM,eAAe,IAAI,gCAAgC;AACrE,QAAM,QAAQ,MAAM,WAAW,SAAS,UAAU,OAAO,EAAC,OAAM,CAAC;AACjE,UAAQ,eAAe;AACvB,SAAO;AACT;AAGO,SAAS,qBACd,SAC6D;AAC7D,MAAI,CAAC,MAAM,QAAQ,OAAO,EAAG,OAAM,IAAI,MAAM,iCAAiC;AAC9E,QAAM,WAAW,oBAAI,IAAoD;AACzE,aAAW,UAAU,SAAS;AAC5B,QAAI,CAAC,UAAU,OAAO,OAAO,SAAS,YAAY,CAAC,OAAO,KAAK,KAAK;AAClE,YAAM,IAAI,MAAM,kDAAkD;AACpE,QAAI,SAAS,IAAI,OAAO,IAAI,EAAG,OAAM,IAAI,MAAM,+BAA+B,OAAO,IAAI,EAAE;AAC3F,aAAS,IAAI,OAAO,MAAM,MAAM;AAAA,EAClC;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DataSource, DataSourceOptions, TableReference } from '@loaders.gl/core/loader-utils';
|
|
2
|
+
/** Resolves one literal source/table reference without inspecting unrelated source data. */
|
|
3
|
+
export declare function resolveQuerySource(reference: TableReference, sources: readonly DataSource<unknown, DataSourceOptions>[] | undefined, signal?: AbortSignal): Promise<unknown>;
|
|
4
|
+
/** Snapshots source identities consistently for FROM and metadata queries. */
|
|
5
|
+
export declare function createSourceRegistry(sources: readonly DataSource<unknown, DataSourceOptions>[] | undefined): ReadonlyMap<string, DataSource<unknown, DataSourceOptions>>;
|
|
6
|
+
//# sourceMappingURL=resolve-query-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-query-source.d.ts","sourceRoot":"","sources":["../../src/scan/resolve-query-source.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EAEf,MAAM,+BAA+B,CAAC;AAEvC,4FAA4F;AAC5F,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,SAAS,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,EAAE,GAAG,SAAS,EACtE,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,OAAO,CAAC,CAclB;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,EAAE,GAAG,SAAS,GACrE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAU7D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { validateTableReference } from '@loaders.gl/core/loader-utils';
|
|
5
|
+
/** Resolves one literal source/table reference without inspecting unrelated source data. */
|
|
6
|
+
export async function resolveQuerySource(reference, sources, signal) {
|
|
7
|
+
validateTableReference(reference);
|
|
8
|
+
const registry = createSourceRegistry(sources);
|
|
9
|
+
const name = typeof reference === 'string' ? reference : reference.source;
|
|
10
|
+
const source = registry.get(name);
|
|
11
|
+
if (!source)
|
|
12
|
+
throw new Error(`Unknown data source: ${name}`);
|
|
13
|
+
signal?.throwIfAborted();
|
|
14
|
+
if (typeof reference === 'string')
|
|
15
|
+
return source;
|
|
16
|
+
const collection = source;
|
|
17
|
+
if (typeof collection.getTable !== 'function')
|
|
18
|
+
throw new Error(`Data source ${name} does not expose named tables.`);
|
|
19
|
+
const table = await collection.getTable(reference.table, { signal });
|
|
20
|
+
signal?.throwIfAborted();
|
|
21
|
+
return table;
|
|
22
|
+
}
|
|
23
|
+
/** Snapshots source identities consistently for FROM and metadata queries. */
|
|
24
|
+
export function createSourceRegistry(sources) {
|
|
25
|
+
if (!Array.isArray(sources))
|
|
26
|
+
throw new Error('Query requires a sources array.');
|
|
27
|
+
const registry = new Map();
|
|
28
|
+
for (const source of sources) {
|
|
29
|
+
if (!source || typeof source.name !== 'string' || !source.name.trim())
|
|
30
|
+
throw new Error('Registered data sources require non-empty names.');
|
|
31
|
+
if (registry.has(source.name))
|
|
32
|
+
throw new Error(`Duplicate data source name: ${source.name}`);
|
|
33
|
+
registry.set(source.name, source);
|
|
34
|
+
}
|
|
35
|
+
return registry;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=resolve-query-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-query-source.js","sourceRoot":"","sources":["../../src/scan/resolve-query-source.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,sBAAsB,EAAC,MAAM,+BAA+B,CAAC;AAQrE,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,SAAyB,EACzB,OAAsE,EACtE,MAAoB;IAEpB,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;IAC1E,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,OAAO,SAAS,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACjD,MAAM,UAAU,GAAG,MAAmD,CAAC;IACvE,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,UAAU;QAC3C,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,gCAAgC,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,EAAC,MAAM,EAAC,CAAC,CAAC;IACnE,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,oBAAoB,CAClC,OAAsE;IAEtE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAChF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkD,CAAC;IAC3E,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;YACnE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7F,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
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/sql-catalog.ts
|
|
21
|
+
var sql_catalog_exports = {};
|
|
22
|
+
__export(sql_catalog_exports, {
|
|
23
|
+
createSQLCatalog: () => createSQLCatalog
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(sql_catalog_exports);
|
|
26
|
+
var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
27
|
+
var import_resolve_query_source = require("./resolve-query-source.cjs");
|
|
28
|
+
function createSQLCatalog(sources) {
|
|
29
|
+
const registry = (0, import_resolve_query_source.createSourceRegistry)(sources);
|
|
30
|
+
const names = Object.freeze([...registry.keys()].map((name) => Object.freeze({ name })));
|
|
31
|
+
function getSource(name) {
|
|
32
|
+
const source = registry.get(name);
|
|
33
|
+
if (!source) throw new Error(`Unknown data source: ${name}`);
|
|
34
|
+
return source;
|
|
35
|
+
}
|
|
36
|
+
async function getTables(sourceName, options = {}) {
|
|
37
|
+
options.signal?.throwIfAborted();
|
|
38
|
+
const selected = sourceName === void 0 ? [...registry.values()] : [getSource(sourceName)];
|
|
39
|
+
const result = [];
|
|
40
|
+
for (const source of selected) {
|
|
41
|
+
options.signal?.throwIfAborted();
|
|
42
|
+
const discovery = source;
|
|
43
|
+
if (typeof discovery.getTablesMetadata === "function") {
|
|
44
|
+
const tables = await discovery.getTablesMetadata(options);
|
|
45
|
+
options.signal?.throwIfAborted();
|
|
46
|
+
const tableNames = /* @__PURE__ */ new Set();
|
|
47
|
+
if (!Array.isArray(tables)) throw new Error("Table discovery must return an array.");
|
|
48
|
+
for (const table of tables) {
|
|
49
|
+
if (!table || typeof table.name !== "string" || !table.name.trim() || tableNames.has(table.name))
|
|
50
|
+
throw new Error("Table metadata requires unique non-empty names.");
|
|
51
|
+
if (table.queryable !== void 0 && typeof table.queryable !== "boolean")
|
|
52
|
+
throw new Error("Table metadata queryable must be a boolean.");
|
|
53
|
+
tableNames.add(table.name);
|
|
54
|
+
result.push({
|
|
55
|
+
...table,
|
|
56
|
+
sourceName: source.name,
|
|
57
|
+
reference: { source: source.name, table: table.name },
|
|
58
|
+
queryable: table.queryable ?? typeof discovery.getTable === "function"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
} else if (typeof discovery.getQueryMetadata === "function") {
|
|
62
|
+
const metadata = await discovery.getQueryMetadata(options);
|
|
63
|
+
options.signal?.throwIfAborted();
|
|
64
|
+
if (metadata.queryType === "table")
|
|
65
|
+
result.push({
|
|
66
|
+
name: source.name,
|
|
67
|
+
sourceName: source.name,
|
|
68
|
+
reference: source.name,
|
|
69
|
+
schema: metadata.schema,
|
|
70
|
+
queryable: typeof discovery.read === "function" && metadata.execution.status === "supported" && metadata.execution.method === "read"
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
async function getSchema(reference, options = {}) {
|
|
77
|
+
(0, import_loader_utils.validateTableReference)(reference);
|
|
78
|
+
if (reference === void 0) throw new Error("A table reference is required.");
|
|
79
|
+
options.signal?.throwIfAborted();
|
|
80
|
+
const sourceName = typeof reference === "string" ? reference : reference.source;
|
|
81
|
+
const source = getSource(sourceName);
|
|
82
|
+
const discovery = source;
|
|
83
|
+
let schema;
|
|
84
|
+
if (typeof reference === "string") {
|
|
85
|
+
if (typeof discovery.getTablesMetadata === "function")
|
|
86
|
+
throw new Error(
|
|
87
|
+
`DESCRIBE requires a qualified table reference for collection ${sourceName}.`
|
|
88
|
+
);
|
|
89
|
+
if (typeof discovery.getQueryMetadata === "function") {
|
|
90
|
+
const metadata = await discovery.getQueryMetadata(options);
|
|
91
|
+
if (metadata.queryType === "table") schema = metadata.schema;
|
|
92
|
+
}
|
|
93
|
+
} else if (typeof discovery.getTableMetadata === "function") {
|
|
94
|
+
schema = (await discovery.getTableMetadata(reference.table, options)).schema;
|
|
95
|
+
} else {
|
|
96
|
+
schema = (await getTables(sourceName, options)).find(
|
|
97
|
+
(table) => typeof table.reference === "object" && table.name === reference.table
|
|
98
|
+
)?.schema;
|
|
99
|
+
}
|
|
100
|
+
options.signal?.throwIfAborted();
|
|
101
|
+
if (!schema) throw new Error(`No discoverable table schema: ${sourceName}`);
|
|
102
|
+
return schema;
|
|
103
|
+
}
|
|
104
|
+
return Object.freeze({ getSources: () => names, getTables, getSchema });
|
|
105
|
+
}
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
createSQLCatalog
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=sql-catalog.cjs.map
|