This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-9594-8c8cdc86cf87445359c916bb7f0e7893aab0712e
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 8f83565a1ab1f08192342f1378ff36db807c4399
Author: Kunwoo (Chris) <[email protected]>
AuthorDate: Sun Nov 22 19:55:20 2026 +0000

    fix(frontend): read the runtime stats fields the backend sends (#9594)
    
    ### What changes were proposed in this PR?
    
    Problem. The runtime stats endpoint returns `dataProcessingTime`,
    `controlProcessingTime`, `idleTime` and `numWorkers`, but the frontend
    `WorkflowRuntimeStatistics` type reads `totalDataProcessingTime`,
    `totalControlProcessingTime`, `totalIdleTime` and `numberOfWorkers`.
    Every one of those values is `undefined`, so the three time tabs and the
    Number of Workers tab in Runtime Statistics draw no lines, and the
    heat-map restore gives each operator no processing time and one worker.
    
    Fix. Renames the four fields in the frontend type, the Runtime
    Statistics chart component and `runtime-statistics-mapper.ts` to the
    names the backend sends. The backend names already match the Iceberg
    runtime statistics schema, so the REST response does not change. It also
    drops the type's `[key: string]: any` index signature, which let the
    chart's metric keys name fields the type never declared, and types those
    keys against the interface so the next mismatch fails to compile.
    
    ```
    Before:  GET /stats -> { numWorkers: 32 } -> chart reads numberOfWorkers -> 
undefined -> empty chart
    After:   GET /stats -> { numWorkers: 32 } -> chart reads numWorkers      -> 
32
    ```
    
    The Number of Workers tab for the same completed execution, before and
    after:
    
    | Before | After |
    | --- | --- |
    | <img width="563" height="500" alt="runtime-stats-before"
    
src="https://github.com/user-attachments/assets/2bbb010b-6409-47c5-a2f8-76e78d81f6b1";
    /> | <img width="563" height="500" alt="runtime-stats-after"
    
src="https://github.com/user-attachments/assets/f7b8f688-5b62-429a-b67f-d3c02bcff58e";
    /> |
    
    Not included. The final stats snapshot of a run can race the writer
    close in `ExecutionStatsService` (persist runs on its own thread, close
    runs on the callback thread), which is a separate backend issue.
    
    ### Any related issues, documentation, discussions?
    
    Closes #9590. Possibly related: #4152.
    
    ### How was this PR tested?
    
    Two tests were added that parse the endpoint's JSON exactly as
    `WorkflowExecutionsResource.WorkflowRuntimeStatistics` serializes it,
    one for the chart datasets and one for the heat-map mapper, so a rename
    on either side fails a test. The existing specs built rows with the
    frontend names, which is why they missed this. With the old production
    code and the new specs, both new tests fail along with 5 existing ones.
    
    ```
    cd frontend && npx ng test --watch=false 
--include='**/workflow-runtime-statistics.component.spec.ts' 
--include='**/runtime-statistics-mapper.spec.ts' 
--include='**/heatmap-stats-restore.service.spec.ts'
    cd frontend && npx ng test --watch=false
    ```
    
    The first command passes 39 tests, including one that feeds the old
    field names and checks the mapper ignores them. The second passes 6,875
    tests; 9 unrelated spec files (formly, code editor, versions list) did
    not load because `monaco-languageclient` cannot resolve a subpath on
    Node 23.7, and they fail the same way without this change. `ngc -p
    src/tsconfig.app.json --noEmit`, `ngc -p src/tsconfig.spec.json
    --noEmit`, `prettier-eslint` and `eslint` ran clean on the changed
    files.
    
    Checked in a browser against a local stack on a completed execution with
    1,730 stats rows: before the change every Number of Workers point is
    `undefined` and the chart is empty; after it the chart shows 32 workers
    for the Python UDF and 2 then 4 for the hash join, and Total Data
    Processing Time plots up to about 16,000 s. The heat-map restore after a
    page refresh was not clicked through and is covered by the mapper test
    only.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code, Claude Opus 5.5
---
 .../workflow-runtime-statistics.component.spec.ts  | 55 ++++++++++++++--------
 .../workflow-runtime-statistics.component.ts       | 16 +++----
 .../dashboard/type/workflow-runtime-statistics.ts  |  9 ++--
 .../heatmap/heatmap-stats-restore.service.spec.ts  |  8 ++--
 .../heatmap/runtime-statistics-mapper.spec.ts      | 42 +++++++++++++----
 .../service/heatmap/runtime-statistics-mapper.ts   |  8 ++--
 6 files changed, 89 insertions(+), 49 deletions(-)

diff --git 
a/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.spec.ts
 
b/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.spec.ts
index 12e3647d41..c7b15a2230 100644
--- 
a/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.spec.ts
+++ 
b/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.spec.ts
@@ -57,10 +57,10 @@ describe("WorkflowRuntimeStatisticsComponent", () => {
       inputTupleSize: 0,
       outputTupleCount: 0,
       outputTupleSize: 0,
-      totalDataProcessingTime: 0,
-      totalControlProcessingTime: 0,
-      totalIdleTime: 0,
-      numberOfWorkers: 1,
+      dataProcessingTime: 0,
+      controlProcessingTime: 0,
+      idleTime: 0,
+      numWorkers: 1,
       status: 0,
       ...overrides,
     };
@@ -79,10 +79,10 @@ describe("WorkflowRuntimeStatisticsComponent", () => {
         inputTupleSize: 11,
         outputTupleCount: 12,
         outputTupleSize: 13,
-        totalDataProcessingTime: 2 * NANOS,
-        totalControlProcessingTime: 3 * NANOS,
-        totalIdleTime: 4 * NANOS,
-        numberOfWorkers: 1,
+        dataProcessingTime: 2 * NANOS,
+        controlProcessingTime: 3 * NANOS,
+        idleTime: 4 * NANOS,
+        numWorkers: 1,
       }),
       makeStat({
         operatorId: "scan-op-111111",
@@ -91,17 +91,17 @@ describe("WorkflowRuntimeStatisticsComponent", () => {
         inputTupleSize: 21,
         outputTupleCount: 22,
         outputTupleSize: 23,
-        totalDataProcessingTime: 5 * NANOS,
-        totalControlProcessingTime: 6 * NANOS,
-        totalIdleTime: 7 * NANOS,
-        numberOfWorkers: 2,
+        dataProcessingTime: 5 * NANOS,
+        controlProcessingTime: 6 * NANOS,
+        idleTime: 7 * NANOS,
+        numWorkers: 2,
       }),
       makeStat({
         operatorId: "filter-op-222222",
         timestamp: 2000,
         inputTupleCount: 100,
-        totalDataProcessingTime: 1 * NANOS,
-        numberOfWorkers: 4,
+        dataProcessingTime: 1 * NANOS,
+        numWorkers: 4,
       }),
     ];
   }
@@ -181,13 +181,13 @@ describe("WorkflowRuntimeStatisticsComponent", () => {
 
     // Two stats for scan-op-111111 collapsed under one group key; one for 
filter.
     expect(Object.keys(grouped).sort()).toEqual(["filter-op-222222", 
"scan-op-111111"]);
-    const scan = grouped["scan-op-111111"] as Array<WorkflowRuntimeStatistics 
& { dataProcessingTime: number }>;
+    const scan = grouped["scan-op-111111"];
     expect(scan.length).toBe(2);
-    // totalDataProcessingTime (2e9, 5e9 ns) divided by 1e9 => seconds.
+    // dataProcessingTime (2e9, 5e9 ns) divided by 1e9 => seconds.
     expect(scan.map(s => s.dataProcessingTime)).toEqual([2, 5]);
     // control/idle also converted ns->s on the first stat (3e9 -> 3, 4e9 -> 
4).
-    expect((scan[0] as unknown as { controlProcessingTime: number 
}).controlProcessingTime).toBe(3);
-    expect((scan[0] as unknown as { idleTime: number }).idleTime).toBe(4);
+    expect(scan[0].controlProcessingTime).toBe(3);
+    expect(scan[0].idleTime).toBe(4);
     // timestamps made relative to the first stat (1000): 0 and 2000.
     expect(scan.map(s => s.timestamp)).toEqual([0, 2000]);
     // filter stat timestamp 2000 - initial 1000 = 1000.
@@ -307,7 +307,7 @@ describe("WorkflowRuntimeStatisticsComponent", () => {
     expect(gd.data).toBeUndefined();
   });
 
-  it("createDataset falls back to the numberOfWorkers metric for an 
out-of-range metric index", async () => {
+  it("createDataset falls back to the numWorkers metric for an out-of-range 
metric index", async () => {
     await createFixture({ workflowRuntimeStatistics: validStats() });
     const grouped = group();
 
@@ -317,10 +317,25 @@ describe("WorkflowRuntimeStatisticsComponent", () => {
     // There are 8 metric keys (indices 0..7), so index 8 selects none of them.
     const outOfRange = seriesNamed(dataset(8, grouped), "scan-111111");
 
-    // It falls back to numberOfWorkers, i.e. the same series metric index 7 
selects...
+    // It falls back to numWorkers, i.e. the same series metric index 7 
selects...
     expect(outOfRange.y).toEqual([1, 2]);
     expect(outOfRange.y).toEqual(seriesNamed(dataset(7, grouped), 
"scan-111111").y);
     // ...and not the metric-0 series, so the fallback really did pick a 
different key.
     expect(outOfRange.y).not.toEqual(seriesNamed(dataset(0, grouped), 
"scan-111111").y);
   });
+
+  it("plots the time and worker charts from the JSON the stats endpoint 
returns", async () => {
+    // Parsed from the exact body 
`WorkflowExecutionsResource.WorkflowRuntimeStatistics` serializes, so a renamed
+    // field on either side fails here instead of plotting an all-empty chart.
+    const fromBackend: WorkflowRuntimeStatistics[] = JSON.parse(
+      
'[{"operatorId":"scan-op-111111","timestamp":1000,"inputTupleCount":10,"inputTupleSize":80,'
 +
+        
'"outputTupleCount":5,"outputTupleSize":40,"dataProcessingTime":2000000000,' +
+        
'"controlProcessingTime":3000000000,"idleTime":4000000000,"numWorkers":3,"status":3}]'
+    );
+    await createFixture({ workflowRuntimeStatistics: fromBackend });
+    const grouped = group();
+
+    // Metric indices 4..7 are data time, control time, idle time and number 
of workers.
+    expect([4, 5, 6, 7].map(i => seriesNamed(dataset(i, grouped), 
"scan-111111").y)).toEqual([[2], [3], [4], [3]]);
+  });
 });
diff --git 
a/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.ts
 
b/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.ts
index 1525e6c730..8ae73ff1a3 100644
--- 
a/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.ts
+++ 
b/frontend/src/app/dashboard/component/user/user-workflow/ngbd-modal-workflow-executions/workflow-runtime-statistics/workflow-runtime-statistics.component.ts
@@ -75,7 +75,8 @@ export class WorkflowRuntimeStatisticsComponent implements 
OnInit {
 
   /**
    * Groups statistics by operator ID, converting times from nanoseconds to 
seconds,
-   * and adjusts timestamps relative to the initial timestamp.
+   * and adjusts timestamps relative to the initial timestamp. The grouped 
rows keep the
+   * same field names, so their time fields hold seconds, not the API's 
nanoseconds.
    */
   private groupStatisticsByOperatorId(): Record<string, 
WorkflowRuntimeStatistics[]> {
     if (!this.workflowRuntimeStatistics || 
this.workflowRuntimeStatistics.length === 0) {
@@ -96,10 +97,9 @@ export class WorkflowRuntimeStatisticsComponent implements 
OnInit {
 
         const processedStat = {
           ...stat,
-          dataProcessingTime: stat.totalDataProcessingTime / 
NANOSECONDS_TO_SECONDS,
-          controlProcessingTime: stat.totalControlProcessingTime / 
NANOSECONDS_TO_SECONDS,
-          idleTime: stat.totalIdleTime / NANOSECONDS_TO_SECONDS,
-          numberOfWorkers: stat.numberOfWorkers,
+          dataProcessingTime: stat.dataProcessingTime / NANOSECONDS_TO_SECONDS,
+          controlProcessingTime: stat.controlProcessingTime / 
NANOSECONDS_TO_SECONDS,
+          idleTime: stat.idleTime / NANOSECONDS_TO_SECONDS,
           timestamp: stat.timestamp - initialTimestamp,
         };
 
@@ -123,7 +123,7 @@ export class WorkflowRuntimeStatisticsComponent implements 
OnInit {
       return [];
     }
 
-    const metricKeys = [
+    const metricKeys: (keyof WorkflowRuntimeStatistics)[] = [
       "inputTupleCount",
       "inputTupleSize",
       "outputTupleCount",
@@ -131,10 +131,10 @@ export class WorkflowRuntimeStatisticsComponent 
implements OnInit {
       "dataProcessingTime",
       "controlProcessingTime",
       "idleTime",
-      "numberOfWorkers",
+      "numWorkers",
     ];
 
-    const yValuesKey = metricKeys[metricIndex] || "numberOfWorkers";
+    const yValuesKey = metricKeys[metricIndex] || "numWorkers";
 
     return Object.entries(this.groupedStatistics)
       .map(([operatorId, stats]) => {
diff --git a/frontend/src/app/dashboard/type/workflow-runtime-statistics.ts 
b/frontend/src/app/dashboard/type/workflow-runtime-statistics.ts
index 2ef5b24b9e..8a43cf4e6c 100644
--- a/frontend/src/app/dashboard/type/workflow-runtime-statistics.ts
+++ b/frontend/src/app/dashboard/type/workflow-runtime-statistics.ts
@@ -18,16 +18,15 @@
  */
 
 export interface WorkflowRuntimeStatistics {
-  [key: string]: any;
   operatorId: string;
   timestamp: number;
   inputTupleCount: number;
   inputTupleSize: number;
   outputTupleCount: number;
   outputTupleSize: number;
-  totalDataProcessingTime: number;
-  totalControlProcessingTime: number;
-  totalIdleTime: number;
-  numberOfWorkers: number;
+  dataProcessingTime: number; // nanoseconds
+  controlProcessingTime: number; // nanoseconds
+  idleTime: number; // nanoseconds
+  numWorkers: number;
   status: number; // Operator status (e.g., RUNNING, COMPLETED, FAILED, etc.)
 }
diff --git 
a/frontend/src/app/workspace/service/heatmap/heatmap-stats-restore.service.spec.ts
 
b/frontend/src/app/workspace/service/heatmap/heatmap-stats-restore.service.spec.ts
index f017a21c0e..45f5dbbcda 100644
--- 
a/frontend/src/app/workspace/service/heatmap/heatmap-stats-restore.service.spec.ts
+++ 
b/frontend/src/app/workspace/service/heatmap/heatmap-stats-restore.service.spec.ts
@@ -59,10 +59,10 @@ function makeStatsRow(overrides: 
Partial<WorkflowRuntimeStatistics>): WorkflowRu
     inputTupleSize: 100,
     outputTupleCount: 5,
     outputTupleSize: 50,
-    totalDataProcessingTime: 1_000_000,
-    totalControlProcessingTime: 2_000,
-    totalIdleTime: 3_000,
-    numberOfWorkers: 2,
+    dataProcessingTime: 1_000_000,
+    controlProcessingTime: 2_000,
+    idleTime: 3_000,
+    numWorkers: 2,
     status: 3,
     ...overrides,
   };
diff --git 
a/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.spec.ts 
b/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.spec.ts
index 64d1c0bf83..6cdc8fc1c3 100644
--- 
a/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.spec.ts
+++ 
b/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.spec.ts
@@ -29,10 +29,10 @@ function makeRow(overrides: 
Partial<WorkflowRuntimeStatistics>): WorkflowRuntime
     inputTupleSize: 0,
     outputTupleCount: 0,
     outputTupleSize: 0,
-    totalDataProcessingTime: 0,
-    totalControlProcessingTime: 0,
-    totalIdleTime: 0,
-    numberOfWorkers: 1,
+    dataProcessingTime: 0,
+    controlProcessingTime: 0,
+    idleTime: 0,
+    numWorkers: 1,
     status: 3,
     ...overrides,
   };
@@ -65,10 +65,10 @@ describe("toOperatorRuntimeStatusMap", () => {
         inputTupleSize: 8_000,
         outputTupleCount: 250,
         outputTupleSize: 2_000,
-        totalDataProcessingTime: 5_000_000,
-        totalControlProcessingTime: 1_000_000,
-        totalIdleTime: 700_000,
-        numberOfWorkers: 2,
+        dataProcessingTime: 5_000_000,
+        controlProcessingTime: 1_000_000,
+        idleTime: 700_000,
+        numWorkers: 2,
         status: 1,
       }),
     ]);
@@ -88,6 +88,32 @@ describe("toOperatorRuntimeStatusMap", () => {
     });
   });
 
+  // One row exactly as `WorkflowExecutionsResource.WorkflowRuntimeStatistics` 
serializes it.
+  const BACKEND_BODY =
+    
'[{"operatorId":"op1","timestamp":1700000000000,"inputTupleCount":10,"inputTupleSize":80,'
 +
+    
'"outputTupleCount":5,"outputTupleSize":40,"dataProcessingTime":5000000,"controlProcessingTime":1000000,'
 +
+    '"idleTime":700000,"numWorkers":3,"status":3}]';
+
+  it("reads the timing and worker fields from the JSON the stats endpoint 
returns", () => {
+    // A renamed field on either side fails here instead of restoring zero 
times and one worker.
+    const restored = toOperatorRuntimeStatusMap(JSON.parse(BACKEND_BODY)).op1;
+    expect(restored.aggregatedDataProcessingTime).toBe(5_000_000);
+    expect(restored.aggregatedControlProcessingTime).toBe(1_000_000);
+    expect(restored.aggregatedIdleTime).toBe(700_000);
+    expect(restored.numWorkers).toBe(3);
+  });
+
+  it("ignores the legacy total*/numberOfWorkers names", () => {
+    const legacyBody =
+      
'[{"operatorId":"op1","timestamp":1,"totalDataProcessingTime":5000000,"totalControlProcessingTime":1000000,'
 +
+      '"totalIdleTime":700000,"numberOfWorkers":3,"status":3}]';
+    const restored = toOperatorRuntimeStatusMap(JSON.parse(legacyBody)).op1;
+    expect(restored.aggregatedDataProcessingTime).toBeUndefined();
+    expect(restored.aggregatedControlProcessingTime).toBeUndefined();
+    expect(restored.aggregatedIdleTime).toBeUndefined();
+    expect(restored.numWorkers).toBeUndefined();
+  });
+
   it("omits the port maps rather than emitting empty ones, so port labels 
survive a restore", () => {
     // An empty map reads as "every port measured zero" and makes 
JointUIService write 0 over
     // the port display names; absent means "no per-port information" and 
leaves them alone.
diff --git 
a/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.ts 
b/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.ts
index 980c6bd6da..2b0cdad1ac 100644
--- a/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.ts
+++ b/frontend/src/app/workspace/service/heatmap/runtime-statistics-mapper.ts
@@ -68,10 +68,10 @@ export function toOperatorRuntimeStatusMap(rows: 
WorkflowRuntimeStatistics[]): R
       aggregatedInputSize: row.inputTupleSize,
       aggregatedOutputRowCount: row.outputTupleCount,
       aggregatedOutputSize: row.outputTupleSize,
-      numWorkers: row.numberOfWorkers,
-      aggregatedDataProcessingTime: row.totalDataProcessingTime,
-      aggregatedControlProcessingTime: row.totalControlProcessingTime,
-      aggregatedIdleTime: row.totalIdleTime,
+      numWorkers: row.numWorkers,
+      aggregatedDataProcessingTime: row.dataProcessingTime,
+      aggregatedControlProcessingTime: row.controlProcessingTime,
+      aggregatedIdleTime: row.idleTime,
     };
   }
   return result;

Reply via email to