Skip to content

Commit 16828ad

Browse files
committed
docs: add UDTF
1 parent b83db3d commit 16828ad

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ implement_from_tuple!(
116116
```
117117
- User-Defined Function: `features = ["macros"]`
118118
```rust
119-
function!(TestFunction::test(LogicalType::Integer, LogicalType::Integer) -> LogicalType::Integer => |v1: ValueRef, v2: ValueRef| {
119+
scala_function!(TestFunction::test(LogicalType::Integer, LogicalType::Integer) -> LogicalType::Integer => |v1: ValueRef, v2: ValueRef| {
120120
let plus_binary_evaluator = EvaluatorFactory::binary_create(LogicalType::Integer, BinaryOperator::Plus)?;
121121
let value = plus_binary_evaluator.binary_eval(&v1, &v2);
122122

@@ -125,9 +125,28 @@ function!(TestFunction::test(LogicalType::Integer, LogicalType::Integer) -> Logi
125125
});
126126

127127
let fnck_sql = DataBaseBuilder::path("./data")
128-
.register_function(TestFunction::new())
128+
.register_scala_function(TestFunction::new())
129129
.build()?;
130130
```
131+
- User-Defined Table Function: `features = ["macros"]`
132+
```rust
133+
table_function!(MyTableFunction::test_numbers(LogicalType::Integer) -> [c1: LogicalType::Integer, c2: LogicalType::Integer] => (|v1: ValueRef| {
134+
let num = v1.i32().unwrap();
135+
136+
Ok(Box::new((0..num)
137+
.into_iter()
138+
.map(|i| Ok(Tuple {
139+
id: None,
140+
values: vec![
141+
Arc::new(DataValue::Int32(Some(i))),
142+
Arc::new(DataValue::Int32(Some(i))),
143+
]
144+
}))) as Box<dyn Iterator<Item = Result<Tuple, DatabaseError>>>)
145+
}));
146+
let fnck_sql = DataBaseBuilder::path("./data")
147+
.register_table_function(TestFunction::new())
148+
.build()?;
149+
```
131150
- Optimizer
132151
- RBO
133152
- CBO based on RBO(Physical Selection)

0 commit comments

Comments
 (0)