squirreling 0.11.0 → 0.11.1
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/package.json +1 -1
- package/src/execute/aggregates.js +14 -11
- package/src/types.d.ts +2 -0
package/package.json
CHANGED
|
@@ -161,16 +161,17 @@ export async function* executeScalarAggregate(plan, context) {
|
|
|
161
161
|
* @param {ExecuteContext} context
|
|
162
162
|
* @returns {AsyncGenerator<AsyncRow> | undefined}
|
|
163
163
|
*/
|
|
164
|
-
function tryColumnScanAggregate(plan,
|
|
164
|
+
function tryColumnScanAggregate(plan, { tables, signal }) {
|
|
165
165
|
// No HAVING support in fast path
|
|
166
166
|
if (plan.having) return
|
|
167
167
|
// Child must be a direct table scan
|
|
168
168
|
if (plan.child.type !== 'Scan') return
|
|
169
169
|
const scanNode = plan.child
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
const { limit, offset, where } = scanNode.hints
|
|
171
|
+
// scanColumn doesn't support filtering
|
|
172
|
+
if (where) return
|
|
172
173
|
|
|
173
|
-
const table =
|
|
174
|
+
const table = tables[scanNode.table]
|
|
174
175
|
if (!table?.scanColumn) return
|
|
175
176
|
|
|
176
177
|
// All columns must be simple aggregates on plain identifiers
|
|
@@ -190,9 +191,8 @@ function tryColumnScanAggregate(plan, context) {
|
|
|
190
191
|
const cells = {}
|
|
191
192
|
|
|
192
193
|
for (const spec of specs) {
|
|
193
|
-
const value = await scanColumnAggregate(table, spec, context.signal)
|
|
194
194
|
columns.push(spec.alias)
|
|
195
|
-
cells[spec.alias] = () =>
|
|
195
|
+
cells[spec.alias] = () => scanColumnAggregate({ table, spec, limit, offset, signal })
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
yield { columns, cells }
|
|
@@ -226,13 +226,16 @@ function extractColumnAggSpec({ expr, alias }) {
|
|
|
226
226
|
/**
|
|
227
227
|
* Scans a single column and computes an aggregate value.
|
|
228
228
|
*
|
|
229
|
-
* @param {
|
|
230
|
-
* @param {
|
|
231
|
-
* @param {
|
|
229
|
+
* @param {Object} options
|
|
230
|
+
* @param {AsyncDataSource} options.table
|
|
231
|
+
* @param {ColumnAggSpec} options.spec
|
|
232
|
+
* @param {number} [options.limit]
|
|
233
|
+
* @param {number} [options.offset]
|
|
234
|
+
* @param {AbortSignal} [options.signal]
|
|
232
235
|
* @returns {Promise<SqlPrimitive>}
|
|
233
236
|
*/
|
|
234
|
-
async function scanColumnAggregate(table, spec, signal) {
|
|
235
|
-
const values = table.scanColumn({ column: spec.column, signal })
|
|
237
|
+
async function scanColumnAggregate({ table, spec, limit, offset, signal }) {
|
|
238
|
+
const values = table.scanColumn({ column: spec.column, limit, offset, signal })
|
|
236
239
|
|
|
237
240
|
if (spec.funcName === 'COUNT' && spec.distinct) {
|
|
238
241
|
const seen = new Set()
|