mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 22:32:55 +00:00
fix: show proper error msg, when executing non-admin functions as admin functions (#7061)
Signed-off-by: Shyamnatesan <shyamnatesan21@gmail.com>
This commit is contained in:
@@ -49,15 +49,22 @@ impl StatementExecutor {
|
||||
let Admin::Func(func) = &stmt;
|
||||
// the function name should be in lower case.
|
||||
let func_name = func.name.to_string().to_lowercase();
|
||||
let factory = FUNCTION_REGISTRY
|
||||
.get_function(&func_name)
|
||||
.context(error::AdminFunctionNotFoundSnafu { name: func_name })?;
|
||||
let factory = FUNCTION_REGISTRY.get_function(&func_name).context(
|
||||
error::AdminFunctionNotFoundSnafu {
|
||||
name: func_name.clone(),
|
||||
},
|
||||
)?;
|
||||
|
||||
let func_ctx = FunctionContext {
|
||||
query_ctx: query_ctx.clone(),
|
||||
state: self.query_engine.engine_state().function_state(),
|
||||
};
|
||||
|
||||
let admin_udf = factory.provide(func_ctx);
|
||||
let admin_async_fn = admin_udf
|
||||
.as_async()
|
||||
.context(error::AdminFunctionNotFoundSnafu { name: func_name })?;
|
||||
|
||||
let fn_name = admin_udf.name();
|
||||
let signature = admin_udf.signature();
|
||||
|
||||
@@ -122,11 +129,7 @@ impl StatementExecutor {
|
||||
};
|
||||
|
||||
// Execute the async UDF
|
||||
let result_columnar = admin_udf
|
||||
.as_async()
|
||||
.with_context(|| error::BuildAdminFunctionArgsSnafu {
|
||||
msg: format!("Function {} is not async", fn_name),
|
||||
})?
|
||||
let result_columnar = admin_async_fn
|
||||
.invoke_async_with_args(func_args)
|
||||
.await
|
||||
.with_context(|_| ExecuteAdminFunctionSnafu {
|
||||
|
||||
Reference in New Issue
Block a user