apache / datafusion

Apache DataFusion SQL Query Engine
https://datafusion.apache.org/
Apache License 2.0
6.37k stars 1.2k forks source link

Logical Plan Tree Structure #13266

Open whatever1345 opened 2 weeks ago

whatever1345 commented 2 weeks ago

Is your feature request related to a problem or challenge?

Hello guys, I'm interesting in the analysis feature of DataFusion, specifically with the Logical Plan. But it is very frustrating when I can hardly find any documentation on how Logical Plan nodes are built at low level and because Logical Plan nodes have a lot of enums, it is very hard to picture the tree of Logical Plan with just... imagination.

Up until now, we only have sql_analysis.rs as an example of traversing the Logical Plan tree, but still, it only concerns little info of node Join and nothing else, so I have to figure out the rest of tree by a lot of trial - error and also guess-work.

Describe the solution you'd like

I would love to see (a joint effort maybe) to write a documentation on how Logical Plan tree are built from a query with all possible cases: what is the root of the tree?, which is the leaf?, which node would be push down deeper and why?, etc. The documentation should answer these questions.

Or the best would be an implementation of a print_tree(&LogicalPlan) would be greatly helpful, but again the documentation should the top priority.

Describe alternatives you've considered

No response

Additional context

No response

niebayes commented 2 weeks ago

For part of your question, there provides a DisplayableExeuctionPlan for print an execution plan in a pretty way.