datafusion
datafusion copied to clipboard
Nested explain possible via DataFrame API
Describe the bug
Via SQL we disallow nested explains:
use datafusion::error::Result;
use datafusion::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
let ctx = SessionContext::new();
ctx.sql("explain explain select 1").await?.show().await?;
Ok(())
}
Will output:
Error: Plan("Nested EXPLAINs are not supported")
This is expected behaviour.
However, via the DataFrame API we can bypass this restriction.
To Reproduce
use datafusion::error::Result;
use datafusion::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
let ctx = SessionContext::new();
ctx.sql("explain select 1")
.await?
.explain(false, false)? // NOTE: you can actually just keep adding more explains here
.show()
.await?;
Ok(())
}
Will output:
+--------------+------------------------+
| plan_type | plan |
+--------------+------------------------+
| logical_plan | Explain |
| | Projection: Int64(1) |
| | EmptyRelation |
+--------------+------------------------+
Expected behavior
DataFrame API version should throw an error like for SQL
Additional context
No response
take