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


##########
datafusion/datasource/src/sink.rs:
##########
@@ -67,13 +67,30 @@ pub trait DataSink: Any + DisplayAs + Debug + Send + Sync {
     ///
     /// Returning `Ok(None)` lets the caller try its extension codec instead.
     #[cfg(feature = "proto")]
+    #[deprecated(since = "57.0.0", note = "implement `try_to_proto_sink` 
instead")]
     fn try_to_proto(
         &self,
         _exec: &DataSinkExec,
         _ctx: &datafusion_physical_plan::proto::ExecutionPlanEncodeCtx<'_>,
     ) -> Result<Option<datafusion_proto_models::protobuf::PhysicalPlanNode>> {
         Ok(None)
     }
+
+    /// Serialize this sink into a [`DataSinkNode`], if it knows how.
+    /// [`DataSinkExec`] encodes its input and sort order alongside it.
+    ///
+    /// * `Ok(None)` (the default) — the caller falls back to the deprecated
+    ///   [`Self::try_to_proto`] hook and then to the extension codec.
+    /// * `Ok(Some(node))` — fully serialized.
+    ///
+    /// [`DataSinkNode`]: datafusion_proto_models::protobuf::DataSinkNode

Review Comment:
   Yep exactly. I added some docs to help clarify.



##########
docs/source/library-user-guide/upgrading/index.md:
##########
@@ -391,3 +391,36 @@ simplify expressions such as `col IS NULL` on them.
 Row values are unchanged, but schema inspection can differ: code that compares
 the resulting schema against a hand-written one with `nullable: true` for
 every field needs to be updated.
+
+### Whole-plan `DataSource` / `FileSource` / `DataSink` proto hooks are 
deprecated
+
+Scans and sinks now serialize as layered `data_source` / `data_sink` plan
+nodes. Each level emits only its own message:
+
+| Deprecated                                                 | 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 deprecated hooks are still called when the new one returns `None`, so
+existing implementations keep working. The flat `parquet_scan`, `csv_scan`,
+`json_scan`, `avro_scan`, `arrow_scan`, `memory_scan`, `json_sink`,
+`csv_sink` and `parquet_sink` variants are no longer emitted but still decode.
+
+Plans encoded by 57.0.0 use the new `data_source` / `data_sink` variants, which
+older readers do not understand: a 56.x process cannot decode scans or sinks
+serialized by 57.0.0. Upgrade readers before (or together with) writers in
+mixed-version deployments.
+
+**Migration guide:** implement the new hook and return only your own message;

Review Comment:
   Will do. The example needs the decoder registry from #26555 to round-trip, 
so it goes in a follow-up PR. Both the example and this link are on the 
checklist in #27941.



-- 
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