You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ri...@apache.org on 2023/01/05 18:57:32 UTC

[pinot] branch debug-compatibility-verifier updated (627412e48c -> f13af6b986)

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

richardstartin pushed a change to branch debug-compatibility-verifier
in repository https://gitbox.apache.org/repos/asf/pinot.git


 discard 627412e48c print explain plan for successful verifications to compare against
 discard bf3e2487ee output explain plan when compatibility verifier rejects change in query execution
     new 2ac8cd0827 output explain plan when compatibility verifier rejects change in query execution
     new f13af6b986 print explain plan for successful verifications to compare against

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (627412e48c)
            \
             N -- N -- N   refs/heads/debug-compatibility-verifier (f13af6b986)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/pinot/integration/tests/ClusterIntegrationTestUtils.java  | 1 -
 1 file changed, 1 deletion(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[pinot] 01/02: output explain plan when compatibility verifier rejects change in query execution

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

richardstartin pushed a commit to branch debug-compatibility-verifier
in repository https://gitbox.apache.org/repos/asf/pinot.git

commit 2ac8cd0827e4a0bb0359112c5a533c3a3d0a7a04
Author: Richard Startin <ri...@apache.org>
AuthorDate: Thu Jan 5 18:35:31 2023 +0000

    output explain plan when compatibility verifier rejects change in query execution
---
 .../main/java/org/apache/pinot/compat/QueryOp.java | 27 ++++++---
 .../tests/ClusterIntegrationTestUtils.java         | 37 +-----------
 .../apache/pinot/tools/utils/ExplainPlanUtils.java | 67 ++++++++++++++++++++++
 3 files changed, 89 insertions(+), 42 deletions(-)

diff --git a/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java b/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java
index 2489851d5d..931ad734d5 100644
--- a/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java
+++ b/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java
@@ -26,6 +26,7 @@ import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import org.apache.pinot.common.utils.SqlResultComparator;
 import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.tools.utils.ExplainPlanUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -126,27 +127,29 @@ public class QueryOp extends BaseOp {
           try {
             actualJson = Utils.postSqlQuery(query, ClusterDescriptor.getInstance().getBrokerUrl());
           } catch (Exception e) {
-            LOGGER.error("Comparison FAILED: Line: {} Exception caught while running query: '{}'", queryLineNum, query,
-                e);
+            LOGGER.error("Comparison FAILED: Line: {} Exception caught while running query: '{}', explain plan: {}",
+                queryLineNum, query, getExplainPlan(query), e);
           }
         }
 
         if (expectedJson != null && actualJson != null) {
           try {
-            boolean passed = SqlResultComparator
-                .areEqual(actualJson, expectedJson, query);
+            boolean passed = SqlResultComparator.areEqual(actualJson, expectedJson, query);
             if (passed) {
               succeededQueryCount++;
               LOGGER.debug("Comparison PASSED: Line: {}, query: '{}', actual response: {}, expected response: {}",
                   queryLineNum, query, actualJson, expectedJson);
             } else {
-              LOGGER.error("Comparison FAILED: Line: {}, query: '{}', actual response: {}, expected response: {}",
-                  queryLineNum, query, actualJson, expectedJson);
+              LOGGER.error(
+                  "Comparison FAILED: Line: {}, query: '{}', actual response: {}, expected response: {}, explain "
+                      + "plan: {}",
+                  queryLineNum, query, actualJson, expectedJson, getExplainPlan(query));
             }
           } catch (Exception e) {
             LOGGER.error(
                 "Comparison FAILED: Line: {} Exception caught while comparing query: '{}' actual response: {}, "
-                    + "expected response: {}", queryLineNum, query, actualJson, expectedJson, e);
+                    + "expected response: {}, explain plan: {}", queryLineNum, query, actualJson, expectedJson,
+                getExplainPlan(query), e);
           }
         }
         totalQueryCount++;
@@ -159,4 +162,14 @@ public class QueryOp extends BaseOp {
     }
     return testPassed;
   }
+
+  private static String getExplainPlan(String query) {
+    try {
+      JsonNode explainPlanResponse =
+          Utils.postSqlQuery("explain plan for " + query, ClusterDescriptor.getInstance().getBrokerUrl());
+      return ExplainPlanUtils.formatExplainPlan(explainPlanResponse);
+    } catch (Throwable error) {
+      return error.getMessage();
+    }
+  }
 }
diff --git a/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/ClusterIntegrationTestUtils.java b/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/ClusterIntegrationTestUtils.java
index e8f4d143e2..3a3e867348 100644
--- a/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/ClusterIntegrationTestUtils.java
+++ b/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/ClusterIntegrationTestUtils.java
@@ -41,7 +41,6 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 import java.util.Set;
-import java.util.TreeMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -76,6 +75,7 @@ import org.apache.pinot.spi.stream.StreamDataProvider;
 import org.apache.pinot.spi.utils.JsonUtils;
 import org.apache.pinot.spi.utils.StringUtil;
 import org.apache.pinot.sql.parsers.CalciteSqlParser;
+import org.apache.pinot.tools.utils.ExplainPlanUtils;
 import org.apache.pinot.tools.utils.KafkaStarterUtils;
 import org.testng.Assert;
 
