UNPKG

@uwdata/mosaic-sql

Version:

SQL query construction and analysis.

62 lines 2.95 kB
import type { ColumnRefNode } from '../ast/column-ref.js'; import type { TableRefNode } from '../ast/table-ref.js'; import { ExprNode, type SQLNode } from '../ast/node.js'; import { WindowDefNode } from '../ast/window.js'; /** * Interpret a value as a SQL AST node. String values are assumed to be * column references. All other primitive values are interpreted as * SQL literals. Dynamic parameters are interpreted as param AST nodes, * while existing AST nodes are left as-is. * @param value The value to interpret as a SQL AST node. */ export declare function asNode(value: unknown): ExprNode; /** * Interpret a value as a verbatim SQL AST node. String values will be * passed through to queries as verbatim text. All other primitive values * are interpreted as SQL literals. Dynamic parameters are interpreted * as param AST nodes, while existing AST nodes are left as-is. * @param value The value to interpret as a verbatim AST node. */ export declare function asVerbatim(value: unknown): ExprNode; /** * Interpret a value as a literal AST node. All other primitive values * are interpreted as SQL literals. Dynamic parameters are interpreted * as param AST nodes, while existing AST nodes are left as-is. * @param value The value to interpret as a literal AST node. */ export declare function asLiteral(value: unknown): ExprNode; /** * Interpret a value as a table reference AST node. String values are parsed * assuming dot ('.') delimiters (as in `schema.table`). Array values are * interpreted as pre-parsed name paths (as in `['schema', 'table']`). Any * other values are left as-is. * @param value The value to interpret as a table reference AST node. */ export declare function asTableRef(value?: string | string[] | TableRefNode): TableRefNode | undefined; /** * Try to interpret a value as a table reference AST node. String values are * parsed assuming dot ('.') delimiters (as in `schema.table`). Array values * are interpreted as pre-parsed name paths (as in `['schema', 'table']`). Any * other values are left as-is. * @param value The value to interpret as a table reference. */ export declare function maybeTableRef(value: string | string[] | SQLNode): SQLNode; /** * Parse a string as a column reference, potentially with * dot ('.') delimited table, schema, and database references. * @param ref The column reference string. */ export declare function parseColumnRef(ref: string): ColumnRefNode; /** * Parse a string as a table reference, potentially with * dot ('.') delimited schema and database references. * @param ref The table reference string. */ export declare function parseTableRef(ref: string): TableRefNode; /** * Create a new window definition node. The return value is an empty * window definition. Use chained calls such as `partitionby` and `orderby` * to specify the window settings. */ export declare function over(): WindowDefNode; //# sourceMappingURL=ast.d.ts.map