martin-g commented on code in PR #1949:
URL: 
https://github.com/apache/datafusion-ballista/pull/1949#discussion_r3558682276


##########
ballista/scheduler/src/api/handlers.rs:
##########
@@ -22,9 +22,10 @@ use axum::{
     extract::{Path, State},
     response::{IntoResponse, Response},
 };
+use ballista_core::serde::protobuf::failed_task::FailedReason::*;

Review Comment:
   nit: I personally prefer avoiding glob-importing. Not sure what the other 
devs prefer though.



##########
ballista-cli/src/tui/ui/main/jobs/stage_tasks_popup.rs:
##########
@@ -101,18 +101,16 @@ fn build_stage_task_row(i: usize, task: 
&StageTaskResponse, app: &App) -> Row<'s
         app.theme.row_odd
     };
 
-    let status_style = match task.status.as_str() {
-        "Running" => app.theme.status_running,
-        "Queued" => app.theme.status_queued,
-        "Successful" | "Completed" => app.theme.status_completed,
-        "Failed" => app.theme.status_failed,
-        _ => app.theme.status_unknown,
+    let (status_label, status_style) = match &task.status {
+        StageTaskStatus::Running => ("Running", app.theme.status_running),
+        StageTaskStatus::Successful => ("Successful", 
app.theme.status_completed),
+        StageTaskStatus::Failed { reason } => (reason.as_str(), 
app.theme.status_failed),
     };
 
     Row::new(vec![
         Cell::from(Text::from(task.id.to_string()).right_aligned()),
         Cell::from(
-            Text::from(task.status.clone())
+            Text::from(status_label.to_string())
                 .style(status_style)
                 .centered(),

Review Comment:
   nit: Since a failure is a "cold path" we could optimize this a bit by 
allocating a new String only for failures:
   
   ```suggestion
       let status_text = match &task.status {
           StageTaskStatus::Running => Text::from("Running").style( 
app.theme.status_running),
           StageTaskStatus::Successful => Text::from("Successful").style( 
app.theme.status_completed),
           StageTaskStatus::Failed { reason } => 
Text::from(reason.clone()).style( app.theme.status_failed),
       };
   
       Row::new(vec![
           Cell::from(Text::from(task.id.to_string()).right_aligned()),
           Cell::from(status_text.centered()),
   ```



##########
ballista/scheduler/src/api/handlers.rs:
##########
@@ -637,6 +641,54 @@ pub async fn get_query_stages<
                             })
                             .collect();
                     }
+                    ExecutionStage::Failed(failed_stage) => {
+                        let metrics = 
failed_stage.stage_metrics.as_deref().unwrap_or(&[]);
+                        summary.stage_plan = Some(match plan_format {
+                            PlanFormat::Default => 
displayable(failed_stage.plan.as_ref()).indent(false).to_string(),
+                            PlanFormat::Tree    => 
displayable(failed_stage.plan.as_ref()).tree_render().to_string(),

Review Comment:
   ```suggestion
                               PlanFormat::Tree => 
displayable(failed_stage.plan.as_ref()).tree_render().to_string(),
   ```
   nit: No need of manual formatting.



-- 
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]

Reply via email to