From bc814f40a368453d74348aeeafbb4fbd4ab6c1d4 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Wed, 24 Jun 2026 20:38:38 -0700 Subject: [PATCH] PHOENIX-7937 Trim whitespace in EXPLAIN FORMAT JSON scan attributes Co-authored-by: Claude Opus 4.8[1m] --- .../java/org/apache/phoenix/iterate/ExplainTable.java | 7 ++++--- .../org/apache/phoenix/query/explain/ExplainPlanTest.java | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.java b/phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.java index 88ccead7f30..ac6d927dd66 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.java @@ -344,10 +344,10 @@ protected void explain(String prefix, List planSteps, if (OrderBy.REV_ROW_KEY_ORDER_BY.equals(orderBy)) { explainPlanAttributesBuilder.setClientSortedBy("REVERSE"); } - explainPlanAttributesBuilder.setExplainScanType(scanTypeDetails); + explainPlanAttributesBuilder.setExplainScanType(scanTypeDetails.trim()); explainPlanAttributesBuilder.setTableName(tableName); if (!scanRanges.isPointLookup()) { - explainPlanAttributesBuilder.setKeyRanges(appendKeyRanges()); + explainPlanAttributesBuilder.setKeyRanges(appendKeyRanges().trim()); } } @@ -662,7 +662,8 @@ public static void overrideMutationProject(List planSteps, if (countProject == null || countProject.isEmpty()) { return; } - // Only override the internal COUNT(*)/COUNT(1) aggregate projection used for mutation row counts. + // Only override the internal COUNT(*)/COUNT(1) aggregate projection used for mutation row + // counts. if (countProject.size() != 1 || !countProject.get(0).startsWith("COUNT(")) { return; } diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.java index 50764d27934..72c9149f553 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.java @@ -874,9 +874,9 @@ public void testMultiTenantView() throws Exception { " REGIONS PLANNED ", " SERVER 1 ROW LIMIT", "CLIENT 1 ROW LIMIT"), attrs().put("tenantId", TENANT_ID).put("viewName", MT_VIEW).put("viewBaseName", MT_BASE) .put("iteratorTypeAndScanSize", "SERIAL -WAY").put("consistency", "STRONG") - .put("explainScanType", "RANGE SCAN ").put("tableName", "EO_MT_BASE") + .put("explainScanType", "RANGE SCAN").put("tableName", "EO_MT_BASE") .put("indexName", "EO_MT_VIEW").put("indexRule", "data table") - .put("keyRanges", " ['tenant42']").put("serverRowLimit", 1).put("clientRowLimit", 1) + .put("keyRanges", "['tenant42']").put("serverRowLimit", 1).put("clientRowLimit", 1) .set("clientSteps", clientSteps("CLIENT 1 ROW LIMIT"))); } @@ -1894,7 +1894,7 @@ private static ObjectNode scanAttrs(String scanType, String table, String keys) ObjectNode n = defaultAttrs(); n.put("iteratorTypeAndScanSize", "PARALLEL -WAY"); n.put("consistency", "STRONG"); - n.put("explainScanType", scanType); + n.put("explainScanType", scanType.trim()); n.put("tableName", table); // For a data table scan the per scan INDEX line names the same entity as tableName. View and // index scans that diverge override indexName on the returned node. @@ -1903,7 +1903,7 @@ private static ObjectNode scanAttrs(String scanType, String table, String keys) // A point lookup short-circuits to the point lookup rule. Index targets set their own rule. n.put("indexRule", scanType.trim().startsWith("POINT LOOKUP") ? "point lookup" : "data table"); if (keys != null) { - n.put("keyRanges", keys); + n.put("keyRanges", keys.trim()); } return n; }