Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi extension codecs for AsExecutionPlan trait #10983

Closed
wants to merge 4 commits into from

Conversation

lewiszlw
Copy link
Member

Which issue does this PR close?

Closes #.

Rationale for this change

Execution plan tree might have different node from different crates, for example ShuffleWriterExec from datafusion-ballista and DeltaScan from deltalake, these crates both provide PhysicalExtensionCodec.

ShuffleWriterExec
    ProjectionExec
       ...
          DeltaScan

We should be able to serialize/deserialize this case.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than changing the API, I wonder if we could instead provide an example of how to make your own composeable codec

Something like

/// A PhysicalExtensionCodec that tries one of multiple inner codecs 
/// until one works
struct ComposedCodec {
  codecs: Vec<Arc<dyn PhysicalExtensionCodec>>
}

impl PhysicalExtensionCodec for ComposedCodec
    // Required methods
    fn try_decode(
        &self,
        buf: &[u8],
        inputs: &[Arc<dyn ExecutionPlan>],
        registry: &dyn FunctionRegistry,
    ) -> Result<Arc<dyn ExecutionPlan>> {
      let mut last_e = None;
      for codec in self.codecs.iter() {
       match codec.try_decode(buf, inputs, registry) {
         Ok(plan) => return Ok(plan),
        // remember error
         Err(e) => last_e = Some(e),
       }
     return Err(last_e.unwrap())  
    }
...
}

@lewiszlw
Copy link
Member Author

Looks great. I'll give it a try later.

@alamb alamb marked this pull request as draft June 22, 2024 11:45
@alamb
Copy link
Contributor

alamb commented Jun 22, 2024

Marking as draft as I don't think this PR is waiting on more feedback and I am trying to clear out the remaining reviews

@lewiszlw
Copy link
Member Author

Closed in favor of #11095.

@lewiszlw lewiszlw closed this Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants