(
columns: &[Expr],
expr: &Expr,
purpose: CheckColumnsSatisfyExprsPurpose,
)
| 168 | } |
| 169 | |
| 170 | fn check_column_satisfies_expr( |
| 171 | columns: &[Expr], |
| 172 | expr: &Expr, |
| 173 | purpose: CheckColumnsSatisfyExprsPurpose, |
| 174 | ) -> Result<()> { |
| 175 | if !columns.contains(expr) { |
| 176 | let diagnostic = Diagnostic::new_error( |
| 177 | purpose.diagnostic_message(expr), |
| 178 | expr.spans().and_then(|spans| spans.first()), |
| 179 | ) |
| 180 | .with_help(format!("Either add '{expr}' to GROUP BY clause, or use an aggregate function like ANY_VALUE({expr})"), None); |
| 181 | |
| 182 | return plan_err!( |
| 183 | "{}: While expanding wildcard, column \"{}\" must appear in the GROUP BY clause or must be part of an aggregate function, currently only \"{}\" appears in the SELECT clause satisfies this requirement", |
| 184 | purpose.message_prefix(), |
| 185 | expr, |
| 186 | expr_vec_fmt!(columns); |
| 187 | diagnostic=diagnostic |
| 188 | ); |
| 189 | } |
| 190 | Ok(()) |
| 191 | } |
| 192 | |
| 193 | /// Returns mapping of each alias (`String`) to the expression (`Expr`) it is |
| 194 | /// aliasing. |
no test coverage detected
searching dependent graphs…