Check if an expression contains aggregate functions
(&self, expr: &Expression)
| 2067 | |
| 2068 | /// Check if an expression contains aggregate functions |
| 2069 | fn contains_aggregate_function(&self, expr: &Expression) -> bool { |
| 2070 | match expr { |
| 2071 | Expression::FunctionCall(func_call) => { |
| 2072 | // Check if this is an aggregate function |
| 2073 | matches!( |
| 2074 | func_call.name.to_uppercase().as_str(), |
| 2075 | "COUNT" | "AVG" | "SUM" | "MIN" | "MAX" |
| 2076 | ) |
| 2077 | } |
| 2078 | Expression::Binary(binary) => { |
| 2079 | // Recursively check both operands |
| 2080 | self.contains_aggregate_function(&binary.left) |
| 2081 | || self.contains_aggregate_function(&binary.right) |
| 2082 | } |
| 2083 | Expression::Unary(unary) => { |
| 2084 | // Recursively check the expression |
| 2085 | self.contains_aggregate_function(&unary.expression) |
| 2086 | } |
| 2087 | // Other expression types don't contain aggregate functions |
| 2088 | _ => false, |
| 2089 | } |
| 2090 | } |
| 2091 | |
| 2092 | /// Execute final RETURN clause with aggregation when needed |
| 2093 | fn execute_return_with_aggregation( |
no outgoing calls
no test coverage detected