alamb commented on code in PR #9482:
URL: https://github.com/apache/arrow-datafusion/pull/9482#discussion_r1518633014
##########
datafusion/core/tests/user_defined/user_defined_scalar_functions.rs:
##########
@@ -826,11 +914,22 @@ async fn create_scalar_function_from_sql_statement() ->
Result<()> {
.await
.is_err());
- ctx.sql("select better_add(2.0, 2.0)").await?.show().await?;
+ let result = ctx
Review Comment:
👍
##########
datafusion-examples/examples/function_factory.rs:
##########
@@ -0,0 +1,243 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use arrow::array::{ArrayRef, Int64Array, RecordBatch};
+use datafusion::error::Result;
+use datafusion::execution::config::SessionConfig;
+use datafusion::execution::context::{
+ FunctionFactory, RegisterFunction, SessionContext, SessionState,
+};
+use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
+use datafusion_common::tree_node::{Transformed, TreeNode};
+use datafusion_common::{exec_err, internal_err, DataFusionError};
+use datafusion_expr::simplify::ExprSimplifyResult;
+use datafusion_expr::simplify::SimplifyInfo;
+use datafusion_expr::{CreateFunction, Expr, ScalarUDF, ScalarUDFImpl,
Signature};
+use std::result::Result as RResult;
+use std::sync::Arc;
+
+/// This example shows how to utilize [FunctionFactory] to register
+/// `CREATE FUNCTION` handler. Apart from [FunctionFactory] this
+/// example covers [ScalarUDFImpl::simplify()] usage and synergy
+/// between those two functionality.
+///
+/// This example is rather simple, there are many edge cases to be covered
+///
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ let runtime_config = RuntimeConfig::new();
Review Comment:
This example showed how awkward it was to create the appropriate
`SessionState`, so I added a convenience methods on `SessionContext` to make it
easier
--
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]