datafusion-ballista icon indicating copy to clipboard operation
datafusion-ballista copied to clipboard

Improve `EXPLAN` command support

Open milenkovicm opened this issue 1 year ago • 5 comments

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

EXPLAN query provides valuable information to understand job behaviour, at the moment it will provide datafusion plan without shuffles, also it does not really provide information for EXPLAN ANALYSE

Describe the solution you'd like

Improve EXPLAN command support

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

milenkovicm avatar Aug 17 '25 19:08 milenkovicm

Hey team, I’m new to the DataFusion/Ballista community and would love to start contributing from this issue 🙂

danielhumanmod avatar Aug 24 '25 00:08 danielhumanmod

Welcome, let us know if you need any help

milenkovicm avatar Aug 24 '25 06:08 milenkovicm

Hey @milenkovicm , I read through the codebase and have an initial proposal for EXPLAIN (I will start work on EXPLAIN first, then EXPLAN ANALYZE)

  1. In Ballista's scheduler phase (when logical → physical), detect the ExecExplain (DF one) node, replace with new custom BallistaExecPlan node
  2. Implement BallistaExecPlan returns three rows:
  • Logical plan: reuse DF’s final logical plan from ExplainExec.
  • physical plan: reuse DF’s final physical plan from ExplainExec
  • distributed plan: derive from Ballista’s stage DAG (DefaultDistributedPlanner::plan_query_stages), showing stages/shuffles/deps.

PS: Why a new exec instead of reusing ExplainExec? DF’s ExplainExec filters rows via PlanType::should_display(). In non-VERBOSE mode it only shows logical_plan and physical_plan. Our distributed_plan is unknown to DF’s PlanType, so: • Plan A: either we “fake” it as another physical_plan row (but potentially confusing to user), or • Plan B: we introduce a Ballista-specific exec that appends a third distributed_plan row explicitly.

Happy to know your thought here, is the solution sounds good to you, and do you prefer plan A or B in this case?

danielhumanmod avatar Aug 24 '25 21:08 danielhumanmod

Your plan makes sense @danielhumanmod, If it is easier we could split this issue in two, explain and explain analyse and deliver it as two separate PRs.

Regarding options, B looks better to me but once you start implementing you'll have better idea.

milenkovicm avatar Aug 24 '25 22:08 milenkovicm

Hey @milenkovicm , I have finished the draft version for EXPLAIN implementation #1309 and would love to get some early feedbacks from you :)

danielhumanmod avatar Sep 04 '25 06:09 danielhumanmod