Skip to main content

no_mistakes_postgres_sql/statement_facts/
transformed.rs

1/// Predicate context for a cast or function applied to a column.
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum SqlTransformedColumnClause {
4    Where,
5    Join,
6    Having,
7}
8
9/// A syntactic column reference below a cast or function, resolved against base relations.
10/// An empty table needs catalog disambiguation; absent candidates mean unknown scope.
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct SqlTransformedColumnUseFact {
13    pub table: String,
14    pub column: String,
15    pub candidate_tables: Option<Vec<String>>,
16    pub clause: SqlTransformedColumnClause,
17    pub line: usize,
18    pub column_position: usize,
19    pub transformation: String,
20    pub expression: std::sync::Arc<sqlparser::ast::Expr>,
21    pub outer_join_residual: bool,
22    pub index_operand: bool,
23    pub expression_single_relation: bool,
24    pub expression_relations: std::sync::Arc<Vec<SqlTransformedColumnProbeFact>>,
25    pub expression_site: (usize, usize),
26    pub bare_anchors: Vec<SqlTransformedColumnProbeFact>,
27    pub driving_probe: Option<SqlTransformedColumnProbeFact>,
28    /// The other wrapped operand when this fact describes a cross-relation comparison.
29    pub comparison_peer: Option<Box<SqlTransformedColumnUseFact>>,
30}
31
32/// Bare probe key whose catalog type must be proven before exempting driving transforms.
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub struct SqlTransformedColumnProbeFact {
35    pub table: String,
36    pub column: String,
37    pub candidate_tables: Option<Vec<String>>,
38}