import { BaseNode, Keyword } from "./Base"; import { BigqueryOptions } from "./dialects/Bigquery"; import { DataType } from "./DataType"; import { Expr, Identifier, ListExpr, ParenExpr, EntityName } from "./Expr"; import { NumberLiteral, StringLiteral } from "./Literal"; import { DeterminismClause, LanguageClause, WithConnectionClause, ReturnsClause } from "./ProcClause"; import { AsClause } from "./OtherClauses"; import { SubSelect } from "./Select"; import { BlockStmt } from "./ProceduralLanguage"; import { AlterFunctionAction } from "./AlterAction"; import { ResetParameterClause, SetParameterClause, SetParameterFromCurrentClause } from "./Parameter"; export type AllFunctionNodes = AllFunctionStatements | FunctionSignature | FunctionParam | FunctionParamDefault | ReturnClause | DynamicallyLoadedFunction | FunctionWindowClause | FunctionBehaviorClause | FunctionSecurityClause | FunctionCostClause | FunctionRowsClause | FunctionSupportClause | FunctionTransformClause | TransformType; export type AllFunctionStatements = CreateFunctionStmt | DropFunctionStmt | AlterFunctionStmt; export interface CreateFunctionStmt extends BaseNode { type: "create_function_stmt"; createKw: Keyword<"CREATE">; orReplaceKw?: [Keyword<"OR">, Keyword<"REPLACE">]; temporaryKw?: Keyword<"TEMP" | "TEMPORARY">; tableKw?: Keyword<"TABLE">; functionKw: Keyword<"FUNCTION">; ifNotExistsKw?: [Keyword<"IF">, Keyword<"NOT">, Keyword<"EXISTS">]; name: EntityName; params: ParenExpr>; clauses: CreateFunctionClause[]; } export interface FunctionSignature extends BaseNode { type: "function_signature"; name: EntityName; params?: ParenExpr>; } export interface FunctionParam extends BaseNode { type: "function_param"; mode?: Keyword<"IN" | "OUT" | "INOUT" | "VARIADIC">; name?: Identifier; dataType: DataType; default?: FunctionParamDefault; } export interface FunctionParamDefault extends BaseNode { type: "function_param_default"; operator: Keyword<"DEFAULT"> | "="; expr: Expr; } type CreateFunctionClause = ReturnsClause | ReturnClause | BlockStmt | DeterminismClause | LanguageClause | AsClause | SubSelect | DynamicallyLoadedFunction> | BigqueryOptions | WithConnectionClause | FunctionWindowClause | FunctionBehaviorClause | FunctionSecurityClause | FunctionCostClause | FunctionRowsClause | FunctionSupportClause | FunctionTransformClause | SetParameterClause | SetParameterFromCurrentClause; export interface ReturnClause extends BaseNode { type: "return_clause"; returnKw: Keyword<"RETURN">; expr: Expr; } export interface DynamicallyLoadedFunction extends BaseNode { type: "dynamically_loaded_function"; objectFile: StringLiteral; symbol: StringLiteral; } export interface FunctionWindowClause extends BaseNode { type: "function_window_clause"; windowKw: Keyword<"WINDOW">; } export interface FunctionBehaviorClause extends BaseNode { type: "function_behavior_clause"; behaviorKw: Keyword<"VOLATILE"> | Keyword<"STABLE"> | Keyword<"IMMUTABLE"> | Keyword<"LEAKPROOF"> | [Keyword<"NOT">, Keyword<"LEAKPROOF">] | [Keyword<"CALLED">, Keyword<"ON">, Keyword<"NULL">, Keyword<"INPUT">] | [ Keyword<"RETURNS">, Keyword<"NULL">, Keyword<"ON">, Keyword<"NULL">, Keyword<"INPUT"> ] | Keyword<"STRICT"> | [Keyword<"PARALLEL">, Keyword<"UNSAFE" | "SAFE" | "RESTRICTED">]; } export interface FunctionSecurityClause extends BaseNode { type: "function_security_clause"; externalKw?: Keyword<"EXTERNAL">; securityKw: [Keyword<"SECURITY">, Keyword<"DEFINER" | "INVOKER">]; } export interface FunctionCostClause extends BaseNode { type: "function_cost_clause"; costKw: Keyword<"COST">; cost: NumberLiteral; } export interface FunctionRowsClause extends BaseNode { type: "function_rows_clause"; rowsKw: Keyword<"ROWS">; rows: NumberLiteral; } export interface FunctionSupportClause extends BaseNode { type: "function_support_clause"; supportKw: Keyword<"SUPPORT">; name: EntityName; } export interface FunctionTransformClause extends BaseNode { type: "function_transform_clause"; transformKw: Keyword<"TRANSFORM">; types: ListExpr; } export interface TransformType extends BaseNode { type: "transform_type"; forTypeKw: [Keyword<"FOR">, Keyword<"TYPE">]; dataType: DataType; } export interface DropFunctionStmt extends BaseNode { type: "drop_function_stmt"; dropKw: Keyword<"DROP">; tableKw?: Keyword<"TABLE">; functionKw: Keyword<"FUNCTION">; ifExistsKw?: [Keyword<"IF">, Keyword<"EXISTS">]; signatures: ListExpr; behaviorKw?: Keyword<"CASCADE" | "RESTRICT">; } export interface AlterFunctionStmt extends BaseNode { type: "alter_function_stmt"; alterKw: Keyword<"ALTER">; functionKw: Keyword<"FUNCTION">; signature: FunctionSignature; actions: (AlterFunctionAction | AlterFunctionClause)[]; behaviorKw?: Keyword<"RESTRICT">; } type AlterFunctionClause = SetParameterClause | SetParameterFromCurrentClause | ResetParameterClause | FunctionBehaviorClause | FunctionSecurityClause | FunctionCostClause | FunctionRowsClause | FunctionSupportClause; export {};