@query-farm/vgi 0.49.1 → 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/index.js +21 -17
- package/dist/index.js.map +3 -3
- package/dist/serve-entry.js +21 -17
- package/dist/serve-entry.js.map +3 -3
- package/dist/worker-cf-entry.js +21 -17
- package/dist/worker-cf-entry.js.map +3 -3
- package/package.json +1 -1
- 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)",
|
|
@@ -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;
|