alamb commented on PR #26824:
URL: https://github.com/apache/datafusion/pull/26824#issuecomment-7327571198

   I found this PR description really hard to read / understand the rationale 
for as it was talking about a bunch of code details that I am unfamiliar with 
rather than what the purpose is in terms of end user terms. I had my agent do 
some analysis, and I think the actual usecase is something like 
   
   ## Who is this for:
   People who ship physical plans between processes (e.g. distributed engines 
built on `datafusion-proto`) and who have their own source or sink types. Users 
of only the built-in Parquet/CSV/JSON/Avro/Arrow sources see no functional 
change.
   
   ## Concrete usecase:
   
   A distributed engine that scans a "custom" file format (that is not part of 
the  DataFusion core), for example `VortexSource` implementing `FileSource`, 
and needs to send the scan from the coordinator to workers.
   
   ### Today
   
   VortexSource has one piece of its own state (say, a pushed-down predicate), 
but its hook must produce the whole plan node, including everything 
`FileScanConfig` owns:
   
   ```rust
   impl FileSource for VortexSource {
       fn try_to_proto(&self, base: &FileScanConfig, ctx: 
&ExecutionPlanEncodeCtx<'_>)
           -> Result<Option<PhysicalPlanNode>>
       {
           // Must carry the shared config (files, projection, stats, limit) 
itself
           let my_msg = MyVortexScan {
               base_conf: Some(base.try_to_proto(ctx)?),
               predicate: self.encode_predicate(ctx)?,
           };
           // ...and wrap it in a plan-level extension node
           Ok(Some(PhysicalPlanNode { /* extension { node: my_msg bytes } */ }))
       }
   }
   ```
   
   On the worker, a `PhysicalExtensionCodec` has to recognize those bytes among 
every other extension plan, rebuild the `FileScanConfig`, and wrap it in a 
DataSourceExec. 
   
   ### After this PR and the follow-ups
   
   The source describes only itself:
   
   ```rust
   impl FileSource for VortexSource {
       fn try_to_proto_file_source(&self, ctx: &ExecutionPlanEncodeCtx<'_>)
           -> Result<Option<FileSourceNode>>
       {
           Ok(Some(FileSourceNode {
               file_source_type: 
Some(FileSourceType::Extension(ExtensionFileSourceNode {
                   name: "vortex".into(),
                   payload: self.encode_predicate(ctx)?,   // only its own state
               })),
           }))
       }
   }
   ```
   
   Is that accurate?


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