alamb commented on code in PR #26824:
URL: https://github.com/apache/datafusion/pull/26824#discussion_r4773054652


##########
docs/source/library-user-guide/upgrading/index.md:
##########
@@ -439,6 +439,83 @@ if let Some(schema) = catalog.schema("public")? {
 The FFI wrappers (`FFI_CatalogProvider` and `FFI_SchemaProvider`) carry these
 errors across the FFI boundary instead of dropping them.
 
+### `DataSource`, `FileSource` and `DataSink` serialize only their own state
+
+This change affects you if you serialize physical plans with `datafusion-proto`
+and you have your own `DataSource`, `FileSource` or `DataSink`, or you build
+the scan and sink protobuf messages by hand.
+
+Scans and sinks serialize as the `data_source` and `data_sink` variants of
+`PhysicalPlanNode`. Each trait level writes one message, and DataFusion writes
+the wrappers (`DataSourceExec`, `FileScanConfig`, `DataSinkExec`).
+
+The whole-plan hooks are removed. Code that implements or calls one of them
+does not compile:
+
+| Removed                                                    | Replacement     
                                               |
+| ---------------------------------------------------------- | 
-------------------------------------------------------------- |
+| `DataSource::try_to_proto` → `PhysicalPlanNode`            | 
`DataSource::try_to_proto_source` → `DataSourceNode`           |
+| `FileSource::try_to_proto(base, ctx)` → `PhysicalPlanNode` | 
`FileSource::try_to_proto_file_source(ctx)` → `FileSourceNode` |
+| `DataSink::try_to_proto(exec, ctx)` → `PhysicalPlanNode`   | 
`DataSink::try_to_proto_sink(ctx)` → `DataSinkNode`            |
+| `{Csv,Json,Avro,Arrow,Parquet}Source::try_from_proto`      | 
`…Source::try_from_proto_file_source`                          |
+| `MemorySourceConfig::try_from_proto`                       | 
`MemorySourceConfig::try_from_proto_source`                    |
+| `{Csv,Json,Parquet}Sink::try_from_proto`                   | 
`TryFrom<&protobuf::{Csv,Json,Parquet}Sink>`                   |
+
+The per-format plan variants and their messages are removed too:
+`parquet_scan`, `csv_scan`, `json_scan`, `avro_scan`, `arrow_scan`,
+`memory_scan`, `json_sink`, `csv_sink` and `parquet_sink`.
+
+**Wire format:** 57.0.0 cannot decode a scan or sink that an earlier version
+serialized, and an earlier version cannot decode one that 57.0.0 serialized.
+Upgrade readers and writers together. Serialized plans are
+[not guaranteed to be compatible across 
versions](https://docs.rs/datafusion-proto/latest/datafusion_proto/#version-compatibility).
+
+**Migration guide:** return only your own state from the new hook. A type that
+DataFusion does not define uses the `extension` arm, which carries a name and
+an opaque payload.
+
+Before:
+
+```rust,ignore
+impl FileSource for MySource {
+    fn try_to_proto(
+        &self,
+        base: &FileScanConfig,
+        ctx: &ExecutionPlanEncodeCtx<'_>,
+    ) -> Result<Option<PhysicalPlanNode>> {
+        let my_msg = MyScan {
+            base_conf: Some(base.try_to_proto(ctx)?),
+            predicate: self.encode_predicate(ctx)?,
+        };
+        Ok(Some(PhysicalPlanNode { /* a plan-level extension node */ }))
+    }
+}
+```
+
+After:
+
+```rust,ignore
+impl FileSource for MySource {
+    fn try_to_proto_file_source(
+        &self,
+        ctx: &ExecutionPlanEncodeCtx<'_>,
+    ) -> Result<Option<FileSourceNode>> {
+        Ok(Some(FileSourceNode {
+            file_source_type: Some(FileSourceType::Extension(
+                ExtensionFileSourceNode {
+                    name: "my_source".into(),
+                    payload: self.encode_predicate(ctx)?,
+                },
+            )),
+        }))
+    }
+}
+```
+
+DataFusion does not decode the `extension` arms yet. Until it does, leave the

Review Comment:
   we should probably leave a link to the relevant tracking ticket here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to