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

Method create_function

datafusion/core/src/execution/context/mod.rs:1474–1506  ·  view source on GitHub ↗
(&self, stmt: CreateFunction)

Source from the content-addressed store, hash-verified

1472 }
1473
1474 async fn create_function(&self, stmt: CreateFunction) -> Result<DataFrame> {
1475 let function = {
1476 let state = self.state.read().clone();
1477 let function_factory = state.function_factory();
1478
1479 match function_factory {
1480 Some(f) => f.create(&state, stmt).await?,
1481 _ => {
1482 return Err(DataFusionError::Configuration(
1483 "Function factory has not been configured".to_string(),
1484 ));
1485 }
1486 }
1487 };
1488
1489 match function {
1490 RegisterFunction::Scalar(f) => {
1491 self.state.write().register_udf(f)?;
1492 }
1493 RegisterFunction::Aggregate(f) => {
1494 self.state.write().register_udaf(f)?;
1495 }
1496 RegisterFunction::Window(f) => {
1497 self.state.write().register_udwf(f)?;
1498 }
1499 RegisterFunction::HigherOrder(f) => {
1500 self.state.write().register_higher_order_function(f)?;
1501 }
1502 RegisterFunction::Table(name, f) => self.register_udtf(&name, f),
1503 };
1504
1505 self.return_empty_dataframe()
1506 }
1507
1508 async fn drop_function(&self, stmt: DropFunction) -> Result<DataFrame> {
1509 // we don't know function type at this point

Callers 1

execute_logical_planMethod · 0.80

Calls 12

readMethod · 0.80
function_factoryMethod · 0.80
cloneMethod · 0.45
createMethod · 0.45
to_stringMethod · 0.45
register_udfMethod · 0.45
writeMethod · 0.45
register_udafMethod · 0.45
register_udwfMethod · 0.45
register_udtfMethod · 0.45

Tested by

no test coverage detected