flowscope_core/analyzer/helpers/
query.rs1use sqlparser::ast::{self as ast, Expr, Query, SetExpr};
2
3pub fn classify_query_type(query: &Query) -> String {
5 if query.with.is_some() {
6 "WITH".to_string()
7 } else {
8 match &*query.body {
9 SetExpr::Select(_) => "SELECT".to_string(),
10 SetExpr::SetOperation { op, .. } => match op {
11 ast::SetOperator::Union => "UNION".to_string(),
12 ast::SetOperator::Intersect => "INTERSECT".to_string(),
13 ast::SetOperator::Except => "EXCEPT".to_string(),
14 ast::SetOperator::Minus => "MINUS".to_string(),
15 },
16 SetExpr::Values(_) => "VALUES".to_string(),
17 _ => "SELECT".to_string(),
18 }
19 }
20}
21
22pub fn is_simple_column_ref(expr: &Expr) -> bool {
24 matches!(expr, Expr::Identifier(_) | Expr::CompoundIdentifier(_))
25}