@@ -691,40 +691,7 @@ public class ClusterIntegrationTestUtils {
       throws Exception {
     JsonNode explainPlanForResponse =
         ClusterTest.postQuery("explain plan for " + pinotQuery, brokerUrl, headers, extraJsonProperties);
-    Map<Integer, String> nodesById = new TreeMap<>();
-    JsonNode rows = explainPlanForResponse.get("resultTable").get("rows");
-    int[] parentMapping = new int[rows.size()];
-    for (int i = 0; i < rows.size(); i++) {
-      JsonNode row = rows.get(i);
-      int id = row.get(1).asInt();
-      if (id > 0) {
-        parentMapping[id] = row.get(2).asInt();
-      }
-      nodesById.put(id, row.get(0).asText());
-    }
-    int[] depths = new int[rows.size()];
-    for (Map.Entry<Integer, String> pair : nodesById.entrySet()) {
-      int depth = 0;
-      int id = pair.getKey();
-      int parentId = id;
-      while (parentId > 0) {
-        depth++;
-        parentId = parentMapping[parentId];
-      }
-      if (id > 0) {
-        depths[id] = depth;
-      }
-    }
-    StringBuilder explainPlan = new StringBuilder();
-    for (Map.Entry<Integer, String> pair : nodesById.entrySet()) {
-      explainPlan.append('\n');
-      int id = pair.getKey();
-      for (int i = 0; id > 0 && i < depths[id]; i++) {
-        explainPlan.append('\t');
-      }
-      explainPlan.append(pair.getValue());
-    }
-    return explainPlan.toString();
+    return ExplainPlanUtils.formatExplainPlan(explainPlanForResponse);
   }
 
   private static int getH2ExpectedValues(Set<String> expectedValues, List<String> expectedOrderByValues,
diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/utils/ExplainPlanUtils.java b/pinot-tools/src/main/java/org/apache/pinot/tools/utils/ExplainPlanUtils.java
new file mode 100644
index 0000000000..74da8b45a5
--- /dev/null
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/utils/ExplainPlanUtils.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.tools.utils;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.Map;
+import java.util.TreeMap;
+
+
+public class ExplainPlanUtils {
+
+  private ExplainPlanUtils() {
+  }
+
+  public static String formatExplainPlan(JsonNode explainPlanJson) {
+    Map<Integer, String> nodesById = new TreeMap<>();
+    JsonNode rows = explainPlanJson.get("resultTable").get("rows");
+    int[] parentMapping = new int[rows.size()];
+    for (int i = 0; i < rows.size(); i++) {
+      JsonNode row = rows.get(i);
+      int id = row.get(1).asInt();
+      if (id > 0) {
+        parentMapping[id] = row.get(2).asInt();
+      }
+      nodesById.put(id, row.get(0).asText());
+    }
+    int[] depths = new int[rows.size()];
+    for (Map.Entry<Integer, String> pair : nodesById.entrySet()) {
+      int depth = 0;
+      int id = pair.getKey();
+      int parentId = id;
+      while (parentId > 0) {
+        depth++;
+        parentId = parentMapping[parentId];
+      }
+      if (id > 0) {
+        depths[id] = depth;
+      }
+    }
+    StringBuilder explainPlan = new StringBuilder();
+    for (Map.Entry<Integer, String> pair : nodesById.entrySet()) {
+      explainPlan.append('\n');
+      int id = pair.getKey();
+      for (int i = 0; id > 0 && i < depths[id]; i++) {
+        explainPlan.append('\t');
+      }
+      explainPlan.append(pair.getValue());
+    }
+    return explainPlan.toString();
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[pinot] 02/02: print explain plan for successful verifications to compare against

Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

richardstartin pushed a commit to branch debug-compatibility-verifier
in repository https://gitbox.apache.org/repos/asf/pinot.git

commit f13af6b986b6ea8e298e2bac14a6acfafca11b9c
Author: Richard Startin <ri...@apache.org>
AuthorDate: Thu Jan 5 18:57:09 2023 +0000

    print explain plan for successful verifications to compare against
---
 .../src/main/java/org/apache/pinot/compat/QueryOp.java           | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java b/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java
index 931ad734d5..66bc45d6b0 100644
--- a/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java
+++ b/pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/QueryOp.java
@@ -137,13 +137,14 @@ public class QueryOp extends BaseOp {
             boolean passed = SqlResultComparator.areEqual(actualJson, expectedJson, query);
             if (passed) {
               succeededQueryCount++;
-              LOGGER.debug("Comparison PASSED: Line: {}, query: '{}', actual response: {}, expected response: {}",
-                  queryLineNum, query, actualJson, expectedJson);
+              LOGGER.debug(
+                  "Comparison PASSED: Line: {}, query: '{}', actual response: {}, expected response: {}, explain "
+                      + "plan: {}",
+                  queryLineNum, query, actualJson, expectedJson, getExplainPlan(query));
             } else {
               LOGGER.error(
                   "Comparison FAILED: Line: {}, query: '{}', actual response: {}, expected response: {}, explain "
-                      + "plan: {}",
-                  queryLineNum, query, actualJson, expectedJson, getExplainPlan(query));
+                      + "plan: {}", queryLineNum, query, actualJson, expectedJson, getExplainPlan(query));
             }
           } catch (Exception e) {
             LOGGER.error(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org