Skip to content

feat: Add plan compression and CLI decode support - #586

Open
Rich-T-kid wants to merge 2 commits into
datafusion-contrib:mainfrom
Rich-T-kid:rich-T-kid/add-plan-compression
Open

feat: Add plan compression and CLI decode support#586
Rich-T-kid wants to merge 2 commits into
datafusion-contrib:mainfrom
Rich-T-kid:rich-T-kid/add-plan-compression

Conversation

@Rich-T-kid

@Rich-T-kid Rich-T-kid commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closes #523

  • explain_analyze now base64-encodes plans over char limit (currently 10_000 chars), making large plan strings safe to log without truncation
  • DistributedExec::extract_encoded_plan decodes a base64 plan string back to readable ASCII; passes through plain-text plans unchanged
  • Console CLI accepts --encoded-plan to decode and print a logged plan

Comment on lines +139 to +144
/// Decodes a base64-encoded plan string produced by [`explain_analyze`](crate::explain_analyze).
pub fn extract_encoded_plan(&self, encoded_plan: &str) -> String {
Engine::decode(&STANDARD, encoded_plan)
.map(|bytes| String::from_utf8_lossy(&bytes).into_owned())
.unwrap_or_else(|_| encoded_plan.to_string())
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Based on the original issue:

This project is capable of representing DataFusion metrics in a protobuf format, and at the same time, all DataFusion plans can be serialized as well, so it should be possible for this project to provide a loggable compressed EXPLAIN ANALYZE-like representation that is suitable for a logging system + the tools for properly decoding and visualizing that.

We do not want to just compress the EXPLAIN ANALYZE string in base64, what we want is to create a representation of the metrics as protobuf-compatible structs, and serialize/deserialize those instead.

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.

Add a standard compressed serialized representation of plans with metrics

2 participants