UNPKG

@uwdata/mosaic-sql

Version:

SQL query construction and analysis.

82 lines 3.05 kB
import type { ExprVarArgs, OrderByExpr } from '../types.js'; import type { WindowFrameNode } from './window-frame.js'; import { ExprNode } from './node.js'; import { WindowNode } from './window.js'; export declare class AggregateNode extends ExprNode { /** The aggregate function name. */ readonly name: string; /** The aggregate function arguments. */ readonly args: ExprNode[]; /** The distinct flag. */ readonly isDistinct: boolean; /** Filter criteria. */ readonly filter: ExprNode | null; /** Order by expression for order-sensitive aggregates. */ readonly order: ExprNode[]; /** * Instantiate an aggregate function node. * @param name The aggregate function name. * @param args The aggregate function arguments. * @param distinct The distinct flag. * @param filter Filter expression. * @param argOrder Order by expression. */ constructor(name: string, args: ExprNode[], distinct?: boolean, filter?: ExprNode | null, argOrder?: OrderByExpr); /** * Return a new derived aggregate over distinct values. * @param isDistinct The distinct flag. * @returns A new aggregate node. */ distinct(isDistinct?: boolean): AggregateNode; /** * Return a new derived aggregate function that filters values. * @param The filter expression. * @returns A new aggregate node. */ where(filter: ExprNode | string): AggregateNode; /** * Return a new derived aggregate function that sorts values prior to aggregation. * @param order The order by expression. * @returns A new aggregate node. */ argOrder(order: OrderByExpr): AggregateNode; /** * Return a new window function over this aggregate. * @returns A new window node. */ window(): WindowNode; /** * Return a new window function over this aggregate with the given partitions. * @param expr The partition by criteria. * @returns A new window node. */ partitionby(...expr: ExprVarArgs[]): WindowNode; /** * Return a new window function over this aggregate with the given ordering. * @param expr The order by criteria. * @returns A new window node. */ orderby(...expr: ExprVarArgs[]): WindowNode; /** * Return a new window function over this aggregate with the given frame. * @param framedef The window frame definition. * @returns A new window node. */ frame(framedef: WindowFrameNode): WindowNode; /** * Generate a SQL query string for this node. */ toString(): string; } /** * Check if a function name corresponds to an aggregate function. * @param name The function name to check * @returns True if a known aggregate function, false otherwise. */ export declare function isAggregateFunction(name: string): boolean; /** * An array of known aggregate function names. * From https://duckdb.org/docs/sql/functions/aggregates.html. */ export declare const aggregateNames: string[]; //# sourceMappingURL=aggregate.d.ts.map