MCPcopy Create free account
hub / github.com/apache/datafusion / check_column_satisfies_expr

Function check_column_satisfies_expr

datafusion/sql/src/utils.rs:170–191  ·  view source on GitHub ↗
(
    columns: &[Expr],
    expr: &Expr,
    purpose: CheckColumnsSatisfyExprsPurpose,
)

Source from the content-addressed store, hash-verified

168}
169
170fn 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.

Callers 1

Calls 5

with_helpMethod · 0.80
diagnostic_messageMethod · 0.80
containsMethod · 0.45
spansMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…