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

Function test_user_defined_table_function

datafusion/ffi/tests/ffi_udtf.rs:36–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 /// using the abs() function as our scalar UDF.
35 #[tokio::test]
36 async fn test_user_defined_table_function() -> Result<()> {
37 let module = get_module()?;
38 let (ctx, codec) = super::utils::ctx_and_codec();
39
40 let ffi_table_func = (module.create_table_function)(codec);
41 let foreign_table_func: Arc<dyn TableFunctionImpl> = ffi_table_func.into();
42
43 ctx.register_udtf("my_range", foreign_table_func);
44
45 let result = ctx
46 .sql("SELECT * FROM my_range(5)")
47 .await?
48 .collect()
49 .await?;
50 let expected = create_array!(Int64, [0, 1, 2, 3, 4]) as ArrayRef;
51
52 assert!(result.len() == 1);
53 assert!(result[0].column(0) == &expected);
54
55 Ok(())
56 }
57}

Callers

nothing calls this directly

Calls 6

get_moduleFunction · 0.85
ctx_and_codecFunction · 0.85
collectMethod · 0.80
sqlMethod · 0.80
intoMethod · 0.45
register_udtfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…