geoffreyclaude commented on code in PR #21767:
URL: https://github.com/apache/datafusion/pull/21767#discussion_r3323238272
##########
datafusion/physical-plan/src/analyze.rs:
##########
@@ -238,39 +312,59 @@ fn create_output_batch(
schema: &SchemaRef,
metric_types: &[MetricType],
metric_categories: Option<&[MetricCategory]>,
+ format: &ExplainFormat,
) -> Result<RecordBatch> {
let mut type_builder = StringBuilder::with_capacity(1, 1024);
let mut plan_builder = StringBuilder::with_capacity(1, 1024);
- // TODO use some sort of enum rather than strings?
- type_builder.append_value("Plan with Metrics");
-
- let annotated_plan = DisplayableExecutionPlan::with_metrics(input.as_ref())
- .set_metric_types(metric_types.to_vec())
- .set_metric_categories(metric_categories.map(|c| c.to_vec()))
- .set_show_statistics(show_statistics)
- .indent(verbose)
- .to_string();
- plan_builder.append_value(annotated_plan);
-
- // Verbose output
- // TODO make this more sophisticated
- if verbose {
- type_builder.append_value("Plan with Full Metrics");
-
- let annotated_plan =
DisplayableExecutionPlan::with_full_metrics(input.as_ref())
- .set_metric_types(metric_types.to_vec())
- .set_metric_categories(metric_categories.map(|c| c.to_vec()))
- .set_show_statistics(show_statistics)
- .indent(verbose)
- .to_string();
- plan_builder.append_value(annotated_plan);
-
- type_builder.append_value("Output Rows");
- plan_builder.append_value(total_rows.to_string());
-
- type_builder.append_value("Duration");
- plan_builder.append_value(format!("{duration:?}"));
+ match format {
+ ExplainFormat::Indent => {
+ // TODO use some sort of enum rather than strings?
+ type_builder.append_value("Plan with Metrics");
+ let annotated_plan =
DisplayableExecutionPlan::with_metrics(input.as_ref())
+ .set_metric_types(metric_types.to_vec())
+ .set_metric_categories(metric_categories.map(|c| c.to_vec()))
+ .set_show_statistics(show_statistics)
+ .indent(verbose)
+ .to_string();
+ plan_builder.append_value(annotated_plan);
+ // Verbose output
+ // TODO make this more sophisticated
+ if verbose {
+ type_builder.append_value("Plan with Full Metrics");
+ let annotated_plan =
+ DisplayableExecutionPlan::with_full_metrics(input.as_ref())
+ .set_metric_types(metric_types.to_vec())
+ .set_metric_categories(metric_categories.map(|c|
c.to_vec()))
+ .set_show_statistics(show_statistics)
+ .indent(verbose)
+ .to_string();
+ plan_builder.append_value(annotated_plan);
+ type_builder.append_value("Output Rows");
+ plan_builder.append_value(total_rows.to_string());
+ type_builder.append_value("Duration");
+ plan_builder.append_value(format!("{duration:?}"));
+ }
+ }
+ ExplainFormat::PostgresJSON => {
+ type_builder.append_value("Plan with Metrics");
+ let mut displayable = if verbose {
+ DisplayableExecutionPlan::with_full_metrics(input.as_ref())
+ } else {
+ DisplayableExecutionPlan::with_metrics(input.as_ref())
+ };
+ displayable = displayable
+ .set_metric_types(metric_types.to_vec())
+ .set_metric_categories(metric_categories.map(|c| c.to_vec()))
+ .set_show_statistics(show_statistics);
Review Comment:
Looks like `show_statistics` is ignored in the pgjson path: it’s set here,
but `pgjson()` never uses it. Should this either render stats in the JSON or
reject `show_statistics` for pgjson for now?
--
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]