@uwdata/mosaic-sql
Version:
SQL query construction and analysis.
56 lines • 2.36 kB
TypeScript
import type { ExprNode, SQLNode } from '../ast/node.js';
import type { WindowFunctionName } from '../types.js';
import { AggregateNode } from '../ast/aggregate.js';
import { FunctionNode } from '../ast/function.js';
import { WindowNode } from '../ast/window.js';
/**
* Test if an AST node is a specific function call.
* @param node The SQL AST node to test.
* @param name The function name.
*/
export declare function isFunctionCall(node: SQLNode, name: string): node is FunctionNode;
/**
* Create a new function call AST node.
* @param name The function name.
* @param args The function arguments.
*/
export declare function fn(name: string, ...args: unknown[]): FunctionNode;
/**
* Create a new aggregate function AST node.
* @param name The function name.
* @param args The function arguments.
*/
export declare function aggFn(name: string, ...args: unknown[]): AggregateNode;
/**
* Create a new window AST node. The output node has an empty window
* definition. Use chained calls such as `partitionby` and `orderby`
* to specify the window settings.
* @param name The function name.
* @param args The function arguments.
*/
export declare function winFn(name: WindowFunctionName, ...args: unknown[]): WindowNode;
/**
* Process a list of expression inputs. Nested arrays are flattened,
* null results are removed, and each input is cast to a SQL AST node.
* @param list The list of expression inputs.
* @param cast A function that casts an input value
* to a desired type. By default, `asNode` is used to coerce
* inputs to AST nodes as needed.
*/
export declare function exprList<T>(list: unknown[], cast: ((x: unknown) => T)): T[];
/**
* Process a list of expression inputs. Nested arrays are flattened,
* null results are removed, and each input is cast (as needed) to
* be a proper SQL AST node. By default, strings are assumed to be
* column names, while other primitive values map to SQL literals.
* Use an alternative *cast* function to change this behavior.
* @param list The list of expression inputs.
*/
export declare function nodeList(list: unknown[]): ExprNode[];
/**
* Process a list of function arguments, stripping any undefined
* values from the end of the list.
* @param list The input function arguments.
*/
export declare function argsList<T>(list: T[]): T[];
//# sourceMappingURL=function.d.ts.map