import type * as Malloy from '@malloydata/malloy-interfaces'; import type { Expr, TimestampUnit } from '../../../model/malloy_types'; import type { ExprValue } from './expr-value'; import type { FieldSpace } from './field-space'; import { MalloyElement } from './malloy-element'; import type { BinaryMalloyOperator } from './binary_operators'; /** Node types in an alternation tree */ export declare enum ATNodeType { And = 0, Or = 1, Value = 2, Partial = 3 } /** * Root node for any element in an expression. These essentially * create a sub-tree in the larger AST. Expression nodes know * how to write themselves as SQL (or rather, generate the * template for SQL required by the query writer) */ export declare abstract class ExpressionDef extends MalloyElement { abstract elementType: string; granular(): boolean; /** * Returns the "translation" or template for SQL generation. When asking * for a translation you may pass the types you can accept, allowing * the translation code a chance to convert to match your expectations * @param space Namespace for looking up field references */ abstract getExpression(fs: FieldSpace): ExprValue; legalChildTypes: import("../../../model/malloy_types").TypeDesc[]; /** * Some operators want to give the right hand value a chance to * rewrite itself. This requests a translation for a rewrite, * or returns undefined if that request should be denied. * @param fs FieldSpace * @return Translated expression or undefined */ requestExpression(fs: FieldSpace): ExprValue | undefined; defaultFieldName(): string | undefined; /** * Check an expression for type compatibility * @param _eNode currently unused, will be used to get error location * @param eVal ...list of expressions that must match legalChildTypes */ typeCheck(eNode: ExpressionDef, eVal: ExprValue): boolean; drillExpression(): Malloy.Expression | undefined; /** * This is the operation which makes partial comparison and value trees work * The default implementation merely constructs LEFT OP RIGHT, but specialized * nodes like alternation trees or or partial comparison can control how * the appplication gets generated * @param fs The symbol table * @param op The operator being applied * @param expr The "other" (besdies 'this') value * @return The translated expression */ apply(fs: FieldSpace, op: BinaryMalloyOperator, left: ExpressionDef, _warnOnComplexTree?: boolean): ExprValue; canSupportPartitionBy(): boolean; canSupportOrderBy(): boolean; canSupportLimit(): boolean; supportsWhere(expr: ExprValue): boolean; atNodeType(): ATNodeType; atExpr(): ExpressionDef; } export declare class ExprDuration extends ExpressionDef { readonly n: ExpressionDef; readonly timeframe: TimestampUnit; elementType: string; legalChildTypes: import("../../../model/malloy_types").TypeDesc[]; constructor(n: ExpressionDef, timeframe: TimestampUnit); apply(fs: FieldSpace, op: BinaryMalloyOperator, left: ExpressionDef): ExprValue; getExpression(fs: FieldSpace): ExprValue; } export type MorphicType = 'date' | 'timestamp'; export declare function getMorphicValue(mv: ExprValue, mt: MorphicType): ExprValue | undefined; /** * All of the magic of malloy expressions eventually flows to here, * where an operator is applied to two values. Depending on the * operator and value types this may involve transformations of * the values or even the operator. * @param fs FieldSpace for the symbols * @param left Left value * @param op The operator * @param right Right Value * @return ExprValue of the expression */ export declare function applyBinary(fs: FieldSpace, left: ExpressionDef, op: BinaryMalloyOperator, right: ExpressionDef): ExprValue; export declare function checkFilterExpression(logTo: MalloyElement, ft: string, fexpr: Expr): void;