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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squirreling",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Squirreling Async SQL Engine",
5
5
  "author": "Hyperparam",
6
6
  "homepage": "https://hyperparam.app",
@@ -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, context) {
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
- // No WHERE in scan (scanColumn doesn't support filtering)
171
- if (scanNode.hints.where) return
170
+ const { limit, offset, where } = scanNode.hints
171
+ // scanColumn doesn't support filtering
172
+ if (where) return
172
173
 
173
- const table = context.tables[scanNode.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] = () => Promise.resolve(value)
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 {AsyncDataSource} table
230
- * @param {ColumnAggSpec} spec
231
- * @param {AbortSignal} [signal]
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()
package/src/types.d.ts CHANGED
@@ -84,6 +84,8 @@ export interface ScanOptions {
84
84
  */
85
85
  export interface ScanColumnOptions {
86
86
  column: string
87
+ limit?: number
88
+ offset?: number
87
89
  signal?: AbortSignal
88
90
  }
89
91