Omega359 commented on code in PR #9407:
URL: https://github.com/apache/arrow-datafusion/pull/9407#discussion_r1510337986
##########
datafusion/sql/src/expr/function.rs:
##########
@@ -20,20 +20,63 @@ use arrow_schema::DataType;
use datafusion_common::{
not_impl_err, plan_datafusion_err, plan_err, DFSchema, Dependency, Result,
};
-use datafusion_expr::expr::{ScalarFunction, Unnest};
-use datafusion_expr::function::suggest_valid_function;
use datafusion_expr::window_frame::{check_window_frame,
regularize_window_order_by};
use datafusion_expr::{
- expr, AggregateFunction, BuiltinScalarFunction, Expr, ExprSchemable,
WindowFrame,
- WindowFunctionDefinition,
+ expr, AggregateFunction, Expr, ExprSchemable, WindowFrame,
WindowFunctionDefinition,
+};
+use datafusion_expr::{
+ expr::{ScalarFunction, Unnest},
+ BuiltInWindowFunction, BuiltinScalarFunction,
};
use sqlparser::ast::{
Expr as SQLExpr, Function as SQLFunction, FunctionArg, FunctionArgExpr,
WindowType,
};
use std::str::FromStr;
+use strum::IntoEnumIterator;
use super::arrow_cast::ARROW_CAST_NAME;
+/// Suggest a valid function based on an invalid input function name
+pub fn suggest_valid_function(
+ input_function_name: &str,
+ is_window_func: bool,
+ ctx: &dyn ContextProvider,
+) -> String {
+ let valid_funcs = if is_window_func {
+ // All aggregate functions and builtin window functions
+ AggregateFunction::iter()
+ .map(|func| func.to_string())
+ .chain(BuiltInWindowFunction::iter().map(|func| func.to_string()))
Review Comment:
Would we want to add the ctx.udafs() and ctx.udwfs() here as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]