@luma.gl/graph 10.0.0-beta.1 → 10.0.0-beta.3
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/gpu/arrow-gpu-analytics-adapters.cjs +22 -9
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts +11 -2
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js +27 -10
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.cjs +24 -13
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts +9 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js +41 -14
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +24 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +10 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +29 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -1
- package/dist/arrow/index.cjs +2 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -1
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -1
- package/dist/arrow/index.js.map +1 -1
- package/dist/experimental-models.cjs +21 -0
- package/dist/experimental-models.d.ts +2 -0
- package/dist/experimental-models.d.ts.map +1 -0
- package/dist/experimental-models.js +5 -0
- package/dist/experimental-models.js.map +1 -0
- package/dist/experimental-simulation.cjs +21 -0
- package/dist/experimental-simulation.d.ts +2 -0
- package/dist/experimental-simulation.d.ts.map +1 -0
- package/dist/experimental-simulation.js +5 -0
- package/dist/experimental-simulation.js.map +1 -0
- package/dist/gpu-core/gpu-bvh-bounds.cjs +63 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts +32 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts.map +1 -0
- package/dist/gpu-core/gpu-bvh-bounds.js +56 -0
- package/dist/gpu-core/gpu-bvh-bounds.js.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.cjs +92 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts +41 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js +85 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js.map +1 -0
- package/dist/gpu-core/index.cjs +6 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +4 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.cjs +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.cjs +60 -15
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts +13 -2
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.js +69 -18
- package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.cjs +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.d.ts +10 -0
- package/dist/gpu-dataframe/gpu-data-frame.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.js +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.cjs +157 -25
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts +9 -5
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.js +184 -25
- package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +100 -8
- package/dist/gpu-dataframe/gpu-expression.d.ts +35 -3
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +92 -6
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +2 -3
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +4 -3
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +4 -4
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js +11 -5
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +136 -99
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +7 -2
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +135 -97
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +286 -49
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +17 -2
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +290 -40
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +10 -8
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +7 -1
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +14 -8
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +8 -8
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +9 -9
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +38 -10
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +3 -2
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +37 -9
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-query.cjs +13 -5
- package/dist/gpu-dataframe/gpu-sort-query.d.ts +4 -1
- package/dist/gpu-dataframe/gpu-sort-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-query.js +14 -5
- package/dist/gpu-dataframe/gpu-sort-query.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs +12 -2
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dataframe/index.d.ts +3 -3
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +2 -2
- package/dist/gpu-dataframe/index.js.map +1 -1
- package/dist/gpu-dataframe/portable-expression.cjs +68 -4
- package/dist/gpu-dataframe/portable-expression.d.ts +3 -1
- package/dist/gpu-dataframe/portable-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/portable-expression.js +69 -5
- package/dist/gpu-dataframe/portable-expression.js.map +1 -1
- package/dist/gpu-dggs-benchmarks.cjs +21 -0
- package/dist/gpu-dggs-benchmarks.d.ts +2 -0
- package/dist/gpu-dggs-benchmarks.d.ts.map +1 -0
- package/dist/gpu-dggs-benchmarks.js +5 -0
- package/dist/gpu-dggs-benchmarks.js.map +1 -0
- package/dist/gpu-graph-algorithms-benchmarks.cjs +21 -0
- package/dist/gpu-graph-algorithms-benchmarks.d.ts +2 -0
- package/dist/gpu-graph-algorithms-benchmarks.d.ts.map +1 -0
- package/dist/gpu-graph-algorithms-benchmarks.js +5 -0
- package/dist/gpu-graph-algorithms-benchmarks.js.map +1 -0
- package/dist/gpu-physics/gpu-physics-batch.cjs +11 -10
- package/dist/gpu-physics/gpu-physics-batch.d.ts +1 -0
- package/dist/gpu-physics/gpu-physics-batch.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-batch.js +14 -10
- package/dist/gpu-physics/gpu-physics-batch.js.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.cjs +116 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts +42 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts.map +1 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.js +90 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.js.map +1 -0
- package/dist/gpu-physics/gpu-physics-ensemble.cjs +105 -8
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts +40 -2
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.js +109 -6
- package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +737 -213
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +111 -5
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +842 -231
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs +23 -2
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +10 -3
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js +6 -1
- package/dist/gpu-physics/index.js.map +1 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.cjs +21 -8
- package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.js +15 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.cjs +10 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.js +15 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.cjs +15 -2
- package/dist/gpu-physics/rigid-body-capacity.d.ts +3 -1
- package/dist/gpu-physics/rigid-body-capacity.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.js +21 -2
- package/dist/gpu-physics/rigid-body-capacity.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cast-index.cjs +192 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts +44 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-cast-index.js +194 -0
- package/dist/gpu-physics/rigid-body-cast-index.js.map +1 -0
- package/dist/gpu-physics/rigid-body-convex-shaders.cjs +3 -2
- package/dist/gpu-physics/rigid-body-convex-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-convex-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-convex-shaders.js +3 -2
- package/dist/gpu-physics/rigid-body-convex-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.cjs +4 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.js +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.cjs +45 -14
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.js +53 -14
- package/dist/gpu-physics/rigid-body-ensemble-reset.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.cjs +14 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts +5 -0
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js +17 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.cjs +40 -8
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js +49 -9
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js.map +1 -1
- package/dist/gpu-physics/rigid-body-event-compaction.cjs +184 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts +35 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js +168 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.cjs +51 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts +33 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js +34 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js.map +1 -0
- package/dist/gpu-physics/rigid-body-events.cjs +57 -25
- package/dist/gpu-physics/rigid-body-events.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-events.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-events.js +60 -25
- package/dist/gpu-physics/rigid-body-events.js.map +1 -1
- package/dist/gpu-physics/rigid-body-geometry.cjs +41 -4
- package/dist/gpu-physics/rigid-body-geometry.d.ts +10 -1
- package/dist/gpu-physics/rigid-body-geometry.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-geometry.js +44 -3
- package/dist/gpu-physics/rigid-body-geometry.js.map +1 -1
- package/dist/gpu-physics/rigid-body-height-field-shader.cjs +80 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.d.ts +3 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.js +56 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.js.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field.cjs +166 -0
- package/dist/gpu-physics/rigid-body-height-field.d.ts +55 -0
- package/dist/gpu-physics/rigid-body-height-field.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field.js +184 -0
- package/dist/gpu-physics/rigid-body-height-field.js.map +1 -0
- package/dist/gpu-physics/rigid-body-joints.cjs +8 -3
- package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.js +10 -6
- package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.cjs +4 -2
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.js +4 -2
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh.cjs +72 -17
- package/dist/gpu-physics/rigid-body-mesh.d.ts +3 -0
- package/dist/gpu-physics/rigid-body-mesh.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh.js +76 -20
- package/dist/gpu-physics/rigid-body-mesh.js.map +1 -1
- package/dist/gpu-physics/rigid-body-properties.cjs +4 -4
- package/dist/gpu-physics/rigid-body-properties.d.ts +6 -0
- package/dist/gpu-physics/rigid-body-properties.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-properties.js +1 -1
- package/dist/gpu-physics/rigid-body-properties.js.map +1 -1
- package/dist/gpu-physics/rigid-body-publication.cjs +2 -2
- package/dist/gpu-physics/rigid-body-publication.js +1 -1
- package/dist/gpu-physics/rigid-body-publication.js.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.cjs +159 -16
- package/dist/gpu-physics/rigid-body-queries.d.ts +24 -1
- package/dist/gpu-physics/rigid-body-queries.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.js +166 -14
- package/dist/gpu-physics/rigid-body-queries.js.map +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.cjs +22 -4
- package/dist/gpu-physics/rigid-body-query-geometry.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.js +22 -4
- package/dist/gpu-physics/rigid-body-query-geometry.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +13 -7
- package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.js +16 -8
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shape-properties.cjs +2 -0
- package/dist/gpu-physics/rigid-body-shape-properties.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shape-properties.js +2 -0
- package/dist/gpu-physics/rigid-body-shape-properties.js.map +1 -1
- package/dist/gpu-physics/rigid-body-terrain-atlas.cjs +287 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts +87 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.js +275 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.cjs +240 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.d.ts +76 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.js +247 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.cjs +215 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts +25 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.js +218 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.cjs +263 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.d.ts +97 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.js +250 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.js.map +1 -0
- package/dist/gpu-physics/rigid-body-triggers.cjs +54 -15
- package/dist/gpu-physics/rigid-body-triggers.d.ts +1 -0
- package/dist/gpu-physics/rigid-body-triggers.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.js +56 -15
- package/dist/gpu-physics/rigid-body-triggers.js.map +1 -1
- package/dist/gpu-physics/rigid-body-vehicle.cjs +99 -44
- package/dist/gpu-physics/rigid-body-vehicle.d.ts +15 -3
- package/dist/gpu-physics/rigid-body-vehicle.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-vehicle.js +93 -40
- package/dist/gpu-physics/rigid-body-vehicle.js.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.cjs +48 -20
- package/dist/gpu-physics/sphere-world-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.js +51 -21
- package/dist/gpu-physics/sphere-world-shaders.js.map +1 -1
- package/dist/gpu-project/benchmarks.cjs.map +2 -2
- package/dist/gpu-project/cpu-geometry-pipelines.d.ts +1 -1
- package/dist/gpu-project/cpu-projection-operation.d.ts +1 -1
- package/dist/gpu-project/crs.cjs.map +3 -3
- package/dist/gpu-project/crs.d.ts +1 -1
- package/dist/gpu-project/index.cjs.map +2 -2
- package/dist/gpu-project/projection-crs-benchmark.cjs +2 -2
- package/dist/gpu-project/projection-crs-benchmark.d.ts +1 -1
- package/dist/gpu-project/projection-crs-benchmark.js +1 -1
- package/dist/gpu-project/projection-crs-input.cjs +7 -7
- package/dist/gpu-project/projection-crs-input.d.ts +1 -1
- package/dist/gpu-project/projection-crs-input.js +4 -4
- package/dist/gpu-project/projection-engine.d.ts +2 -2
- package/dist/gpu-project/projection-program.cjs +2 -9
- package/dist/gpu-project/projection-program.d.ts.map +1 -1
- package/dist/gpu-project/projection-program.js +1 -8
- package/dist/gpu-project/projection-program.js.map +1 -1
- package/dist/gpu-project-benchmarks.cjs +21 -0
- package/dist/gpu-project-benchmarks.d.ts +2 -0
- package/dist/gpu-project-benchmarks.d.ts.map +1 -0
- package/dist/gpu-project-benchmarks.js +5 -0
- package/dist/gpu-project-benchmarks.js.map +1 -0
- package/dist/gpu-project-crs.cjs +21 -0
- package/dist/gpu-project-crs.d.ts +2 -0
- package/dist/gpu-project-crs.d.ts.map +1 -0
- package/dist/gpu-project-crs.js +5 -0
- package/dist/gpu-project-crs.js.map +1 -0
- package/dist/gpu-project-geoarrow.cjs +21 -0
- package/dist/gpu-project-geoarrow.d.ts +2 -0
- package/dist/gpu-project-geoarrow.d.ts.map +1 -0
- package/dist/gpu-project-geoarrow.js +5 -0
- package/dist/gpu-project-geoarrow.js.map +1 -0
- package/dist/gpu-project-graph.cjs +21 -0
- package/dist/gpu-project-graph.d.ts +2 -0
- package/dist/gpu-project-graph.d.ts.map +1 -0
- package/dist/gpu-project-graph.js +5 -0
- package/dist/gpu-project-graph.js.map +1 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/operation.d.ts +1 -1
- package/dist/gpu-simple-graph/operation/operation.d.ts.map +1 -1
- package/dist/gpu-simple-graph-cpu.cjs +21 -0
- package/dist/gpu-simple-graph-cpu.d.ts +2 -0
- package/dist/gpu-simple-graph-cpu.d.ts.map +1 -0
- package/dist/gpu-simple-graph-cpu.js +5 -0
- package/dist/gpu-simple-graph-cpu.js.map +1 -0
- package/dist/gpu-simple-graph-webgl.cjs +21 -0
- package/dist/gpu-simple-graph-webgl.d.ts +2 -0
- package/dist/gpu-simple-graph-webgl.d.ts.map +1 -0
- package/dist/gpu-simple-graph-webgl.js +5 -0
- package/dist/gpu-simple-graph-webgl.js.map +1 -0
- package/dist/gpu-simple-graph-webgpu.cjs +21 -0
- package/dist/gpu-simple-graph-webgpu.d.ts +2 -0
- package/dist/gpu-simple-graph-webgpu.d.ts.map +1 -0
- package/dist/gpu-simple-graph-webgpu.js +5 -0
- package/dist/gpu-simple-graph-webgpu.js.map +1 -0
- package/dist/gpu-sql/gpu-sql.cjs +269 -171
- package/dist/gpu-sql/gpu-sql.d.ts +36 -1
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +313 -181
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +3 -3
- package/dist/gpu-sql/index.d.ts +1 -1
- package/dist/gpu-sql/index.d.ts.map +1 -1
- package/dist/utils/float32.cjs +35 -0
- package/dist/utils/float32.d.ts +3 -0
- package/dist/utils/float32.d.ts.map +1 -0
- package/dist/utils/float32.js +16 -0
- package/dist/utils/float32.js.map +1 -0
- package/package.json +19 -19
- package/src/arrow/gpu/arrow-gpu-analytics-adapters.ts +77 -25
- package/src/arrow/gpu/arrow-gpu-analytics-readback.ts +52 -16
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +46 -1
- package/src/arrow/index.ts +1 -0
- package/src/experimental-models.ts +5 -0
- package/src/experimental-simulation.ts +5 -0
- package/src/gpu-core/gpu-bvh-bounds.ts +84 -0
- package/src/gpu-core/gpu-command-graph-submission-pacer.ts +102 -0
- package/src/gpu-core/index.ts +5 -0
- package/src/gpu-dataframe/gpu-analytics-compiler-utils.ts +7 -10
- package/src/gpu-dataframe/gpu-data-frame-query.ts +119 -25
- package/src/gpu-dataframe/gpu-data-frame.ts +35 -2
- package/src/gpu-dataframe/gpu-expression-shader.ts +267 -32
- package/src/gpu-dataframe/gpu-expression.ts +186 -10
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +6 -3
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +17 -6
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +177 -105
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +469 -53
- package/src/gpu-dataframe/gpu-group-by-query.ts +29 -13
- package/src/gpu-dataframe/gpu-histogram-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-join-compiler.ts +12 -8
- package/src/gpu-dataframe/gpu-query-compiler.ts +61 -19
- package/src/gpu-dataframe/gpu-sort-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-sort-query.ts +31 -5
- package/src/gpu-dataframe/index.ts +16 -3
- package/src/gpu-dataframe/portable-expression.ts +81 -4
- package/src/gpu-dggs-benchmarks.ts +5 -0
- package/src/gpu-graph-algorithms-benchmarks.ts +5 -0
- package/src/gpu-physics/gpu-physics-batch.ts +19 -13
- package/src/gpu-physics/gpu-physics-ensemble-terrain.ts +114 -0
- package/src/gpu-physics/gpu-physics-ensemble.ts +166 -7
- package/src/gpu-physics/gpu-rigid-body-world.ts +1085 -287
- package/src/gpu-physics/index.ts +46 -0
- package/src/gpu-physics/rigid-body-bounds-shaders.ts +16 -1
- package/src/gpu-physics/rigid-body-cache-shaders.ts +18 -6
- package/src/gpu-physics/rigid-body-capacity.ts +25 -4
- package/src/gpu-physics/rigid-body-cast-index.ts +277 -0
- package/src/gpu-physics/rigid-body-convex-shaders.ts +3 -2
- package/src/gpu-physics/rigid-body-ensemble-layout.ts +6 -2
- package/src/gpu-physics/rigid-body-ensemble-reset.ts +67 -15
- package/src/gpu-physics/rigid-body-ensemble-shaders.ts +18 -7
- package/src/gpu-physics/rigid-body-ensemble-transaction.ts +61 -10
- package/src/gpu-physics/rigid-body-event-compaction.ts +252 -0
- package/src/gpu-physics/rigid-body-event-snapshot.ts +76 -0
- package/src/gpu-physics/rigid-body-events.ts +63 -25
- package/src/gpu-physics/rigid-body-geometry.ts +49 -4
- package/src/gpu-physics/rigid-body-height-field-shader.ts +56 -0
- package/src/gpu-physics/rigid-body-height-field.ts +257 -0
- package/src/gpu-physics/rigid-body-joints.ts +9 -11
- package/src/gpu-physics/rigid-body-mesh-query-shaders.ts +4 -2
- package/src/gpu-physics/rigid-body-mesh.ts +97 -26
- package/src/gpu-physics/rigid-body-properties.ts +5 -2
- package/src/gpu-physics/rigid-body-publication.ts +1 -1
- package/src/gpu-physics/rigid-body-queries.ts +202 -14
- package/src/gpu-physics/rigid-body-query-geometry.ts +22 -4
- package/src/gpu-physics/rigid-body-shaders.ts +20 -8
- package/src/gpu-physics/rigid-body-shape-properties.ts +2 -0
- package/src/gpu-physics/rigid-body-terrain-atlas.ts +378 -0
- package/src/gpu-physics/rigid-body-terrain-lod.ts +332 -0
- package/src/gpu-physics/rigid-body-terrain-stitch.ts +286 -0
- package/src/gpu-physics/rigid-body-terrain-stream.ts +323 -0
- package/src/gpu-physics/rigid-body-triggers.ts +65 -20
- package/src/gpu-physics/rigid-body-vehicle.ts +108 -41
- package/src/gpu-physics/sphere-world-shaders.ts +53 -21
- package/src/gpu-project/README.md +2 -2
- package/src/gpu-project/cpu-geometry-pipelines.ts +1 -1
- package/src/gpu-project/cpu-projection-operation.ts +1 -1
- package/src/gpu-project/crs.ts +2 -2
- package/src/gpu-project/projection-crs-benchmark.ts +2 -2
- package/src/gpu-project/projection-crs-input.ts +4 -4
- package/src/gpu-project/projection-engine.ts +2 -2
- package/src/gpu-project/projection-program.ts +1 -9
- package/src/gpu-project-benchmarks.ts +5 -0
- package/src/gpu-project-crs.ts +5 -0
- package/src/gpu-project-geoarrow.ts +5 -0
- package/src/gpu-project-graph.ts +5 -0
- package/src/gpu-simple-graph/gpu-simple-graph-transfer.ts +1 -1
- package/src/gpu-simple-graph/gpu-simple-graph-value.ts +1 -1
- package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +1 -1
- package/src/gpu-simple-graph/operation/operation.ts +1 -1
- package/src/gpu-simple-graph/operations/swizzle.ts +1 -1
- package/src/gpu-simple-graph-cpu.ts +5 -0
- package/src/gpu-simple-graph-webgl.ts +5 -0
- package/src/gpu-simple-graph-webgpu.ts +5 -0
- package/src/gpu-sql/gpu-sql.ts +535 -223
- package/src/gpu-sql/index.ts +1 -1
- package/src/utils/float32.ts +16 -0
package/src/gpu-sql/gpu-sql.ts
CHANGED
|
@@ -6,16 +6,36 @@
|
|
|
6
6
|
import {parseSQLSelectStatement} from '@math.gl/sql/parser';
|
|
7
7
|
import type {Expression} from '@math.gl/sql/expressions';
|
|
8
8
|
import type {GPUCommandGraph} from '@luma.gl/graph/gpu-core';
|
|
9
|
+
import type {GPUTypeMap} from '@luma.gl/graph/gpu-tables';
|
|
10
|
+
|
|
9
11
|
import {GPUDataFrame} from '../gpu-dataframe/gpu-data-frame';
|
|
10
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
GPUDataFrameQuery,
|
|
14
|
+
type GPUDataFrameDerivedColumn
|
|
15
|
+
} from '../gpu-dataframe/gpu-data-frame-query';
|
|
16
|
+
import {
|
|
17
|
+
compileGPUDataFrameGroupedAggregation,
|
|
18
|
+
compileGPUDataFrameObservedAggregation
|
|
19
|
+
} from '../gpu-dataframe/gpu-group-aggregation-compiler';
|
|
20
|
+
import {normalizeGPUDataFrameAggregations} from '../gpu-dataframe/gpu-group-by-query';
|
|
21
|
+
import {
|
|
22
|
+
compileGPUDataFrameGlobalSort,
|
|
23
|
+
type GPUGlobalSortKey
|
|
24
|
+
} from '../gpu-dataframe/gpu-global-sort-compiler';
|
|
25
|
+
import type {GPUDataFrameNormalizedSortOptions} from '../gpu-dataframe/gpu-sort-query';
|
|
11
26
|
import {
|
|
12
27
|
GPUExpression,
|
|
13
28
|
column,
|
|
14
|
-
|
|
29
|
+
isGPUScalarFunction,
|
|
15
30
|
parameter,
|
|
16
31
|
type GPUExpressionNode
|
|
17
32
|
} from '../gpu-dataframe/gpu-expression';
|
|
18
|
-
import
|
|
33
|
+
import {lowerPortableExpression} from '../gpu-dataframe/portable-expression';
|
|
34
|
+
import {compileGPUDataFrameJoin} from '../gpu-dataframe/gpu-join-compiler';
|
|
35
|
+
import type {
|
|
36
|
+
GPUDataFrameJoinType,
|
|
37
|
+
GPUDataFrameNormalizedJoinOptions
|
|
38
|
+
} from '../gpu-dataframe/gpu-join-query';
|
|
19
39
|
import type {
|
|
20
40
|
CompiledGPUDataFrameQuery,
|
|
21
41
|
GPUDataFrameQueryParameters
|
|
@@ -27,10 +47,15 @@ export type GPUSQLTables = Readonly<Record<string, GPUDataFrame>>;
|
|
|
27
47
|
/** Defaults for named SQL parameters such as `:minimumFare`; values remain caller-controlled. */
|
|
28
48
|
export type GPUSQLQueryOptions = Readonly<{parameters?: GPUDataFrameQueryParameters}>;
|
|
29
49
|
|
|
50
|
+
/** A source column name with its optional, separately parsed table qualifier. */
|
|
51
|
+
type GPUSQLColumnReference = Readonly<{name: string; qualifier?: string}>;
|
|
52
|
+
|
|
53
|
+
/** A bound-column spelling or a one-based SELECT position. */
|
|
54
|
+
|
|
30
55
|
type GPUSQLSelectItem = Readonly<{
|
|
31
|
-
expression?:
|
|
56
|
+
expression?: Expression;
|
|
32
57
|
aggregate?: 'count' | 'sum' | 'min' | 'max' | 'mean';
|
|
33
|
-
|
|
58
|
+
aggregateInput?: Expression;
|
|
34
59
|
alias?: string;
|
|
35
60
|
star?: boolean;
|
|
36
61
|
}>;
|
|
@@ -42,31 +67,73 @@ type GPUSQLStatement = Readonly<{
|
|
|
42
67
|
type: GPUDataFrameJoinType;
|
|
43
68
|
table: string;
|
|
44
69
|
alias?: string;
|
|
45
|
-
left:
|
|
46
|
-
right:
|
|
70
|
+
left: GPUSQLColumnReference;
|
|
71
|
+
right: GPUSQLColumnReference;
|
|
47
72
|
}>;
|
|
48
|
-
predicate?:
|
|
49
|
-
groupBy?:
|
|
50
|
-
orderBy?: Readonly<{
|
|
51
|
-
|
|
73
|
+
predicate?: Expression;
|
|
74
|
+
groupBy?: readonly Expression[];
|
|
75
|
+
orderBy?: readonly Readonly<{
|
|
76
|
+
expression: Expression;
|
|
52
77
|
direction: 'ascending' | 'descending';
|
|
53
78
|
nulls?: 'first' | 'last';
|
|
54
|
-
}
|
|
79
|
+
}>[];
|
|
55
80
|
limit?: number;
|
|
81
|
+
offset?: number;
|
|
82
|
+
}>;
|
|
83
|
+
|
|
84
|
+
/** Execution route selected by the GPU SQL planner. */
|
|
85
|
+
export type GPUSQLExecution =
|
|
86
|
+
| 'projection'
|
|
87
|
+
| 'global-sort'
|
|
88
|
+
| 'global-aggregation'
|
|
89
|
+
| 'dense-grouping'
|
|
90
|
+
| 'observed-grouping'
|
|
91
|
+
| 'unique-right-join';
|
|
92
|
+
|
|
93
|
+
/** CPU-only description of the bound GPU SQL plan. */
|
|
94
|
+
export type GPUSQLExplanation = Readonly<{
|
|
95
|
+
/** Registered input table. */
|
|
96
|
+
table: string;
|
|
97
|
+
/** Whether a source-row WHERE predicate runs before the terminal operation. */
|
|
98
|
+
filtered: boolean;
|
|
99
|
+
/** Terminal GPU dataframe execution route. */
|
|
100
|
+
execution: GPUSQLExecution;
|
|
101
|
+
/** Result fields in SELECT order. */
|
|
102
|
+
columns: readonly string[];
|
|
103
|
+
/** Columns used internally, including derived or hidden keys when applicable. */
|
|
104
|
+
workingColumns: readonly string[];
|
|
105
|
+
/** Number of resolved grouping or ordering keys. */
|
|
106
|
+
keyCount: number;
|
|
107
|
+
/** Registered right table and join type for join plans. */
|
|
108
|
+
join?: Readonly<{table: string; type: GPUDataFrameJoinType}>;
|
|
109
|
+
/** Applied global page bounds, when supplied. */
|
|
110
|
+
page?: Readonly<{offset: number; limit?: number}>;
|
|
56
111
|
}>;
|
|
57
112
|
|
|
113
|
+
/** Binds executable operations to the immutable description produced at planning time. */
|
|
114
|
+
type GPUSQLBoundPlan = {plan: GPUSQLCompiledPlan; explanation: GPUSQLExplanation};
|
|
115
|
+
|
|
58
116
|
type GPUSQLCompiledPlan = Readonly<{
|
|
59
117
|
compile: (graph: GPUCommandGraph<GPUDataFrameQueryParameters>) => CompiledGPUDataFrameQuery;
|
|
60
118
|
}>;
|
|
61
119
|
|
|
62
120
|
type GPUSQLAggregationDefinitions = Record<
|
|
63
121
|
string,
|
|
64
|
-
'count' | {sum: string} | {min: string} | {max: string} | {mean: string}
|
|
122
|
+
'count' | {count: string} | {sum: string} | {min: string} | {max: string} | {mean: string}
|
|
65
123
|
>;
|
|
66
124
|
|
|
125
|
+
/** Existing global-sort plan and its already-validated controls. */
|
|
126
|
+
type GPUSQLSortPlan = GPUSQLCompiledPlan & {readonly options: GPUDataFrameNormalizedSortOptions};
|
|
127
|
+
|
|
128
|
+
/** Validated join plan with normalized key and hash-index controls. */
|
|
129
|
+
|
|
130
|
+
type GPUSQLJoinPlan = GPUSQLCompiledPlan & {readonly options: GPUDataFrameNormalizedJoinOptions};
|
|
131
|
+
|
|
67
132
|
/** Runtime-validated SQL names cross the strongly typed dataframe boundary exactly once. */
|
|
68
133
|
type GPUSQLDynamicQuery = GPUSQLCompiledPlan & {
|
|
69
|
-
|
|
134
|
+
readonly selectedColumns: readonly string[];
|
|
135
|
+
readonly predicates: readonly GPUExpression<boolean, string>[];
|
|
136
|
+
readonly derivedColumns: readonly GPUDataFrameDerivedColumn[];
|
|
70
137
|
filter: (predicate: GPUExpression<boolean, string>) => GPUSQLDynamicQuery;
|
|
71
138
|
select: (names: readonly string[]) => GPUSQLDynamicQuery;
|
|
72
139
|
withColumn: (
|
|
@@ -74,20 +141,17 @@ type GPUSQLDynamicQuery = GPUSQLCompiledPlan & {
|
|
|
74
141
|
expression: GPUExpression<number | null, string>
|
|
75
142
|
) => GPUSQLDynamicQuery;
|
|
76
143
|
groupBy: (key: string) => {
|
|
77
|
-
|
|
144
|
+
readonly groupCount: number;
|
|
78
145
|
};
|
|
79
146
|
aggregate: (definitions: GPUSQLAggregationDefinitions) => GPUSQLCompiledPlan;
|
|
80
147
|
sortByGlobal: (
|
|
81
148
|
name: string,
|
|
82
149
|
options: {direction: 'ascending' | 'descending'; nulls?: 'first' | 'last'}
|
|
83
|
-
) =>
|
|
84
|
-
innerJoin: (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
) =>
|
|
88
|
-
leftJoin: (right: GPUDataFrame, options: {leftOn: string; rightOn: string}) => GPUSQLCompiledPlan;
|
|
89
|
-
semiJoin: (right: GPUDataFrame, options: {leftOn: string; rightOn: string}) => GPUSQLCompiledPlan;
|
|
90
|
-
antiJoin: (right: GPUDataFrame, options: {leftOn: string; rightOn: string}) => GPUSQLCompiledPlan;
|
|
150
|
+
) => GPUSQLSortPlan & {page: (offset: number, limit?: number) => GPUSQLSortPlan};
|
|
151
|
+
innerJoin: (right: GPUDataFrame, options: {leftOn: string; rightOn: string}) => GPUSQLJoinPlan;
|
|
152
|
+
leftJoin: (right: GPUDataFrame, options: {leftOn: string; rightOn: string}) => GPUSQLJoinPlan;
|
|
153
|
+
semiJoin: (right: GPUDataFrame, options: {leftOn: string; rightOn: string}) => GPUSQLJoinPlan;
|
|
154
|
+
antiJoin: (right: GPUDataFrame, options: {leftOn: string; rightOn: string}) => GPUSQLJoinPlan;
|
|
91
155
|
};
|
|
92
156
|
|
|
93
157
|
/**
|
|
@@ -115,8 +179,11 @@ export class GPUSQLContext {
|
|
|
115
179
|
|
|
116
180
|
/** Parses and validates one immutable SELECT plan without touching registered GPU sources. */
|
|
117
181
|
query(source: string, options: GPUSQLQueryOptions = {}): GPUSQLQuery {
|
|
118
|
-
const statement = parseGPUSQLStatement(source
|
|
119
|
-
return new GPUSQLQuery(
|
|
182
|
+
const statement = parseGPUSQLStatement(source);
|
|
183
|
+
return new GPUSQLQuery(
|
|
184
|
+
source,
|
|
185
|
+
buildGPUSQLPlan(this.tables, statement, options.parameters ?? {})
|
|
186
|
+
);
|
|
120
187
|
}
|
|
121
188
|
}
|
|
122
189
|
|
|
@@ -124,71 +191,260 @@ export class GPUSQLContext {
|
|
|
124
191
|
export class GPUSQLQuery {
|
|
125
192
|
/** Original application-owned SQL text, retained solely for diagnostics and inspection. */
|
|
126
193
|
readonly sql: string;
|
|
127
|
-
private readonly plan:
|
|
194
|
+
private readonly plan: GPUSQLBoundPlan;
|
|
128
195
|
|
|
129
196
|
/** @internal */
|
|
130
|
-
constructor(sql: string, plan:
|
|
197
|
+
constructor(sql: string, plan: GPUSQLBoundPlan) {
|
|
131
198
|
this.sql = sql;
|
|
132
199
|
this.plan = plan;
|
|
133
200
|
Object.freeze(this);
|
|
134
201
|
}
|
|
135
202
|
|
|
203
|
+
/** Returns a frozen plan description without allocating GPU resources. */
|
|
204
|
+
explain(): GPUSQLExplanation {
|
|
205
|
+
return this.plan.explanation;
|
|
206
|
+
}
|
|
207
|
+
|
|
136
208
|
/** Compiles existing dataframe operations into the caller-owned GPU command graph. */
|
|
137
209
|
compile(graph: GPUCommandGraph<GPUDataFrameQueryParameters>): CompiledGPUDataFrameQuery {
|
|
138
|
-
return this.plan.compile(graph);
|
|
210
|
+
return this.plan.plan.compile(graph);
|
|
139
211
|
}
|
|
140
212
|
}
|
|
141
213
|
|
|
142
214
|
function buildGPUSQLPlan(
|
|
143
215
|
tables: Readonly<Record<string, GPUDataFrame>>,
|
|
144
|
-
statement: GPUSQLStatement
|
|
145
|
-
|
|
216
|
+
statement: GPUSQLStatement,
|
|
217
|
+
parameters: GPUDataFrameQueryParameters
|
|
218
|
+
): GPUSQLBoundPlan {
|
|
146
219
|
const frame = tables[statement.table.toLowerCase()];
|
|
147
220
|
if (!frame) throw new Error(`GPUSQL table "${statement.table}" is not registered`);
|
|
148
221
|
let query = new GPUDataFrameQuery(frame, [], frame.columnNames) as unknown as GPUSQLDynamicQuery;
|
|
149
222
|
const qualifier = statement.alias ?? statement.table;
|
|
150
|
-
const resolve = (
|
|
223
|
+
const resolve = (reference: GPUSQLColumnReference): string =>
|
|
224
|
+
resolveGPUSQLColumn(reference, qualifier, frame.columnNames);
|
|
151
225
|
if (statement.predicate) {
|
|
152
226
|
query = query.filter(
|
|
153
|
-
new GPUExpression<boolean, string>(
|
|
227
|
+
new GPUExpression<boolean, string>(
|
|
228
|
+
lowerSQLExpression(statement.predicate, parameters, resolve)
|
|
229
|
+
)
|
|
154
230
|
);
|
|
155
231
|
}
|
|
156
232
|
|
|
233
|
+
/** Captures the route chosen by the same branch that supplies the executable plan. */
|
|
234
|
+
const describe = (
|
|
235
|
+
plan: GPUSQLCompiledPlan,
|
|
236
|
+
execution: GPUSQLExecution,
|
|
237
|
+
columns: readonly string[],
|
|
238
|
+
workingColumns: readonly string[] = columns,
|
|
239
|
+
keyCount = 0
|
|
240
|
+
): GPUSQLBoundPlan => ({
|
|
241
|
+
plan,
|
|
242
|
+
explanation: Object.freeze({
|
|
243
|
+
table: statement.table,
|
|
244
|
+
filtered: Boolean(statement.predicate),
|
|
245
|
+
execution,
|
|
246
|
+
columns: Object.freeze([...columns]),
|
|
247
|
+
workingColumns: Object.freeze([...workingColumns]),
|
|
248
|
+
keyCount,
|
|
249
|
+
...(statement.join
|
|
250
|
+
? {join: Object.freeze({table: statement.join.table, type: statement.join.type})}
|
|
251
|
+
: {}),
|
|
252
|
+
...(statement.limit !== undefined || statement.offset !== undefined
|
|
253
|
+
? {page: Object.freeze({offset: statement.offset ?? 0, limit: statement.limit})}
|
|
254
|
+
: {})
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
|
|
157
258
|
const aggregates = statement.items.filter(item => item.aggregate);
|
|
158
259
|
if (aggregates.length > 0) {
|
|
159
|
-
if (
|
|
160
|
-
|
|
260
|
+
if (
|
|
261
|
+
statement.join ||
|
|
262
|
+
statement.orderBy ||
|
|
263
|
+
statement.limit !== undefined ||
|
|
264
|
+
statement.offset !== undefined
|
|
265
|
+
) {
|
|
266
|
+
throw new Error('GPUSQL aggregate queries do not yet support joins, ordering, or pagination');
|
|
161
267
|
}
|
|
162
268
|
const definitions: GPUSQLAggregationDefinitions = {};
|
|
269
|
+
const reservedNames = new Set(frame.columnNames);
|
|
270
|
+
const outputNames = new Map<GPUSQLSelectItem, string>();
|
|
271
|
+
let inputIndex = 0;
|
|
163
272
|
for (const item of aggregates) {
|
|
164
|
-
const
|
|
273
|
+
const input =
|
|
274
|
+
item.aggregateInput && lowerSQLExpression(item.aggregateInput, parameters, resolve);
|
|
275
|
+
let inputColumn = input?.kind === 'column' ? input.name : undefined;
|
|
276
|
+
if (input && input.kind !== 'column') {
|
|
277
|
+
if (!item.alias) {
|
|
278
|
+
throw new Error('GPUSQL computed aggregate inputs require an explicit AS alias');
|
|
279
|
+
}
|
|
280
|
+
do {
|
|
281
|
+
inputColumn = '__sqlAggregateInput' + inputIndex++;
|
|
282
|
+
} while (reservedNames.has(inputColumn));
|
|
283
|
+
reservedNames.add(inputColumn);
|
|
284
|
+
query = query.withColumn(inputColumn, new GPUExpression<number | null, string>(input));
|
|
285
|
+
}
|
|
286
|
+
const name = item.alias ?? `${item.aggregate}_${inputColumn ?? 'all'}`;
|
|
287
|
+
outputNames.set(item, name);
|
|
165
288
|
if (definitions[name]) throw new Error(`GPUSQL aggregate alias "${name}" is duplicated`);
|
|
166
289
|
definitions[name] =
|
|
167
290
|
item.aggregate === 'count'
|
|
168
|
-
?
|
|
169
|
-
|
|
291
|
+
? inputColumn === undefined
|
|
292
|
+
? 'count'
|
|
293
|
+
: {count: inputColumn}
|
|
294
|
+
: ({[item.aggregate!]: inputColumn!} as
|
|
170
295
|
| {sum: string}
|
|
171
296
|
| {min: string}
|
|
172
297
|
| {max: string}
|
|
173
298
|
| {mean: string});
|
|
174
299
|
}
|
|
175
|
-
if (statement.groupBy) {
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
300
|
+
if (statement.groupBy !== undefined) {
|
|
301
|
+
const keyItems = statement.items.filter(item => !item.aggregate);
|
|
302
|
+
const occupied = new Set(Object.keys(definitions));
|
|
303
|
+
const selectedKeys = new Map<string, {source: string; output: string}>();
|
|
304
|
+
const keyByItem = new Map<GPUSQLSelectItem, {source: string; output: string}>();
|
|
305
|
+
/** Reuses a source field or creates an internal column for a computed group key. */
|
|
306
|
+
|
|
307
|
+
const materializeKey = (expression: GPUExpressionNode): string => {
|
|
308
|
+
if (expression.kind === 'column') return expression.name;
|
|
309
|
+
let source: string;
|
|
310
|
+
do {
|
|
311
|
+
source = '__sqlGroupKey' + inputIndex++;
|
|
312
|
+
} while (reservedNames.has(source));
|
|
313
|
+
reservedNames.add(source);
|
|
314
|
+
query = query.withColumn(source, new GPUExpression<number | null, string>(expression));
|
|
315
|
+
return source;
|
|
316
|
+
};
|
|
317
|
+
for (const item of keyItems) {
|
|
318
|
+
if (!item.expression) {
|
|
319
|
+
throw new Error('GPUSQL grouped SELECT requires explicit key expressions');
|
|
320
|
+
}
|
|
321
|
+
const expression = lowerSQLExpression(item.expression, parameters, resolve);
|
|
322
|
+
const output = item.alias ?? (expression.kind === 'column' ? expression.name : undefined);
|
|
323
|
+
if (!output) throw new Error('GPUSQL computed group keys require an explicit AS alias');
|
|
324
|
+
if (occupied.has(output)) {
|
|
325
|
+
throw new Error('GPUSQL output column "' + output + '" is duplicated');
|
|
326
|
+
}
|
|
327
|
+
const signature = JSON.stringify(expression);
|
|
328
|
+
if (selectedKeys.has(signature)) {
|
|
329
|
+
throw new Error('GPUSQL grouped queries must select each GROUP BY key exactly once');
|
|
330
|
+
}
|
|
331
|
+
const key = {source: materializeKey(expression), output};
|
|
332
|
+
selectedKeys.set(signature, key);
|
|
333
|
+
keyByItem.set(item, key);
|
|
334
|
+
occupied.add(output);
|
|
335
|
+
outputNames.set(item, output);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const hiddenKeys = new Map<string, {source: string}>();
|
|
339
|
+
const keys = statement.groupBy.map<{source: string; output?: string}>(reference => {
|
|
340
|
+
if (reference.type === 'Literal' && typeof reference.value === 'number') {
|
|
341
|
+
const item = getGPUSQLProjectionItem(statement.items, reference.value, 'GROUP BY');
|
|
342
|
+
const key = keyByItem.get(item);
|
|
343
|
+
if (!key) throw new Error('GPUSQL GROUP BY position must reference a group key directly');
|
|
344
|
+
return key;
|
|
345
|
+
}
|
|
346
|
+
if (
|
|
347
|
+
reference.type === 'Identifier' &&
|
|
348
|
+
!('gpuSQLParameter' in reference) &&
|
|
349
|
+
!frame.columnNames.includes(reference.name)
|
|
350
|
+
) {
|
|
351
|
+
const alias = keyItems.find(item => item.alias === reference.name);
|
|
352
|
+
if (alias) return keyByItem.get(alias)!;
|
|
353
|
+
}
|
|
354
|
+
const expression = lowerSQLExpression(reference, parameters, resolve);
|
|
355
|
+
const signature = JSON.stringify(expression);
|
|
356
|
+
const existing = selectedKeys.get(signature) ?? hiddenKeys.get(signature);
|
|
357
|
+
if (existing) return existing;
|
|
358
|
+
const key = {source: materializeKey(expression)};
|
|
359
|
+
hiddenKeys.set(signature, key);
|
|
360
|
+
return key;
|
|
361
|
+
});
|
|
362
|
+
const uniqueKeys = new Set(keys);
|
|
363
|
+
if (uniqueKeys.size !== keys.length) {
|
|
364
|
+
throw new Error('GPUSQL GROUP BY keys must be distinct');
|
|
365
|
+
}
|
|
366
|
+
if ([...selectedKeys.values()].some(key => !uniqueKeys.has(key))) {
|
|
367
|
+
throw new Error(
|
|
368
|
+
'GPUSQL grouped queries must group by every non-aggregate SELECT expression'
|
|
369
|
+
);
|
|
183
370
|
}
|
|
184
|
-
|
|
371
|
+
|
|
372
|
+
const {predicates, selectedColumns, derivedColumns} = query;
|
|
373
|
+
const columns = statement.items.map(item => outputNames.get(item)!);
|
|
374
|
+
const normalized = normalizeGPUDataFrameAggregations<GPUTypeMap, string, GPUTypeMap>(
|
|
375
|
+
{...query, source: frame},
|
|
376
|
+
keys[0].output,
|
|
377
|
+
definitions
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
if (keys.length > 1 || keys[0].output === undefined || !frame.dictionaries[keys[0].source]) {
|
|
381
|
+
for (const {source} of keys) {
|
|
382
|
+
const format = frame.schema.fields.find(field => field.name === source)?.format;
|
|
383
|
+
if (
|
|
384
|
+
!derivedColumns.some(column => column.name === source) &&
|
|
385
|
+
format !== 'uint32' &&
|
|
386
|
+
format !== 'sint32' &&
|
|
387
|
+
format !== 'float32'
|
|
388
|
+
) {
|
|
389
|
+
throw new Error('GPUSQL GROUP BY requires 32-bit numeric or dictionary keys');
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return describe(
|
|
393
|
+
{
|
|
394
|
+
compile: graph =>
|
|
395
|
+
compileGPUDataFrameObservedAggregation(
|
|
396
|
+
frame,
|
|
397
|
+
predicates,
|
|
398
|
+
selectedColumns,
|
|
399
|
+
derivedColumns,
|
|
400
|
+
keys,
|
|
401
|
+
normalized,
|
|
402
|
+
graph,
|
|
403
|
+
columns
|
|
404
|
+
)
|
|
405
|
+
},
|
|
406
|
+
'observed-grouping',
|
|
407
|
+
columns,
|
|
408
|
+
selectedColumns,
|
|
409
|
+
keys.length
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const [key] = keys;
|
|
414
|
+
const {groupCount} = query.groupBy(key.source);
|
|
415
|
+
return describe(
|
|
416
|
+
{
|
|
417
|
+
compile: graph =>
|
|
418
|
+
compileGPUDataFrameGroupedAggregation(
|
|
419
|
+
frame,
|
|
420
|
+
predicates,
|
|
421
|
+
selectedColumns,
|
|
422
|
+
derivedColumns,
|
|
423
|
+
key.source,
|
|
424
|
+
groupCount,
|
|
425
|
+
normalized,
|
|
426
|
+
graph,
|
|
427
|
+
{key: key.output!, columns}
|
|
428
|
+
)
|
|
429
|
+
},
|
|
430
|
+
'dense-grouping',
|
|
431
|
+
columns,
|
|
432
|
+
selectedColumns,
|
|
433
|
+
1
|
|
434
|
+
);
|
|
185
435
|
}
|
|
186
436
|
if (aggregates.length !== statement.items.length) {
|
|
187
437
|
throw new Error('GPUSQL global aggregates cannot mix ordinary source columns');
|
|
188
438
|
}
|
|
189
|
-
return
|
|
439
|
+
return describe(
|
|
440
|
+
query.aggregate(definitions),
|
|
441
|
+
'global-aggregation',
|
|
442
|
+
statement.items.map(item => outputNames.get(item)!),
|
|
443
|
+
query.selectedColumns
|
|
444
|
+
);
|
|
190
445
|
}
|
|
191
|
-
if (statement.groupBy
|
|
446
|
+
if (statement.groupBy !== undefined)
|
|
447
|
+
throw new Error('GPUSQL GROUP BY requires at least one aggregation');
|
|
192
448
|
|
|
193
449
|
const selected: string[] = [];
|
|
194
450
|
for (const item of statement.items) {
|
|
@@ -198,7 +454,7 @@ function buildGPUSQLPlan(
|
|
|
198
454
|
selected.push(...frame.columnNames);
|
|
199
455
|
continue;
|
|
200
456
|
}
|
|
201
|
-
const node =
|
|
457
|
+
const node = lowerSQLExpression(item.expression!, parameters, resolve);
|
|
202
458
|
const name = item.alias ?? (node.kind === 'column' ? node.name : undefined);
|
|
203
459
|
if (!name) throw new Error('GPUSQL computed SELECT expressions require an explicit AS alias');
|
|
204
460
|
if (selected.includes(name)) throw new Error(`GPUSQL output column "${name}" is duplicated`);
|
|
@@ -212,110 +468,188 @@ function buildGPUSQLPlan(
|
|
|
212
468
|
}
|
|
213
469
|
|
|
214
470
|
if (statement.join) {
|
|
215
|
-
if (statement.orderBy || statement.limit !== undefined) {
|
|
216
|
-
throw new Error('GPUSQL joined results do not yet support ORDER BY or
|
|
471
|
+
if (statement.orderBy || statement.limit !== undefined || statement.offset !== undefined) {
|
|
472
|
+
throw new Error('GPUSQL joined results do not yet support ORDER BY or pagination');
|
|
217
473
|
}
|
|
218
474
|
const right = tables[statement.join.table.toLowerCase()];
|
|
219
475
|
if (!right) throw new Error(`GPUSQL table "${statement.join.table}" is not registered`);
|
|
220
|
-
const leftKey = resolve(statement.join.left);
|
|
221
476
|
const rightQualifier = statement.join.alias ?? statement.join.table;
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
case 'semi':
|
|
232
|
-
return query.semiJoin(right, options);
|
|
233
|
-
case 'anti':
|
|
234
|
-
return query.antiJoin(right, options);
|
|
235
|
-
default:
|
|
236
|
-
return query.innerJoin(right, options);
|
|
477
|
+
const {left: firstOperand, right: secondOperand} = statement.join;
|
|
478
|
+
const matchesLeft = (reference: GPUSQLColumnReference) =>
|
|
479
|
+
matchesGPUSQLColumn(reference, qualifier, frame.columnNames);
|
|
480
|
+
const matchesRight = (reference: GPUSQLColumnReference) =>
|
|
481
|
+
matchesGPUSQLColumn(reference, rightQualifier, right.columnNames);
|
|
482
|
+
const forward = matchesLeft(firstOperand) && matchesRight(secondOperand);
|
|
483
|
+
const reversed = matchesLeft(secondOperand) && matchesRight(firstOperand);
|
|
484
|
+
if (forward && reversed) {
|
|
485
|
+
throw new Error('GPUSQL JOIN key references are ambiguous; qualify the columns');
|
|
237
486
|
}
|
|
487
|
+
const leftKey = resolve(reversed ? secondOperand : firstOperand);
|
|
488
|
+
const rightKey = resolveGPUSQLColumn(
|
|
489
|
+
reversed ? firstOperand : secondOperand,
|
|
490
|
+
rightQualifier,
|
|
491
|
+
right.columnNames
|
|
492
|
+
);
|
|
493
|
+
const keyIsSelected = selected.includes(leftKey);
|
|
494
|
+
const workingColumns = keyIsSelected ? selected : [...selected, leftKey];
|
|
495
|
+
const workingQuery = query.select(workingColumns);
|
|
496
|
+
const joinType = statement.join.type;
|
|
497
|
+
const method = {
|
|
498
|
+
left: 'leftJoin',
|
|
499
|
+
semi: 'semiJoin',
|
|
500
|
+
anti: 'antiJoin',
|
|
501
|
+
inner: 'innerJoin'
|
|
502
|
+
} as const;
|
|
503
|
+
const join = workingQuery[method[joinType]](right, {leftOn: leftKey, rightOn: rightKey});
|
|
504
|
+
if (keyIsSelected) return describe(join, 'unique-right-join', selected, workingColumns, 1);
|
|
505
|
+
|
|
506
|
+
const {predicates, derivedColumns} = workingQuery;
|
|
507
|
+
return describe(
|
|
508
|
+
{
|
|
509
|
+
compile: graph =>
|
|
510
|
+
compileGPUDataFrameJoin(
|
|
511
|
+
frame,
|
|
512
|
+
predicates,
|
|
513
|
+
workingColumns,
|
|
514
|
+
derivedColumns,
|
|
515
|
+
right,
|
|
516
|
+
join.options,
|
|
517
|
+
joinType,
|
|
518
|
+
graph,
|
|
519
|
+
selected
|
|
520
|
+
)
|
|
521
|
+
},
|
|
522
|
+
'unique-right-join',
|
|
523
|
+
selected,
|
|
524
|
+
workingColumns,
|
|
525
|
+
1
|
|
526
|
+
);
|
|
238
527
|
}
|
|
239
528
|
|
|
240
529
|
if (statement.orderBy) {
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
530
|
+
const workingColumns = new Set(selected);
|
|
531
|
+
const resolvedKeys = statement.orderBy.map(({expression, direction, nulls}) => {
|
|
532
|
+
let orderColumn: string;
|
|
533
|
+
if (expression.type === 'Literal' && typeof expression.value === 'number') {
|
|
534
|
+
orderColumn = getGPUSQLProjectionItem(selected, expression.value, 'ORDER BY');
|
|
535
|
+
} else if (
|
|
536
|
+
expression.type === 'Identifier' &&
|
|
537
|
+
!('gpuSQLParameter' in expression) &&
|
|
538
|
+
selected.includes(expression.name)
|
|
539
|
+
) {
|
|
540
|
+
orderColumn = expression.name;
|
|
541
|
+
} else {
|
|
542
|
+
const sortExpression = lowerSQLExpression(expression, parameters, resolve);
|
|
543
|
+
if (sortExpression.kind === 'column') {
|
|
544
|
+
orderColumn = sortExpression.name;
|
|
545
|
+
} else {
|
|
546
|
+
orderColumn = '__sqlOrderKey';
|
|
547
|
+
while (frame.columnNames.includes(orderColumn) || workingColumns.has(orderColumn)) {
|
|
548
|
+
orderColumn += '_';
|
|
549
|
+
}
|
|
550
|
+
query = query.withColumn(
|
|
551
|
+
orderColumn,
|
|
552
|
+
new GPUExpression<number | null, string>(sortExpression)
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
workingColumns.add(orderColumn);
|
|
557
|
+
return {column: orderColumn, direction, nulls};
|
|
249
558
|
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
559
|
+
|
|
560
|
+
const columns = [...workingColumns];
|
|
561
|
+
const workingQuery = query.select(columns);
|
|
562
|
+
const plans = resolvedKeys.map(({column, direction, nulls}) => ({
|
|
563
|
+
column,
|
|
564
|
+
plan: workingQuery.sortByGlobal(column, {direction, nulls})
|
|
565
|
+
}));
|
|
566
|
+
const [{column, plan: sort}, ...secondary] = plans;
|
|
567
|
+
const page =
|
|
568
|
+
statement.limit === undefined && statement.offset === undefined
|
|
569
|
+
? sort
|
|
570
|
+
: sort.page(statement.offset ?? 0, statement.limit);
|
|
571
|
+
const projection = columns.length > selected.length ? selected : undefined;
|
|
572
|
+
if (!projection && secondary.length === 0)
|
|
573
|
+
return describe(page, 'global-sort', selected, columns, plans.length);
|
|
574
|
+
|
|
575
|
+
const {predicates, derivedColumns} = workingQuery;
|
|
576
|
+
const additionalKeys: GPUGlobalSortKey[] = secondary.map(key => ({
|
|
577
|
+
column: key.column,
|
|
578
|
+
options: key.plan.options
|
|
579
|
+
}));
|
|
580
|
+
return describe(
|
|
581
|
+
{
|
|
582
|
+
compile: graph =>
|
|
583
|
+
compileGPUDataFrameGlobalSort(
|
|
584
|
+
frame,
|
|
585
|
+
predicates,
|
|
586
|
+
columns,
|
|
587
|
+
derivedColumns,
|
|
588
|
+
column,
|
|
589
|
+
page.options,
|
|
590
|
+
graph,
|
|
591
|
+
projection,
|
|
592
|
+
additionalKeys
|
|
593
|
+
)
|
|
594
|
+
},
|
|
595
|
+
'global-sort',
|
|
596
|
+
selected,
|
|
597
|
+
columns,
|
|
598
|
+
plans.length
|
|
599
|
+
);
|
|
257
600
|
}
|
|
258
|
-
|
|
601
|
+
if (statement.limit !== undefined || statement.offset !== undefined)
|
|
602
|
+
throw new Error('GPUSQL LIMIT or OFFSET currently requires ORDER BY');
|
|
603
|
+
return describe(query.select(selected), 'projection', selected);
|
|
259
604
|
}
|
|
260
605
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
606
|
+
/** Formats the source spelling for diagnostics. */
|
|
607
|
+
function formatGPUSQLColumn({name, qualifier}: GPUSQLColumnReference): string {
|
|
608
|
+
return qualifier === undefined ? name : qualifier + '.' + name;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** Checks whether a join operand can bind to one side of the join. */
|
|
612
|
+
function matchesGPUSQLColumn(
|
|
613
|
+
reference: GPUSQLColumnReference,
|
|
614
|
+
qualifier: string,
|
|
615
|
+
columns: readonly string[]
|
|
616
|
+
): boolean {
|
|
617
|
+
return (
|
|
618
|
+
(reference.qualifier === undefined ||
|
|
619
|
+
reference.qualifier.toLowerCase() === qualifier.toLowerCase()) &&
|
|
620
|
+
columns.includes(reference.name)
|
|
621
|
+
);
|
|
269
622
|
}
|
|
270
623
|
|
|
271
|
-
|
|
272
|
-
|
|
624
|
+
/** Binds a parsed reference to an exact dataframe field. */
|
|
625
|
+
function resolveGPUSQLColumn(
|
|
626
|
+
reference: GPUSQLColumnReference,
|
|
627
|
+
qualifier: string,
|
|
628
|
+
columns: readonly string[]
|
|
629
|
+
): string {
|
|
273
630
|
if (
|
|
274
|
-
|
|
275
|
-
|
|
631
|
+
reference.qualifier !== undefined &&
|
|
632
|
+
reference.qualifier.toLowerCase() !== qualifier.toLowerCase()
|
|
276
633
|
) {
|
|
277
|
-
throw new Error(
|
|
634
|
+
throw new Error(
|
|
635
|
+
'GPUSQL column "' + formatGPUSQLColumn(reference) + '" has an unknown table qualifier'
|
|
636
|
+
);
|
|
278
637
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return requested;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function resolveGPUSQLExpression(
|
|
285
|
-
expression: GPUExpressionNode,
|
|
286
|
-
resolve: (name: string) => string
|
|
287
|
-
): GPUExpressionNode {
|
|
288
|
-
switch (expression.kind) {
|
|
289
|
-
case 'column':
|
|
290
|
-
return {kind: 'column', name: resolve(expression.name)};
|
|
291
|
-
case 'unary':
|
|
292
|
-
return {...expression, operand: resolveGPUSQLExpression(expression.operand, resolve)};
|
|
293
|
-
case 'binary':
|
|
294
|
-
return {
|
|
295
|
-
...expression,
|
|
296
|
-
left: resolveGPUSQLExpression(expression.left, resolve),
|
|
297
|
-
right: resolveGPUSQLExpression(expression.right, resolve)
|
|
298
|
-
};
|
|
299
|
-
default:
|
|
300
|
-
return expression;
|
|
638
|
+
if (!columns.includes(reference.name)) {
|
|
639
|
+
throw new Error('GPUSQL column "' + formatGPUSQLColumn(reference) + '" does not exist');
|
|
301
640
|
}
|
|
641
|
+
return reference.name;
|
|
302
642
|
}
|
|
303
643
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
parameters: GPUDataFrameQueryParameters
|
|
307
|
-
): GPUSQLStatement {
|
|
644
|
+
/** Parses the SQL subset supported by the GPU relational planner. */
|
|
645
|
+
function parseGPUSQLStatement(source: string): GPUSQLStatement {
|
|
308
646
|
const statement = parseSQLSelectStatement(source, {
|
|
309
647
|
parseParameter: name => ({type: 'Identifier', name, gpuSQLParameter: true})
|
|
310
648
|
});
|
|
311
|
-
if (statement.offset !== undefined
|
|
312
|
-
|
|
313
|
-
if ((statement.groupBy?.length ?? 0) > 1) {
|
|
314
|
-
throw new Error('GPUSQL currently supports one GROUP BY column');
|
|
315
|
-
}
|
|
316
|
-
if ((statement.orderBy?.length ?? 0) > 1) {
|
|
317
|
-
throw new Error('GPUSQL currently supports one ORDER BY column');
|
|
649
|
+
if (statement.offset !== undefined && statement.offset > 0xffffffff) {
|
|
650
|
+
throw new Error('GPUSQL OFFSET must fit an unsigned 32-bit row count');
|
|
318
651
|
}
|
|
652
|
+
if (statement.joins.length > 1) throw new Error('GPUSQL currently supports one JOIN');
|
|
319
653
|
if (statement.limit !== undefined && statement.limit > 0xffffffff) {
|
|
320
654
|
throw new Error('GPUSQL LIMIT must fit an unsigned 32-bit row count');
|
|
321
655
|
}
|
|
@@ -334,18 +668,18 @@ function parseGPUSQLStatement(
|
|
|
334
668
|
}
|
|
335
669
|
const argument = expression.arguments[0] as Expression;
|
|
336
670
|
const wildcard = argument.type === 'Identifier' && argument['sqlWildcard'] === true;
|
|
337
|
-
if (
|
|
671
|
+
if (wildcard && aggregate !== 'count') {
|
|
338
672
|
throw new Error('GPUSQL only permits COUNT(*) as a wildcard aggregation');
|
|
339
673
|
}
|
|
340
674
|
return {
|
|
341
675
|
aggregate,
|
|
342
|
-
...(wildcard ? {} : {
|
|
676
|
+
...(wildcard ? {} : {aggregateInput: argument}),
|
|
343
677
|
alias
|
|
344
678
|
};
|
|
345
679
|
}
|
|
346
680
|
}
|
|
347
681
|
}
|
|
348
|
-
return {expression
|
|
682
|
+
return {expression, alias};
|
|
349
683
|
}) ?? [{star: true}];
|
|
350
684
|
const join = statement.joins[0];
|
|
351
685
|
if (statement.from.inputTable !== undefined || join?.table.inputTable !== undefined) {
|
|
@@ -366,32 +700,46 @@ function parseGPUSQLStatement(
|
|
|
366
700
|
right: readGPUSQLColumn(join.on.right)
|
|
367
701
|
};
|
|
368
702
|
}
|
|
369
|
-
const sort = statement.orderBy?.[0];
|
|
370
703
|
return {
|
|
371
704
|
items,
|
|
372
705
|
table: statement.from.name,
|
|
373
706
|
alias: statement.from.alias,
|
|
374
707
|
join: loweredJoin,
|
|
375
|
-
predicate: statement.where
|
|
376
|
-
groupBy: statement.groupBy?.
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
708
|
+
predicate: statement.where as Expression | undefined,
|
|
709
|
+
groupBy: statement.groupBy?.length
|
|
710
|
+
? statement.groupBy.map(expression => expression as Expression)
|
|
711
|
+
: undefined,
|
|
712
|
+
orderBy: statement.orderBy?.length
|
|
713
|
+
? statement.orderBy.map(sort => ({
|
|
714
|
+
expression: sort.expression as Expression,
|
|
715
|
+
direction: sort.direction === 'desc' ? 'descending' : 'ascending',
|
|
716
|
+
nulls: sort.nulls
|
|
717
|
+
}))
|
|
718
|
+
: undefined,
|
|
719
|
+
offset: statement.offset,
|
|
382
720
|
limit: statement.limit
|
|
383
721
|
};
|
|
384
722
|
}
|
|
385
723
|
|
|
724
|
+
/** Resolves a one-based projection position with a clause-specific diagnostic. */
|
|
725
|
+
function getGPUSQLProjectionItem<Item>(
|
|
726
|
+
projection: readonly Item[],
|
|
727
|
+
position: number,
|
|
728
|
+
clause: 'ORDER BY' | 'GROUP BY'
|
|
729
|
+
): Item {
|
|
730
|
+
if (!Number.isSafeInteger(position) || position < 1 || position > projection.length) {
|
|
731
|
+
throw new Error('GPUSQL ' + clause + ' position must be a one-based SELECT column number');
|
|
732
|
+
}
|
|
733
|
+
return projection[position - 1];
|
|
734
|
+
}
|
|
735
|
+
|
|
386
736
|
/** Reads a source column name or a two-part qualified column reference. */
|
|
387
|
-
function readGPUSQLColumn(
|
|
737
|
+
function readGPUSQLColumn(
|
|
738
|
+
node: Extract<Expression, {type: 'BinaryExpression'}>['left']
|
|
739
|
+
): GPUSQLColumnReference {
|
|
388
740
|
const expression = node as Expression;
|
|
389
|
-
if (
|
|
390
|
-
expression.
|
|
391
|
-
!('gpuSQLParameter' in expression) &&
|
|
392
|
-
!expression.name.includes('.')
|
|
393
|
-
) {
|
|
394
|
-
return expression.name;
|
|
741
|
+
if (expression.type === 'Identifier' && !('gpuSQLParameter' in expression)) {
|
|
742
|
+
return {name: expression.name};
|
|
395
743
|
}
|
|
396
744
|
if (expression.type === 'MemberExpression' && !expression.computed) {
|
|
397
745
|
const object = expression.object as Expression;
|
|
@@ -400,95 +748,59 @@ function readGPUSQLColumn(node: Extract<Expression, {type: 'BinaryExpression'}>[
|
|
|
400
748
|
object.type === 'Identifier' &&
|
|
401
749
|
property.type === 'Identifier' &&
|
|
402
750
|
!('gpuSQLParameter' in object) &&
|
|
403
|
-
!
|
|
404
|
-
!property.name.includes('.')
|
|
751
|
+
!('gpuSQLParameter' in property)
|
|
405
752
|
) {
|
|
406
|
-
return
|
|
753
|
+
return {qualifier: object.name, name: property.name};
|
|
407
754
|
}
|
|
408
755
|
}
|
|
409
756
|
throw new Error('GPUSQL expected a table or column identifier');
|
|
410
757
|
}
|
|
411
758
|
|
|
412
|
-
const SQL_BINARY_OPERATORS: Readonly<
|
|
413
|
-
Partial<Record<string, Extract<GPUExpressionNode, {kind: 'binary'}>['operator']>>
|
|
414
|
-
> = {
|
|
415
|
-
'||': 'or',
|
|
416
|
-
'&&': 'and',
|
|
417
|
-
'==': 'equal',
|
|
418
|
-
'!=': 'not-equal',
|
|
419
|
-
'>': 'greater-than',
|
|
420
|
-
'>=': 'greater-than-or-equal',
|
|
421
|
-
'<': 'less-than',
|
|
422
|
-
'<=': 'less-than-or-equal',
|
|
423
|
-
'+': 'add',
|
|
424
|
-
'-': 'subtract',
|
|
425
|
-
'*': 'multiply',
|
|
426
|
-
'/': 'divide'
|
|
427
|
-
};
|
|
428
|
-
|
|
429
759
|
function lowerSQLExpression(
|
|
430
760
|
node: Extract<Expression, {type: 'BinaryExpression'}>['left'],
|
|
431
|
-
parameters: GPUDataFrameQueryParameters
|
|
761
|
+
parameters: GPUDataFrameQueryParameters,
|
|
762
|
+
resolve: (reference: GPUSQLColumnReference) => string
|
|
432
763
|
): GPUExpressionNode {
|
|
433
|
-
// math.gl types child nodes as generic expressions, though the SQL parser emits the AST union.
|
|
434
764
|
const expression = node as Expression;
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
case 'MemberExpression':
|
|
445
|
-
return column(readGPUSQLColumn(expression)).node;
|
|
446
|
-
case 'Literal': {
|
|
447
|
-
const value = expression.value;
|
|
448
|
-
if (
|
|
449
|
-
value === null ||
|
|
450
|
-
typeof value === 'boolean' ||
|
|
451
|
-
(typeof value === 'number' && Number.isFinite(value))
|
|
452
|
-
) {
|
|
453
|
-
return literal(value).node;
|
|
765
|
+
try {
|
|
766
|
+
return lowerPortableExpression(expression, leaf => {
|
|
767
|
+
if (leaf.type === 'Identifier' && 'gpuSQLParameter' in leaf) {
|
|
768
|
+
const name = leaf.name;
|
|
769
|
+
if (!Object.hasOwn(parameters, name)) {
|
|
770
|
+
throw new Error(`GPUSQL parameter ":${name}" requires an explicit default`);
|
|
771
|
+
}
|
|
772
|
+
return parameter(name, parameters[name]).node;
|
|
454
773
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
case 'UnaryExpression':
|
|
458
|
-
if (expression.operator === '!' || expression.operator === '-') {
|
|
459
|
-
return {
|
|
460
|
-
kind: 'unary',
|
|
461
|
-
operator: expression.operator === '!' ? 'not' : 'negate',
|
|
462
|
-
operand: lowerSQLExpression(expression.argument, parameters)
|
|
463
|
-
};
|
|
774
|
+
if (leaf.type === 'Identifier' || leaf.type === 'MemberExpression') {
|
|
775
|
+
return column(resolve(readGPUSQLColumn(leaf))).node;
|
|
464
776
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
777
|
+
if (leaf.type === 'CallExpression' && leaf.callee.type === 'Identifier') {
|
|
778
|
+
const name = leaf.callee['name'];
|
|
779
|
+
const functionName =
|
|
780
|
+
typeof name === 'string' && leaf['sqlFunction'] === true ? name.toLowerCase() : name;
|
|
781
|
+
if (
|
|
782
|
+
name !== 'isNull' &&
|
|
783
|
+
name !== 'isNotNull' &&
|
|
784
|
+
name !== 'in' &&
|
|
785
|
+
name !== 'cast' &&
|
|
786
|
+
functionName !== 'coalesce' &&
|
|
787
|
+
functionName !== 'nullif' &&
|
|
788
|
+
!isGPUScalarFunction(functionName)
|
|
789
|
+
) {
|
|
790
|
+
throw new Error(`GPUSQL does not support SQL expression "${name}"`);
|
|
791
|
+
}
|
|
475
792
|
}
|
|
476
|
-
|
|
793
|
+
return undefined;
|
|
794
|
+
});
|
|
795
|
+
} catch (error) {
|
|
796
|
+
if (
|
|
797
|
+
error instanceof Error &&
|
|
798
|
+
error.message === 'Unsupported portable GPU dataframe expression'
|
|
799
|
+
) {
|
|
800
|
+
throw new Error(`GPUSQL does not support SQL expression "${expression.type}"`, {
|
|
801
|
+
cause: error
|
|
802
|
+
});
|
|
477
803
|
}
|
|
478
|
-
|
|
479
|
-
if (
|
|
480
|
-
expression.arguments.length === 1 &&
|
|
481
|
-
(expression.callee['name'] === 'isNull' || expression.callee['name'] === 'isNotNull')
|
|
482
|
-
) {
|
|
483
|
-
return {
|
|
484
|
-
kind: 'unary',
|
|
485
|
-
operator: expression.callee['name'] === 'isNull' ? 'is-null' : 'is-valid',
|
|
486
|
-
operand: lowerSQLExpression(expression.arguments[0], parameters)
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
default:
|
|
491
|
-
break;
|
|
804
|
+
throw error;
|
|
492
805
|
}
|
|
493
|
-
throw new Error(`GPUSQL does not support SQL expression "${expression.type}"`);
|
|
494
806
|
}
|