diff --git a/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js b/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js index ac266bd63d080..a287f5da9acac 100644 --- a/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js +++ b/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js @@ -15,7 +15,7 @@ * limitations under the License. */ -/* global $, d3, dagreD3, graphlibDot, uiRoot, appBasePath */ +/* global $, d3, dagreD3, graphlibDot, uiRoot, appBasePath, sorttable */ var PlanVizConstants = { svgMarginX: 16, @@ -441,7 +441,7 @@ function updateDetailsPanel(nodeId, nodeDetails) { var html = ""; if (details.metrics && details.metrics.length > 0) { - html += buildMetricsTable(details.metrics, showStageTask); + html += buildMetricsTable(details.metrics, showStageTask, true); } else if (!details.children) { html += '
No metrics
'; } @@ -453,7 +453,7 @@ function updateDetailsPanel(nodeId, nodeDetails) { if (child) { html += 'No metrics
'; } @@ -461,6 +461,13 @@ function updateDetailsPanel(nodeId, nodeDetails) { }); } bodyEl.innerHTML = html; + + // Initialize sorttable on dynamically injected metrics tables + if (typeof sorttable !== "undefined") { + bodyEl.querySelectorAll("table.sortable").forEach(function (table) { + sorttable.makeSortable(table); + }); + } } function htmlEscape(str) { @@ -471,8 +478,9 @@ function htmlEscape(str) { /* * Build an HTML metrics table from a metrics array. */ -function buildMetricsTable(metrics, showStageTask) { - var html = '| Metric | Value |
|---|