@luma.gl/graph 10.0.0-alpha.8 → 10.0.0-alpha.9
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/gpu-sql/{lu-sql.cjs → gpu-sql.cjs} +68 -68
- package/dist/gpu-sql/{lu-sql.d.ts → gpu-sql.d.ts} +14 -14
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -0
- package/dist/gpu-sql/{lu-sql.js → gpu-sql.js} +68 -68
- package/dist/gpu-sql/gpu-sql.js.map +1 -0
- package/dist/gpu-sql/index.cjs +5 -5
- package/dist/gpu-sql/index.cjs.map +2 -2
- package/dist/gpu-sql/index.d.ts +2 -2
- package/dist/gpu-sql/index.d.ts.map +1 -1
- package/dist/gpu-sql/index.js +1 -1
- package/dist/gpu-sql/index.js.map +1 -1
- package/package.json +4 -4
- package/src/gpu-project/README.md +4 -4
- package/src/gpu-sql/{lu-sql.ts → gpu-sql.ts} +134 -125
- package/src/gpu-sql/index.ts +2 -2
- package/dist/gpu-sql/lu-sql.d.ts.map +0 -1
- package/dist/gpu-sql/lu-sql.js.map +0 -1
|
@@ -15,29 +15,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var gpu_sql_exports = {};
|
|
19
|
+
__export(gpu_sql_exports, {
|
|
20
|
+
GPUSQLContext: () => GPUSQLContext,
|
|
21
|
+
GPUSQLQuery: () => GPUSQLQuery
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(gpu_sql_exports);
|
|
24
24
|
var import_gpu_data_frame = require("../gpu-dataframe/gpu-data-frame.cjs");
|
|
25
25
|
var import_gpu_data_frame_query = require("../gpu-dataframe/gpu-data-frame-query.cjs");
|
|
26
26
|
var import_gpu_expression = require("../gpu-dataframe/gpu-expression.cjs");
|
|
27
27
|
const MAXIMUM_SQL_LENGTH = 65536;
|
|
28
28
|
const MAXIMUM_SQL_TOKENS = 4096;
|
|
29
29
|
const MAXIMUM_EXPRESSION_DEPTH = 64;
|
|
30
|
-
class
|
|
30
|
+
class GPUSQLContext {
|
|
31
31
|
tables;
|
|
32
32
|
constructor(tables) {
|
|
33
33
|
const registered = {};
|
|
34
34
|
for (const [name, table] of Object.entries(tables)) {
|
|
35
35
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name) || !(table instanceof import_gpu_data_frame.GPUDataFrame)) {
|
|
36
|
-
throw new Error("
|
|
36
|
+
throw new Error("GPUSQL requires valid names mapped to existing GPU dataframes");
|
|
37
37
|
}
|
|
38
38
|
const canonical = name.toLowerCase();
|
|
39
39
|
if (registered[canonical])
|
|
40
|
-
throw new Error(`
|
|
40
|
+
throw new Error(`GPUSQL table "${name}" is already registered`);
|
|
41
41
|
registered[canonical] = table;
|
|
42
42
|
}
|
|
43
43
|
this.tables = Object.freeze(registered);
|
|
@@ -45,12 +45,12 @@ class LuSQLContext {
|
|
|
45
45
|
}
|
|
46
46
|
/** Parses and validates one immutable SELECT plan without touching registered GPU sources. */
|
|
47
47
|
query(source, options = {}) {
|
|
48
|
-
const parser = new
|
|
48
|
+
const parser = new GPUSQLParser(source, options.parameters ?? {});
|
|
49
49
|
const statement = parser.parse();
|
|
50
|
-
return new
|
|
50
|
+
return new GPUSQLQuery(source, buildGPUSQLPlan(this.tables, statement));
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class GPUSQLQuery {
|
|
54
54
|
/** Original application-owned SQL text, retained solely for diagnostics and inspection. */
|
|
55
55
|
sql;
|
|
56
56
|
plan;
|
|
@@ -65,60 +65,60 @@ class LuSQLQuery {
|
|
|
65
65
|
return this.plan.compile(graph);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function buildGPUSQLPlan(tables, statement) {
|
|
69
69
|
const frame = tables[statement.table.toLowerCase()];
|
|
70
70
|
if (!frame)
|
|
71
|
-
throw new Error(`
|
|
71
|
+
throw new Error(`GPUSQL table "${statement.table}" is not registered`);
|
|
72
72
|
let query = new import_gpu_data_frame_query.GPUDataFrameQuery(frame, [], frame.columnNames);
|
|
73
73
|
const qualifier = statement.alias ?? statement.table;
|
|
74
|
-
const resolve = (name) =>
|
|
74
|
+
const resolve = (name) => resolveGPUSQLColumn(name, qualifier, frame.columnNames);
|
|
75
75
|
if (statement.predicate) {
|
|
76
|
-
query = query.filter(new import_gpu_expression.GPUExpression(
|
|
76
|
+
query = query.filter(new import_gpu_expression.GPUExpression(resolveGPUSQLExpression(statement.predicate, resolve)));
|
|
77
77
|
}
|
|
78
78
|
const aggregates = statement.items.filter((item) => item.aggregate);
|
|
79
79
|
if (aggregates.length > 0) {
|
|
80
80
|
if (statement.join || statement.orderBy || statement.limit !== void 0) {
|
|
81
|
-
throw new Error("
|
|
81
|
+
throw new Error("GPUSQL aggregate queries do not yet support joins, ordering, or limits");
|
|
82
82
|
}
|
|
83
83
|
const definitions = {};
|
|
84
84
|
for (const item of aggregates) {
|
|
85
85
|
const name = item.alias ?? `${item.aggregate}_${item.aggregateColumn ?? "all"}`;
|
|
86
86
|
if (definitions[name])
|
|
87
|
-
throw new Error(`
|
|
87
|
+
throw new Error(`GPUSQL aggregate alias "${name}" is duplicated`);
|
|
88
88
|
definitions[name] = item.aggregate === "count" ? "count" : { [item.aggregate]: resolve(item.aggregateColumn) };
|
|
89
89
|
}
|
|
90
90
|
if (statement.groupBy) {
|
|
91
91
|
const key = resolve(statement.groupBy);
|
|
92
92
|
const nonAggregates = statement.items.filter((item) => !item.aggregate);
|
|
93
|
-
if (nonAggregates.length !== 1 ||
|
|
94
|
-
throw new Error("
|
|
93
|
+
if (nonAggregates.length !== 1 || resolveGPUSQLProjectionName(nonAggregates[0], resolve) !== key) {
|
|
94
|
+
throw new Error("GPUSQL grouped queries must select their single GROUP BY key");
|
|
95
95
|
}
|
|
96
96
|
return query.groupBy(key).aggregate(definitions);
|
|
97
97
|
}
|
|
98
98
|
if (aggregates.length !== statement.items.length) {
|
|
99
|
-
throw new Error("
|
|
99
|
+
throw new Error("GPUSQL global aggregates cannot mix ordinary source columns");
|
|
100
100
|
}
|
|
101
101
|
return query.aggregate(definitions);
|
|
102
102
|
}
|
|
103
103
|
if (statement.groupBy)
|
|
104
|
-
throw new Error("
|
|
104
|
+
throw new Error("GPUSQL GROUP BY requires at least one aggregation");
|
|
105
105
|
const selected = [];
|
|
106
106
|
for (const item of statement.items) {
|
|
107
107
|
if (item.star) {
|
|
108
108
|
if (statement.items.length !== 1)
|
|
109
|
-
throw new Error("
|
|
109
|
+
throw new Error("GPUSQL SELECT * cannot include other columns");
|
|
110
110
|
selected.push(...frame.columnNames);
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
|
-
const node =
|
|
113
|
+
const node = resolveGPUSQLExpression(item.expression, resolve);
|
|
114
114
|
const name = item.alias ?? (node.kind === "column" ? node.name : void 0);
|
|
115
115
|
if (!name)
|
|
116
|
-
throw new Error("
|
|
116
|
+
throw new Error("GPUSQL computed SELECT expressions require an explicit AS alias");
|
|
117
117
|
if (selected.includes(name))
|
|
118
|
-
throw new Error(`
|
|
118
|
+
throw new Error(`GPUSQL output column "${name}" is duplicated`);
|
|
119
119
|
if (node.kind !== "column" || node.name !== name) {
|
|
120
120
|
if (frame.columnNames.includes(name)) {
|
|
121
|
-
throw new Error(`
|
|
121
|
+
throw new Error(`GPUSQL derived alias "${name}" conflicts with an existing source column`);
|
|
122
122
|
}
|
|
123
123
|
query = query.withColumn(name, new import_gpu_expression.GPUExpression(node));
|
|
124
124
|
}
|
|
@@ -126,16 +126,16 @@ function buildLuSQLPlan(tables, statement) {
|
|
|
126
126
|
}
|
|
127
127
|
if (statement.join) {
|
|
128
128
|
if (statement.orderBy || statement.limit !== void 0) {
|
|
129
|
-
throw new Error("
|
|
129
|
+
throw new Error("GPUSQL joined results do not yet support ORDER BY or LIMIT");
|
|
130
130
|
}
|
|
131
131
|
const right = tables[statement.join.table.toLowerCase()];
|
|
132
132
|
if (!right)
|
|
133
|
-
throw new Error(`
|
|
133
|
+
throw new Error(`GPUSQL table "${statement.join.table}" is not registered`);
|
|
134
134
|
const leftKey = resolve(statement.join.left);
|
|
135
135
|
const rightQualifier = statement.join.alias ?? statement.join.table;
|
|
136
|
-
const rightKey =
|
|
136
|
+
const rightKey = resolveGPUSQLColumn(statement.join.right, rightQualifier, right.columnNames);
|
|
137
137
|
if (!selected.includes(leftKey)) {
|
|
138
|
-
throw new Error("
|
|
138
|
+
throw new Error("GPUSQL joins require the left join key to remain selected");
|
|
139
139
|
}
|
|
140
140
|
query = query.select(selected);
|
|
141
141
|
const options = { leftOn: leftKey, rightOn: rightKey };
|
|
@@ -153,7 +153,7 @@ function buildLuSQLPlan(tables, statement) {
|
|
|
153
153
|
if (statement.orderBy) {
|
|
154
154
|
const orderColumn = selected.find((name) => name.toLowerCase() === statement.orderBy.column.toLowerCase()) ?? resolve(statement.orderBy.column);
|
|
155
155
|
if (!selected.includes(orderColumn)) {
|
|
156
|
-
throw new Error("
|
|
156
|
+
throw new Error("GPUSQL ORDER BY requires the sort column in the SELECT projection");
|
|
157
157
|
}
|
|
158
158
|
const sort = query.select(selected).sortByGlobal(orderColumn, {
|
|
159
159
|
direction: statement.orderBy.direction,
|
|
@@ -162,55 +162,55 @@ function buildLuSQLPlan(tables, statement) {
|
|
|
162
162
|
return statement.limit === void 0 ? sort : sort.topK(statement.limit);
|
|
163
163
|
}
|
|
164
164
|
if (statement.limit !== void 0)
|
|
165
|
-
throw new Error("
|
|
165
|
+
throw new Error("GPUSQL LIMIT currently requires ORDER BY");
|
|
166
166
|
if (query.predicates.length === 0) {
|
|
167
167
|
const firstColumn = frame.columnNames[0];
|
|
168
168
|
if (!firstColumn)
|
|
169
|
-
throw new Error("
|
|
169
|
+
throw new Error("GPUSQL SELECT requires at least one GPU source column");
|
|
170
170
|
query = query.filter((0, import_gpu_expression.column)(firstColumn).isValid().or((0, import_gpu_expression.column)(firstColumn).isNull()));
|
|
171
171
|
}
|
|
172
172
|
return query.select(selected);
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function resolveGPUSQLProjectionName(item, resolve) {
|
|
175
175
|
var _a;
|
|
176
176
|
if (((_a = item.expression) == null ? void 0 : _a.kind) !== "column") {
|
|
177
|
-
throw new Error("
|
|
177
|
+
throw new Error("GPUSQL grouped source expressions must reference the group key directly");
|
|
178
178
|
}
|
|
179
179
|
return resolve(item.expression.name);
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function resolveGPUSQLColumn(name, qualifier, columns) {
|
|
182
182
|
const parts = name.split(".");
|
|
183
183
|
if (parts.length > 2 || parts.length === 2 && parts[0].toLowerCase() !== qualifier.toLowerCase()) {
|
|
184
|
-
throw new Error(`
|
|
184
|
+
throw new Error(`GPUSQL column "${name}" has an unknown table qualifier`);
|
|
185
185
|
}
|
|
186
186
|
const requested = parts[parts.length - 1];
|
|
187
187
|
const matches = columns.filter((candidate) => candidate.toLowerCase() === requested.toLowerCase());
|
|
188
188
|
if (matches.length !== 1)
|
|
189
|
-
throw new Error(`
|
|
189
|
+
throw new Error(`GPUSQL column "${name}" does not exist`);
|
|
190
190
|
return matches[0];
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function resolveGPUSQLExpression(expression, resolve) {
|
|
193
193
|
switch (expression.kind) {
|
|
194
194
|
case "column":
|
|
195
195
|
return { kind: "column", name: resolve(expression.name) };
|
|
196
196
|
case "unary":
|
|
197
|
-
return { ...expression, operand:
|
|
197
|
+
return { ...expression, operand: resolveGPUSQLExpression(expression.operand, resolve) };
|
|
198
198
|
case "binary":
|
|
199
199
|
return {
|
|
200
200
|
...expression,
|
|
201
|
-
left:
|
|
202
|
-
right:
|
|
201
|
+
left: resolveGPUSQLExpression(expression.left, resolve),
|
|
202
|
+
right: resolveGPUSQLExpression(expression.right, resolve)
|
|
203
203
|
};
|
|
204
204
|
default:
|
|
205
205
|
return expression;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
class
|
|
208
|
+
class GPUSQLParser {
|
|
209
209
|
tokens;
|
|
210
210
|
parameters;
|
|
211
211
|
position = 0;
|
|
212
212
|
constructor(source, parameters) {
|
|
213
|
-
this.tokens =
|
|
213
|
+
this.tokens = tokenizeGPUSQL(source);
|
|
214
214
|
this.parameters = parameters;
|
|
215
215
|
}
|
|
216
216
|
parse() {
|
|
@@ -229,7 +229,7 @@ class LuSQLParser {
|
|
|
229
229
|
this.expectKeyword("BY");
|
|
230
230
|
groupBy = this.parseIdentifier();
|
|
231
231
|
if (this.takeSymbol(","))
|
|
232
|
-
throw new Error("
|
|
232
|
+
throw new Error("GPUSQL currently supports one GROUP BY column");
|
|
233
233
|
}
|
|
234
234
|
let orderBy;
|
|
235
235
|
if (this.takeKeyword("ORDER")) {
|
|
@@ -242,22 +242,22 @@ class LuSQLParser {
|
|
|
242
242
|
}
|
|
243
243
|
orderBy = { column: sortColumn, direction, ...nulls ? { nulls } : {} };
|
|
244
244
|
if (this.takeSymbol(","))
|
|
245
|
-
throw new Error("
|
|
245
|
+
throw new Error("GPUSQL currently supports one ORDER BY column");
|
|
246
246
|
}
|
|
247
247
|
let limit;
|
|
248
248
|
if (this.takeKeyword("LIMIT")) {
|
|
249
249
|
const token = this.take();
|
|
250
250
|
if ((token == null ? void 0 : token.kind) !== "number" || !/^\d+$/.test(token.value)) {
|
|
251
|
-
throw new Error("
|
|
251
|
+
throw new Error("GPUSQL LIMIT requires a nonnegative integer");
|
|
252
252
|
}
|
|
253
253
|
limit = Number(token.value);
|
|
254
254
|
if (!Number.isSafeInteger(limit) || limit > 4294967295) {
|
|
255
|
-
throw new Error("
|
|
255
|
+
throw new Error("GPUSQL LIMIT must fit an unsigned 32-bit row count");
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
this.takeSymbol(";");
|
|
259
259
|
if (this.peek())
|
|
260
|
-
throw new Error(`
|
|
260
|
+
throw new Error(`GPUSQL does not support unexpected token "${this.peek().value}"`);
|
|
261
261
|
return {
|
|
262
262
|
items,
|
|
263
263
|
table,
|
|
@@ -281,10 +281,10 @@ class LuSQLParser {
|
|
|
281
281
|
const aggregateColumn = this.takeSymbol("*") ? void 0 : this.parseIdentifier();
|
|
282
282
|
this.expectSymbol(")");
|
|
283
283
|
if (!aggregateColumn && aggregate !== "count") {
|
|
284
|
-
throw new Error("
|
|
284
|
+
throw new Error("GPUSQL only permits COUNT(*) as a wildcard aggregation");
|
|
285
285
|
}
|
|
286
286
|
if (aggregateColumn && aggregate === "count") {
|
|
287
|
-
throw new Error("
|
|
287
|
+
throw new Error("GPUSQL currently supports COUNT(*) but not nullable COUNT(column)");
|
|
288
288
|
}
|
|
289
289
|
return {
|
|
290
290
|
aggregate: aggregate === "avg" ? "mean" : aggregate,
|
|
@@ -312,7 +312,7 @@ class LuSQLParser {
|
|
|
312
312
|
}
|
|
313
313
|
if (!this.takeKeyword("JOIN")) {
|
|
314
314
|
if (type !== "inner")
|
|
315
|
-
throw new Error("
|
|
315
|
+
throw new Error("GPUSQL join modifier must be followed by JOIN");
|
|
316
316
|
return void 0;
|
|
317
317
|
}
|
|
318
318
|
const table = this.parseIdentifier();
|
|
@@ -325,7 +325,7 @@ class LuSQLParser {
|
|
|
325
325
|
}
|
|
326
326
|
parseExpression(depth, minimumPrecedence = 0) {
|
|
327
327
|
if (depth > MAXIMUM_EXPRESSION_DEPTH)
|
|
328
|
-
throw new Error("
|
|
328
|
+
throw new Error("GPUSQL expression nesting exceeds its safe limit");
|
|
329
329
|
let expression = this.parseUnary(depth + 1);
|
|
330
330
|
while (true) {
|
|
331
331
|
if (minimumPrecedence <= 3 && this.takeKeyword("IS")) {
|
|
@@ -339,7 +339,7 @@ class LuSQLParser {
|
|
|
339
339
|
continue;
|
|
340
340
|
}
|
|
341
341
|
const token = this.peek();
|
|
342
|
-
const operation = token ?
|
|
342
|
+
const operation = token ? getGPUSQLBinaryOperator(token.value) : void 0;
|
|
343
343
|
if (!operation || operation.precedence < minimumPrecedence)
|
|
344
344
|
break;
|
|
345
345
|
this.take();
|
|
@@ -366,16 +366,16 @@ class LuSQLParser {
|
|
|
366
366
|
}
|
|
367
367
|
const token = this.take();
|
|
368
368
|
if (!token)
|
|
369
|
-
throw new Error("
|
|
369
|
+
throw new Error("GPUSQL expected an expression");
|
|
370
370
|
if (token.kind === "number") {
|
|
371
371
|
const value = Number(token.value);
|
|
372
372
|
if (!Number.isFinite(value))
|
|
373
|
-
throw new Error("
|
|
373
|
+
throw new Error("GPUSQL numeric literals must be finite");
|
|
374
374
|
return (0, import_gpu_expression.literal)(value).node;
|
|
375
375
|
}
|
|
376
376
|
if (token.kind === "parameter") {
|
|
377
377
|
if (!Object.hasOwn(this.parameters, token.value)) {
|
|
378
|
-
throw new Error(`
|
|
378
|
+
throw new Error(`GPUSQL parameter ":${token.value}" requires an explicit default`);
|
|
379
379
|
}
|
|
380
380
|
return (0, import_gpu_expression.parameter)(token.value, this.parameters[token.value]).node;
|
|
381
381
|
}
|
|
@@ -388,7 +388,7 @@ class LuSQLParser {
|
|
|
388
388
|
return (0, import_gpu_expression.literal)(false).node;
|
|
389
389
|
return (0, import_gpu_expression.column)(token.value).node;
|
|
390
390
|
}
|
|
391
|
-
throw new Error(`
|
|
391
|
+
throw new Error(`GPUSQL does not support expression token "${token.value}"`);
|
|
392
392
|
}
|
|
393
393
|
parseOptionalTableAlias() {
|
|
394
394
|
if (this.takeKeyword("AS"))
|
|
@@ -399,12 +399,12 @@ class LuSQLParser {
|
|
|
399
399
|
parseIdentifier() {
|
|
400
400
|
const token = this.take();
|
|
401
401
|
if ((token == null ? void 0 : token.kind) !== "identifier")
|
|
402
|
-
throw new Error("
|
|
402
|
+
throw new Error("GPUSQL expected a table or column identifier");
|
|
403
403
|
return token.value;
|
|
404
404
|
}
|
|
405
405
|
expectKeyword(keyword) {
|
|
406
406
|
if (!this.takeKeyword(keyword))
|
|
407
|
-
throw new Error(`
|
|
407
|
+
throw new Error(`GPUSQL expected ${keyword}`);
|
|
408
408
|
return true;
|
|
409
409
|
}
|
|
410
410
|
takeKeyword(keyword) {
|
|
@@ -416,7 +416,7 @@ class LuSQLParser {
|
|
|
416
416
|
}
|
|
417
417
|
expectSymbol(symbol) {
|
|
418
418
|
if (!this.takeSymbol(symbol))
|
|
419
|
-
throw new Error(`
|
|
419
|
+
throw new Error(`GPUSQL expected "${symbol}"`);
|
|
420
420
|
}
|
|
421
421
|
takeSymbol(symbol) {
|
|
422
422
|
const token = this.peek();
|
|
@@ -435,9 +435,9 @@ class LuSQLParser {
|
|
|
435
435
|
return this.tokens[this.position];
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function tokenizeGPUSQL(source) {
|
|
439
439
|
if (typeof source !== "string" || source.length === 0 || source.length > MAXIMUM_SQL_LENGTH) {
|
|
440
|
-
throw new Error("
|
|
440
|
+
throw new Error("GPUSQL requires a nonempty, safely bounded SELECT statement");
|
|
441
441
|
}
|
|
442
442
|
const expression = /\s+|(?:--[^\n\r]*)|(?::([A-Za-z_][A-Za-z0-9_]*))|([A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)?)|(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(<=|>=|<>|!=|[(),;*+\-/=<>])/gy;
|
|
443
443
|
const tokens = [];
|
|
@@ -446,7 +446,7 @@ function tokenizeLuSQL(source) {
|
|
|
446
446
|
expression.lastIndex = cursor;
|
|
447
447
|
const match = expression.exec(source);
|
|
448
448
|
if (!match)
|
|
449
|
-
throw new Error(`
|
|
449
|
+
throw new Error(`GPUSQL contains an unsupported token at character ${cursor}`);
|
|
450
450
|
cursor = expression.lastIndex;
|
|
451
451
|
if (match[1])
|
|
452
452
|
tokens.push({ kind: "parameter", value: match[1] });
|
|
@@ -457,11 +457,11 @@ function tokenizeLuSQL(source) {
|
|
|
457
457
|
else if (match[4])
|
|
458
458
|
tokens.push({ kind: "symbol", value: match[4] });
|
|
459
459
|
if (tokens.length > MAXIMUM_SQL_TOKENS)
|
|
460
|
-
throw new Error("
|
|
460
|
+
throw new Error("GPUSQL statement exceeds its safe token limit");
|
|
461
461
|
}
|
|
462
462
|
return tokens;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function getGPUSQLBinaryOperator(value) {
|
|
465
465
|
switch (value.toUpperCase()) {
|
|
466
466
|
case "OR":
|
|
467
467
|
return { operator: "or", precedence: 1 };
|
|
@@ -494,6 +494,6 @@ function getLuSQLBinaryOperator(value) {
|
|
|
494
494
|
}
|
|
495
495
|
// Annotate the CommonJS export names for ESM import in node:
|
|
496
496
|
0 && (module.exports = {
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
GPUSQLContext,
|
|
498
|
+
GPUSQLQuery
|
|
499
499
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { GPUCommandGraph } from '@luma.gl/graph/gpu-core';
|
|
2
|
-
import { GPUDataFrame
|
|
3
|
-
import type { CompiledGPUDataFrameQuery
|
|
2
|
+
import { GPUDataFrame } from "../gpu-dataframe/gpu-data-frame.js";
|
|
3
|
+
import type { CompiledGPUDataFrameQuery, GPUDataFrameQueryParameters } from "../gpu-dataframe/gpu-query-compiler.js";
|
|
4
4
|
/** Explicit GPU dataframe registrations; Arrow remains exclusively an adapter boundary. */
|
|
5
|
-
export type
|
|
5
|
+
export type GPUSQLTables = Readonly<Record<string, GPUDataFrame>>;
|
|
6
6
|
/** Defaults for named SQL parameters such as `:minimumFare`; values remain caller-controlled. */
|
|
7
|
-
export type
|
|
8
|
-
parameters?:
|
|
7
|
+
export type GPUSQLQueryOptions = Readonly<{
|
|
8
|
+
parameters?: GPUDataFrameQueryParameters;
|
|
9
9
|
}>;
|
|
10
|
-
type
|
|
11
|
-
compile: (graph: GPUCommandGraph<
|
|
10
|
+
type GPUSQLCompiledPlan = Readonly<{
|
|
11
|
+
compile: (graph: GPUCommandGraph<GPUDataFrameQueryParameters>) => CompiledGPUDataFrameQuery;
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
14
|
* Dependency-free SQL frontend over explicitly registered, already GPU-resident dataframes.
|
|
@@ -16,21 +16,21 @@ type LuSQLCompiledPlan = Readonly<{
|
|
|
16
16
|
* Parsing and planning never upload data, submit work, or read GPU buffers. Arrow upload/output
|
|
17
17
|
* remain explicit `@luma.gl/graph/arrow` operations around the shared GPU table execution core.
|
|
18
18
|
*/
|
|
19
|
-
export declare class
|
|
19
|
+
export declare class GPUSQLContext {
|
|
20
20
|
private readonly tables;
|
|
21
|
-
constructor(tables:
|
|
21
|
+
constructor(tables: GPUSQLTables);
|
|
22
22
|
/** Parses and validates one immutable SELECT plan without touching registered GPU sources. */
|
|
23
|
-
query(source: string, options?:
|
|
23
|
+
query(source: string, options?: GPUSQLQueryOptions): GPUSQLQuery;
|
|
24
24
|
}
|
|
25
25
|
/** Immutable SQL plan lowered directly into existing reusable GPU dataframe command graphs. */
|
|
26
|
-
export declare class
|
|
26
|
+
export declare class GPUSQLQuery {
|
|
27
27
|
/** Original application-owned SQL text, retained solely for diagnostics and inspection. */
|
|
28
28
|
readonly sql: string;
|
|
29
29
|
private readonly plan;
|
|
30
30
|
/** @internal */
|
|
31
|
-
constructor(sql: string, plan:
|
|
31
|
+
constructor(sql: string, plan: GPUSQLCompiledPlan);
|
|
32
32
|
/** Compiles existing dataframe operations into the caller-owned GPU command graph. */
|
|
33
|
-
compile(graph: GPUCommandGraph<
|
|
33
|
+
compile(graph: GPUCommandGraph<GPUDataFrameQueryParameters>): CompiledGPUDataFrameQuery;
|
|
34
34
|
}
|
|
35
35
|
export {};
|
|
36
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=gpu-sql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-sql.d.ts","sourceRoot":"","sources":["../../src/gpu-sql/gpu-sql.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,2CAAwC;AAU7D,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC5B,+CAA4C;AAM7C,2FAA2F;AAC3F,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAElE,iGAAiG;AACjG,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IAAC,UAAU,CAAC,EAAE,2BAA2B,CAAA;CAAC,CAAC,CAAC;AAkCtF,KAAK,kBAAkB,GAAG,QAAQ,CAAC;IACjC,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,2BAA2B,CAAC,KAAK,yBAAyB,CAAC;CAC7F,CAAC,CAAC;AAiCH;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;gBAEpD,MAAM,EAAE,YAAY;IAchC,8FAA8F;IAC9F,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,WAAW;CAKrE;AAED,+FAA+F;AAC/F,qBAAa,WAAW;IACtB,2FAA2F;IAC3F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAE1C,gBAAgB;gBACJ,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB;IAMjD,sFAAsF;IACtF,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,2BAA2B,CAAC,GAAG,yBAAyB;CAGxF"}
|