Function format

Source
pub fn format(plan: &Plan) -> (String, Vec<FormatError>)
Expand description

Format a Substrait plan as human-readable text.

This is the main entry point for formatting plans. It uses default formatting options that produce concise, readable output.

Returns a tuple of (formatted_text, errors). The text is always generated, even if there are formatting errors. Errors are collected and returned for inspection.

§Example

use substrait_explain::{parse, format};
use substrait::proto::Plan;

let plan: Plan = parse(r#"
=== Plan
Root[result]
  Project[$0, $1]
    Read[data => a:i64, b:string]
"#).unwrap();

let (text, errors) = format(&plan);
println!("{}", text);

if !errors.is_empty() {
    println!("Formatting warnings: {:?}", errors);
}

§Output Format

The output follows the Substrait text format specification, with relations displayed in a hierarchical structure using indentation.