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: site/docs/extensions/index.md
+28-15Lines changed: 28 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,7 +138,7 @@ Advanced extensions provide a way to embed custom functionality that goes beyond
138
138
139
139
Advanced extensions come in several main forms, discussed below:
140
140
141
-
1. Embedded extensions: These use the `AdvancedExtension` message for adding custom data to existing Substrait elements
141
+
1. Embedded extensions: These use the `AdvancedExtension` message for adding custom data to existing Substrait messages
142
142
2. Custom relation types: For defining entirely new relational operations
143
143
3. Custom read/write types: for defining new ways to read from or write to data sources
144
144
@@ -157,19 +157,27 @@ message AdvancedExtension {
157
157
}
158
158
```
159
159
160
+
!!! note "Enhancements vs Optimizations"
161
+
162
+
Use **optimizations** for performance hints that don't change semantics and can be safely ignored. Use **enhancements** for semantic changes that must be understood by consumers or the plan cannot be executed correctly.
163
+
160
164
#### Optimizations
161
165
162
166
- Provide hints to improve performance but don't change the meaning of operations
163
167
- Can be safely ignored by consumers that don't understand them
168
+
- Multiple optimizations can be attached to a single message
Semantic-changing extensions shouldn't change the core characteristics of the underlying relation. For example, they should *not* change the default direct output field ordering, change the number of fields output or change the behavior of physical property characteristics. If one needs to change one of these behaviors, one should define a new relation as described below.
173
181
174
182
#### Where AdvancedExtension Messages Can Be Used
175
183
@@ -181,29 +189,34 @@ The `AdvancedExtension` message can be attached to various parts of a Substrait
181
189
| **`RelCommon`** | Extensions for any relational operator |
182
190
| **Relations** (e.g. `ProjectRel`) | Extensions for a specific relation type |
183
191
| **Hints** | Extensions within optimization hints |
184
-
| **`ReadRel.NamedTable`** | Add custom metadata to named table references |
185
-
| **`WriteRel.NamedObjectWrite`** | Add custom metadata to write targets |
186
-
| **`DdlRel.NamedObjectWrite`** | Add custom metadata to DDL targets |
192
+
| **`ReadRel.NamedTable`** | Custom metadata to named table references |
193
+
| **`ReadRel.LocalFiles`** | Custom metadata to local file sources |
194
+
| **`WriteRel.NamedObjectWrite`** | Custom metadata to write targets |
195
+
| **`DdlRel.NamedObjectWrite`** | Custom metadata to DDL targets |
187
196
188
197
### Custom Relations
189
198
190
199
The second form of advanced extensions provides entirely new relational operations via dedicated extension relation types. These allow you to define custom relations while maintaining proper integration with the type system:
These extension relations are first-class relation types in Substrait and can be used anywhere a standard relation would be used.
199
208
209
+
!!! note "Interoperability Guidance"
210
+
211
+
Custom relations are the most flexible but least interoperable option. In most cases it is better to use enhancements to existing relations rather than defining new custom relations, as it means existing code patterns can easily be extended to work with the additional properties.
212
+
200
213
### Custom Read and Write Types
201
214
202
215
The third form of advanced extensions allows you to define extension data sources and destinations:
0 commit comments