()
| 1643 | |
| 1644 | #[tokio::test] |
| 1645 | async 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] |
| 1678 | async fn sendable() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…