You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/library-user-guide/extending-operators.md
+12-69Lines changed: 12 additions & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,63 +1,3 @@
1
-
<!---
2
-
Licensed to the Apache Software Foundation (ASF) under one
3
-
or more contributor license agreements. See the NOTICE file
4
-
distributed with this work for additional information
5
-
regarding copyright ownership. The ASF licenses this file
6
-
to you under the Apache License, Version 2.0 (the
7
-
"License"); you may not use this file except in compliance
8
-
with the License. You may obtain a copy of the License at
9
-
10
-
http://www.apache.org/licenses/LICENSE-2.0
11
-
12
-
Unless required by applicable law or agreed to in writing,
13
-
software distributed under the License is distributed on an
14
-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
-
KIND, either express or implied. See the License for the
16
-
specific language governing permissions and limitations
17
-
under the License.
18
-
-->
19
-
20
-
# Extending DataFusion's operators: custom LogicalPlan and Execution Plans
21
-
22
-
DataFusion supports extension of operators by transforming logical plan and execution plan through customized [optimizer rules](https://docs.rs/datafusion/latest/datafusion/optimizer/trait.OptimizerRule.html). This section will use the µWheel project to illustrate such capabilities.
23
-
24
-
## About DataFusion µWheel
25
-
26
-
[DataFusion µWheel](https://github.com/uwheel/datafusion-uwheel/tree/main) is a native DataFusion optimizer which improves query performance for time-based analytics through fast temporal aggregation and pruning using custom indices. The integration of µWheel into DataFusion is a joint effort with the DataFusion community.
27
-
28
-
### Optimizing Logical Plan
29
-
30
-
The `rewrite` function transforms logical plans by identifying temporal patterns and aggregation functions that match the stored wheel indices. When match is found, it queries the corresponding index to retrieve pre-computed aggregate values, stores these results in a [MemTable](https://docs.rs/datafusion/latest/datafusion/datasource/memory/struct.MemTable.html), and returns as a new `LogicalPlan::TableScan`. If no match is found, the original plan proceeds unchanged through DataFusion's standard execution path.
31
-
32
-
```rust,ignore
33
-
fn rewrite(
34
-
&self,
35
-
plan: LogicalPlan,
36
-
_config: &dyn OptimizerConfig,
37
-
) -> Result<Transformed<LogicalPlan>> {
38
-
// Attempts to rewrite a logical plan to a uwheel-based plan that either provides
39
-
// plan-time aggregates or skips execution based on min/max pruning.
40
-
if let Some(rewritten) = self.try_rewrite(&plan) {
41
-
Ok(Transformed::yes(rewritten))
42
-
} else {
43
-
Ok(Transformed::no(plan))
44
-
}
45
-
}
46
-
```
47
-
48
-
```rust,ignore
49
-
// Converts a uwheel aggregate result to a TableScan with a MemTable as source
0 commit comments