Skip to main content

uqa_sql/schema/
declarations.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Declaration validation and binding for stored schema expressions.
8
9use crate::{
10    ast::{ColumnDef, FunctionVolatility},
11    SQLError,
12};
13use crate::{expr::EngineHook, semantics::sets::SetFunctionCatalog};
14
15/// Definition lookup and planner capability for stored schema expressions.
16pub trait SchemaExpressionCatalog:
17    EngineHook + SetFunctionCatalog + super::dependencies::oid_alias::OidAliasInput
18{
19    /// Analyze original stored syntax, then plan a copy to classify its remaining functions. The planner owns simplification; the returned catalog expression retains its dependencies.
20    fn plan_schema_expression(
21        &self,
22        expression: &crate::ast::Expr,
23        columns: &[ColumnDef],
24    ) -> Result<super::expressions::PlannedSchemaExpression, SQLError>;
25    fn registered_runtime_function_volatility(&self, name: &str) -> Option<FunctionVolatility>;
26    fn schema_expression_columns(&self, table: &str) -> Result<Option<Vec<ColumnDef>>, SQLError>;
27}
28
29/// Routine metadata and immutable namespace inputs for schema expression binding.
30pub struct SchemaBindingContext<'a, 'q> {
31    pub catalog: &'a dyn SchemaExpressionCatalog,
32    pub binding: &'a crate::binding::context::BindingContext<'q>,
33}