You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(sql): Postgres-style EXPLAIN (...) option list
Extends DataFusion's `EXPLAIN` to accept a Postgres-style parenthesized
option list alongside the existing keyword form, on dialects that
enable it (the default `GenericDialect`, `PostgreSqlDialect`,
`DuckDbDialect`, etc.).
This surfaces the metric-category and verbosity knobs introduced in
PR apache#21160 (currently only reachable via `SET`) directly in the
statement, matching Postgres's one-liner ergonomics:
EXPLAIN (ANALYZE, VERBOSE, METRICS 'rows,bytes', LEVEL dev) SELECT ...
Options recognized: `ANALYZE`, `VERBOSE`, `FORMAT`, `METRICS`, `LEVEL`,
`TIMING`, `SUMMARY`, `COSTS`. Statement-level values override the
corresponding session config. Postgres-only options that DataFusion
does not model (`BUFFERS`, `WAL`, `SETTINGS`, `GENERIC_PLAN`, `MEMORY`)
return a clear unsupported-option error rather than silently accepting
them.
The legacy keyword form (`EXPLAIN ANALYZE VERBOSE FORMAT tree ...`) is
unchanged.
Parser delegates to sqlparser's `parse_utility_options()` under the
dialect gate; a new `ExplainStatementOptions` struct in
`datafusion-common` normalizes both forms into a single representation
that flows through `explain_to_plan` into the `Analyze` / `Explain`
logical plan nodes. `handle_analyze` / `handle_explain` in the
physical planner prefer statement-level overrides over session config
before constructing `AnalyzeExec` / `ExplainExec`.
Proto serialization of the new fields is left as a follow-up (TODO
comments in `datafusion/proto/src/logical_plan/mod.rs`); fields
default to `None` on the other side, matching prior behavior.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments