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

Function registry

datafusion/core/tests/dataframe/mod.rs:1645–1675  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1643
1644#[tokio::test]
1645async fn registry() -> Result<()> {
1646 let ctx = SessionContext::new();
1647 register_aggregate_csv(&ctx, "aggregate_test_100").await?;
1648
1649 // declare the udf
1650 let my_fn: ScalarFunctionImplementation =
1651 Arc::new(|_: &[ColumnarValue]| unimplemented!("my_fn is not implemented"));
1652
1653 // create and register the udf
1654 ctx.register_udf(create_udf(
1655 "my_fn",
1656 vec![DataType::Float64],
1657 DataType::Float64,
1658 Volatility::Immutable,
1659 my_fn,
1660 ));
1661
1662 // build query with a UDF using DataFrame API
1663 let df = ctx.table("aggregate_test_100").await?;
1664
1665 let expr = df.registry().udf("my_fn")?.call(vec![col("c12")]);
1666 let df = df.select(vec![expr])?;
1667
1668 // build query using SQL
1669 let sql_plan = ctx.sql("SELECT my_fn(c12) FROM aggregate_test_100").await?;
1670
1671 // the two plans should be identical
1672 assert_same_plan(df.logical_plan(), sql_plan.logical_plan());
1673
1674 Ok(())
1675}
1676
1677#[tokio::test]
1678async fn sendable() {

Callers

nothing calls this directly

Calls 12

newFunction · 0.85
create_udfFunction · 0.85
assert_same_planFunction · 0.85
registryMethod · 0.80
sqlMethod · 0.80
register_aggregate_csvFunction · 0.50
register_udfMethod · 0.45
tableMethod · 0.45
callMethod · 0.45
udfMethod · 0.45
selectMethod · 0.45
logical_planMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…