nuno-faria commented on code in PR #19316:
URL: https://github.com/apache/datafusion/pull/19316#discussion_r2616946012
##########
datafusion/physical-plan/src/analyze.rs:
##########
@@ -101,6 +121,20 @@ impl AnalyzeExec {
input.boundedness(),
)
}
+
+ pub fn enable_auto_explain(&mut self) {
+ self.auto_explain = true;
+ self.cache =
+ Self::compute_properties(&self.input,
Arc::clone(&self.input.schema()));
Review Comment:
Needs to be recomputed since the output changes.
##########
datafusion/physical-plan/src/analyze.rs:
##########
@@ -194,26 +228,49 @@ impl ExecutionPlan for AnalyzeExec {
// JoinSet that computes the overall row count and final
// record batch
let mut input_stream = builder.build();
+
+ let inner_schema = Arc::clone(&self.input.schema());
+ let auto_explain = self.auto_explain;
+ let auto_explain_output = self.auto_explain_output.clone();
+ let auto_explain_min_duration = self.auto_explain_min_duration;
+
let output = async move {
+ let mut batches = vec![];
let mut total_rows = 0;
while let Some(batch) = input_stream.next().await.transpose()? {
total_rows += batch.num_rows();
+ batches.push(batch);
}
let duration = Instant::now() - start;
- create_output_batch(
+ let out = create_output_batch(
verbose,
show_statistics,
total_rows,
duration,
&captured_input,
&captured_schema,
&metric_types,
- )
+ )?;
+
+ if auto_explain {
+ if duration.as_millis() >= auto_explain_min_duration as u128 {
+ export_auto_explain(out, &auto_explain_output)?;
+ }
+ concat_batches(&inner_schema,
&batches).map_err(DataFusionError::from)
+ } else {
+ Ok(out)
+ }
Review Comment:
The `auto_explain` mode will return the input's batches instead of the
analyze.
--
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]