nuno-faria opened a new pull request, #19316:
URL: https://github.com/apache/datafusion/pull/19316
## Which issue does this PR close?
- Closes #19215.
## Rationale for this change
Allowing users to check the execution plans without needing to change the
existing application.
The `auto_explain` mode can be enabled with the
`datafusion.explain.auto_explain` config. In addition, there are two other
configs:
- `datafusion.explain.auto_explain_output`: sets the output location of the
plans. Supports `stdout`, `stderr`, and a file path.
- `datafusion.explain.auto_explain_min_duration`: only outputs plans whose
duration is greater than this value (similar to Postgres'
`auto_explain.log_min_duration`).
Example in `datafusion-cli`:
```sql
-- regular mode
> select 1;
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
1 row(s) fetched.
-- with auto_explain enabled (the plan is not actually part of the result,
it is sent to stdout)
> select 1;
+-------------------+------------------------------------------------------------------------------------------------------------------------------+
| plan_type | plan
|
+-------------------+------------------------------------------------------------------------------------------------------------------------------+
| Plan with Metrics | ProjectionExec: expr=[1 as Int64(1)],
metrics=[output_rows=1, elapsed_compute=21.50µs, output_bytes=8.0 B,
output_batches=1] |
| | PlaceholderRowExec, metrics=[]
|
| |
|
+-------------------+------------------------------------------------------------------------------------------------------------------------------+
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+
1 row(s) fetched.
```
## What changes are included in this PR?
- Extended the existing `AnalyzeExec` operator to support the `auto_explain`
mode.
- Added new explain configs.
- Wrap plans in a `AnalyzeExec` operator when `auto_explain` is enabled.
- Added tests.
## Are these changes tested?
Yes.
## Are there any user-facing changes?
New feature, but it's completely optional.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]