@query-farm/vgi 0.49.0 → 0.49.2
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/catalog/read-only.d.ts +6 -4
- package/dist/index.js +23 -19
- package/dist/index.js.map +4 -4
- package/dist/serve-entry.js +21 -17
- package/dist/serve-entry.js.map +3 -3
- package/dist/worker-cf-entry.js +23 -19
- package/dist/worker-cf-entry.js.map +4 -4
- package/package.json +3 -3
- package/src/catalog/read-only.ts +11 -6
- package/src/filter-pushdown/evaluate.ts +30 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@query-farm/vgi",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.2",
|
|
4
4
|
"description": "TypeScript framework for extending DuckDB with user-defined functions via the Vector Gateway Interface (VGI) over Arrow IPC.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Query Farm LLC (https://query.farm)",
|
|
@@ -93,12 +93,12 @@
|
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@query-farm/apache-arrow": "^21.1.1",
|
|
96
|
-
"@query-farm/vgi-rpc": "^0.29.
|
|
96
|
+
"@query-farm/vgi-rpc": "^0.29.7"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@duckdb/node-api": "^1.5.5-r.4",
|
|
100
100
|
"@query-farm/apache-arrow": "^21.1.1",
|
|
101
|
-
"@query-farm/vgi-rpc": "^0.29.
|
|
101
|
+
"@query-farm/vgi-rpc": "^0.29.7",
|
|
102
102
|
"@types/bun": "latest",
|
|
103
103
|
"typescript": "^7.0.2"
|
|
104
104
|
},
|
package/src/catalog/read-only.ts
CHANGED
|
@@ -27,6 +27,11 @@ import { serializeColumnStatistics } from "../util/statistics.js";
|
|
|
27
27
|
import { SCAN_PLANNING_BIND, SCAN_PLANNING_FILTERED, validateScanPlanning } from "./scan-planning.js";
|
|
28
28
|
import type { VgiFunction } from "../functions/types.js";
|
|
29
29
|
import type { FunctionRegistry } from "../functions/registry.js";
|
|
30
|
+
|
|
31
|
+
// Schema and view lookups may be overridden with async implementations, for a
|
|
32
|
+
// catalog that discovers them from a remote service; the dispatcher awaits
|
|
33
|
+
// them. (schemaContentsTables/tableGet are async already.)
|
|
34
|
+
type Awaitable<T> = T | Promise<T>;
|
|
30
35
|
import { argumentSpecsToSchema } from "../arguments/argument-spec.js";
|
|
31
36
|
import { serializeSchema, serializeBatch, emptyBatch, batchFromColumns } from "../util/arrow/index.js";
|
|
32
37
|
import { resolveMetadata } from "../metadata/resolve.js";
|
|
@@ -330,7 +335,7 @@ export class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
330
335
|
return super.catalogContentsCacheable() && !this.perAttachItemIds;
|
|
331
336
|
}
|
|
332
337
|
|
|
333
|
-
schemas(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): SchemaInfo[] {
|
|
338
|
+
schemas(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): Awaitable<SchemaInfo[]> {
|
|
334
339
|
return this._descriptor.schemas.map((s) => ({
|
|
335
340
|
path: schemaDescriptorPath(s),
|
|
336
341
|
comment: s.comment ?? null,
|
|
@@ -365,7 +370,7 @@ export class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
365
370
|
attachOpaqueData: AttachOpaqueData,
|
|
366
371
|
path: string[],
|
|
367
372
|
transactionOpaqueData?: TransactionOpaqueData
|
|
368
|
-
): SchemaInfo | null {
|
|
373
|
+
): Awaitable<SchemaInfo | null> {
|
|
369
374
|
const desc = this._descriptor.schemas.find((s) => schemaPathsEqual(schemaDescriptorPath(s), path));
|
|
370
375
|
if (!desc) return null;
|
|
371
376
|
return {
|
|
@@ -548,7 +553,7 @@ export class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
548
553
|
attachOpaqueData: AttachOpaqueData,
|
|
549
554
|
path: string[],
|
|
550
555
|
transactionOpaqueData?: TransactionOpaqueData
|
|
551
|
-
): ViewInfo[] {
|
|
556
|
+
): Awaitable<ViewInfo[]> {
|
|
552
557
|
const schema = this._descriptor.schemas.find((s) => schemaPathsEqual(schemaDescriptorPath(s), path));
|
|
553
558
|
if (!schema || !schema.views) return [];
|
|
554
559
|
|
|
@@ -1011,13 +1016,13 @@ export class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
1011
1016
|
return tables.find((t) => t.name === name) ?? null;
|
|
1012
1017
|
}
|
|
1013
1018
|
|
|
1014
|
-
override viewGet(
|
|
1019
|
+
override async viewGet(
|
|
1015
1020
|
attachOpaqueData: AttachOpaqueData,
|
|
1016
1021
|
schemaPath: string[],
|
|
1017
1022
|
name: string,
|
|
1018
1023
|
transactionOpaqueData?: TransactionOpaqueData
|
|
1019
|
-
): ViewInfo | null {
|
|
1020
|
-
const views = this.schemaContentsViews(attachOpaqueData, schemaPath, transactionOpaqueData);
|
|
1024
|
+
): Promise<ViewInfo | null> {
|
|
1025
|
+
const views = await this.schemaContentsViews(attachOpaqueData, schemaPath, transactionOpaqueData);
|
|
1021
1026
|
return views.find((v) => v.name === name) ?? null;
|
|
1022
1027
|
}
|
|
1023
1028
|
|
|
@@ -229,13 +229,24 @@ class WkbBoundsReader {
|
|
|
229
229
|
return value;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
/**
|
|
233
|
+
* One vertex, as DuckDB core `&&` sees it: NaN on an axis leaves that axis
|
|
234
|
+
* unbounded and ±inf are ordinary values. Only a POINT geometry whose
|
|
235
|
+
* coordinates are ALL NaN, Z and M included (how WKB spells POINT EMPTY),
|
|
236
|
+
* has no vertex at all: `POINT Z (nan nan 5)` is a vertex unbounded on both
|
|
237
|
+
* axes, as are all-NaN coordinates in a LINESTRING or POLYGON.
|
|
238
|
+
*/
|
|
239
|
+
private point(littleEndian: boolean, dimensions: number, isPointGeometry = false): Bounds | null {
|
|
233
240
|
const x = this.float64(littleEndian);
|
|
234
241
|
const y = this.float64(littleEndian);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
242
|
+
let allNaN = Number.isNaN(x) && Number.isNaN(y);
|
|
243
|
+
for (let dimension = 2; dimension < dimensions; dimension++) {
|
|
244
|
+
allNaN = Number.isNaN(this.float64(littleEndian)) && allNaN;
|
|
245
|
+
}
|
|
246
|
+
if (isPointGeometry && allNaN) return null;
|
|
247
|
+
const [minX, maxX] = Number.isNaN(x) ? [-Infinity, Infinity] : [x, x];
|
|
248
|
+
const [minY, maxY] = Number.isNaN(y) ? [-Infinity, Infinity] : [y, y];
|
|
249
|
+
return { minX, minY, maxX, maxY };
|
|
239
250
|
}
|
|
240
251
|
|
|
241
252
|
private count(littleEndian: boolean): number {
|
|
@@ -286,7 +297,7 @@ class WkbBoundsReader {
|
|
|
286
297
|
}
|
|
287
298
|
if (hasSrid) this.uint32(littleEndian);
|
|
288
299
|
|
|
289
|
-
if (type === 1) return this.point(littleEndian, dimensions);
|
|
300
|
+
if (type === 1) return this.point(littleEndian, dimensions, true);
|
|
290
301
|
if (type === 2) return this.points(littleEndian, dimensions);
|
|
291
302
|
if (type === 3) {
|
|
292
303
|
let bounds: Bounds | null = null;
|
|
@@ -503,14 +514,19 @@ export class PushdownFilters {
|
|
|
503
514
|
mask.fill(1);
|
|
504
515
|
for (const predicate of this.predicates) {
|
|
505
516
|
if (predicate.expression.node === "runtime_filter" && !predicate.expression.supported) continue;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
517
|
+
// A required predicate that cannot be evaluated fails the scan: DuckDB
|
|
518
|
+
// has dropped it from its own plan. An advisory one only prunes, so a
|
|
519
|
+
// row it cannot evaluate (malformed WKB, a non-binary value, ...) is
|
|
520
|
+
// kept, and the other rows are still filtered.
|
|
521
|
+
const advisory = predicate.mode === "advisory";
|
|
522
|
+
const values = Array.from({ length: batch.numRows }, (_, row) => {
|
|
523
|
+
try {
|
|
524
|
+
return evaluateExpression(predicate.expression, batch, row, this.evaluationContext);
|
|
525
|
+
} catch (error) {
|
|
526
|
+
if (advisory) return true;
|
|
527
|
+
throw error;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
514
530
|
for (let row = 0; row < batch.numRows; row++) mask[row]! &= values[row] === true ? 1 : 0;
|
|
515
531
|
}
|
|
516
532
|
return mask;
|