Dear Substrait Community,
I'm excited to announce
substrait-explain, a new project providing a human-readable, SQL-EXPLAIN-like format for Substrait plans. This approach has been particularly useful internally at Datadog for daily development and debugging, especially for logging production queries and testing.
Here’s an example of the format:
=== Extensions
URIs:
@ 1: https://github.com/substrait-io/substrait/blob/main/extensions/functions_comparison.yaml
@ 2: https://github.com/substrait-io/substrait/blob/main/extensions/functions_arithmetic.yaml
@ 3: https://github.com/substrait-io/substrait/blob/main/extensions/functions_aggregate.yaml
Functions:
# 10 @ 1: eq
# 11 @ 1: gt
# 12 @ 2: multiply
# 13 @ 3: sum
=== Plan
Root[customer_revenue]
Aggregate[$0, $1 => $0, $1, sum($3)]
Filter[gt($3, 100) => $0, $1, $2, $3]
Project[$0, $1, $2, multiply($4, $5)]
Join[&Inner, eq($0, $3) => $0, $1, $2, $3, $4, $5]
Read[users => id:i64, name:string, region:string]
Read[orders => user_id:i64, quantity:i32, price:i64]While the Substrait protobuf format is robust for programmatic use, its JSON form can be challenging for humans to digest.
substrait-explain aims to provide that clear, "EXPLAIN"-like view for understanding plans at a glance. It's a two-way tool: capable of both outputting this text format from a Substrait plan and parsing the text back into a plan.
This project is in active development, currently supporting basic relations with more coverage planned. I hope the community finds it useful! While we’re happy for this project to remain under the Datadog umbrella, we'd certainly be open to discussing adoption by substrait-io in the future if interest develops. Your feedback and contributions are very welcome, especially as its coverage and capabilities evolve – I’d love to hear your thoughts on how this might be more useful!
Best regards,
Wendell Smith
Datadog Substrait Team