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

(pinot) branch master updated: [test] fix multi-stage explain error test (#12098)

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

rongr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 3474db4abb [test] fix multi-stage explain error test (#12098)
3474db4abb is described below

commit 3474db4abb27d41796fbac4da3ea25512bb55349
Author: Rong Rong <ro...@apache.org>
AuthorDate: Wed Dec 6 10:37:54 2023 -0800

    [test] fix multi-stage explain error test (#12098)
    
    Co-authored-by: Rong Rong <ro...@startree.ai>
---
 .../query/queries/ResourceBasedQueryPlansTest.java |   9 +-
 .../src/test/resources/queries/JoinPlans.json      |   2 +-
 .../resources/queries/LiteralEvaluationPlans.json  |   2 +-
 .../src/test/resources/queries/SetOpPlans.json     |   2 +-
 .../resources/queries/ValidationErrorPlan.json     |   8 +-
 .../resources/queries/WindowFunctionPlans.json     | 110 ++++++++++-----------
 6 files changed, 66 insertions(+), 67 deletions(-)

diff --git a/pinot-query-planner/src/test/java/org/apache/pinot/query/queries/ResourceBasedQueryPlansTest.java b/pinot-query-planner/src/test/java/org/apache/pinot/query/queries/ResourceBasedQueryPlansTest.java
index 5f22006c04..e311880349 100644
--- a/pinot-query-planner/src/test/java/org/apache/pinot/query/queries/ResourceBasedQueryPlansTest.java
+++ b/pinot-query-planner/src/test/java/org/apache/pinot/query/queries/ResourceBasedQueryPlansTest.java
@@ -78,10 +78,11 @@ public class ResourceBasedQueryPlansTest extends QueryEnvironmentTestBase {
       if (expectedException == null) {
         throw e;
       } else {
-        Pattern pattern = Pattern.compile(expectedException);
-        Assert.assertTrue(pattern.matcher(e.getMessage()).matches(),
-            String.format("Caught exception '%s' for test case '%s', but it did not match the expected pattern '%s'.",
-                e.getMessage(), testCaseName, expectedException));
+        Pattern pattern = Pattern.compile(expectedException + "((.|\\n)*)");
+        // always get the cause error instead of the top wrapper: those always are parsing or composing error.
+        Assert.assertTrue(pattern.matcher(e.getCause().getMessage()).matches(),
+            String.format("Caught unexpected exception test case '%s'\nexpected pattern '%s'\nactual msg: '%s'.",
+                testCaseName, expectedException, e.getCause().getMessage()));
       }
     }
   }
diff --git a/pinot-query-planner/src/test/resources/queries/JoinPlans.json b/pinot-query-planner/src/test/resources/queries/JoinPlans.json
index 7ce235acf0..41ba0c9618 100644
--- a/pinot-query-planner/src/test/resources/queries/JoinPlans.json
+++ b/pinot-query-planner/src/test/resources/queries/JoinPlans.json
@@ -524,7 +524,7 @@
       {
         "description": "Incorrect table",
         "sql": "EXPLAIN PLAN FOR SELECT b.col1 - a.col3 FROM a JOIN c ON a.col1 = c.col3",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Table 'b' not found.*"
       }
     ]
   }
diff --git a/pinot-query-planner/src/test/resources/queries/LiteralEvaluationPlans.json b/pinot-query-planner/src/test/resources/queries/LiteralEvaluationPlans.json
index 4d82a770c9..52393c1bb3 100644
--- a/pinot-query-planner/src/test/resources/queries/LiteralEvaluationPlans.json
+++ b/pinot-query-planner/src/test/resources/queries/LiteralEvaluationPlans.json
@@ -154,7 +154,7 @@
       {
         "description": "select non-exist literal function",
         "sql": "EXPLAIN PLAN FOR Select nonExistFun(1,2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*No match found for function signature nonExistFun.*"
       }
     ]
   }
diff --git a/pinot-query-planner/src/test/resources/queries/SetOpPlans.json b/pinot-query-planner/src/test/resources/queries/SetOpPlans.json
index 1e0991e96a..0cc8111ec3 100644
--- a/pinot-query-planner/src/test/resources/queries/SetOpPlans.json
+++ b/pinot-query-planner/src/test/resources/queries/SetOpPlans.json
@@ -106,7 +106,7 @@
       {
         "description": "Incorrect selection list ",
         "sql": "EXPLAIN PLAN FOR SELECT col1, col3 FROM a UNION ALL SELECT col1 FROM b",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Column count mismatch in UNION.*"
       }
     ]
   }
diff --git a/pinot-query-planner/src/test/resources/queries/ValidationErrorPlan.json b/pinot-query-planner/src/test/resources/queries/ValidationErrorPlan.json
index 1544ef66f4..980f521586 100644
--- a/pinot-query-planner/src/test/resources/queries/ValidationErrorPlan.json
+++ b/pinot-query-planner/src/test/resources/queries/ValidationErrorPlan.json
@@ -4,22 +4,22 @@
       {
         "description": "arrayToMV validation error 1",
         "sql": "EXPLAIN PLAN FOR SELECT sum(sumCol3), arrayToMv(mcol1) FROM (SELECT SUM(a.col3) as sumCol3, e.mcol1, a.col2  FROM a JOIN e on a.col1=e.col1 GROUP BY e.mcol1, a.col2) GROUP BY arrayToMv(mcol1)",
-        "expectedException": "Error composing query plan for.*"
+        "expectedException": ".*'ArrayToMv' is not supported.*"
       },
       {
         "description": "arrayToMV validation error 2",
         "sql": "EXPLAIN PLAN FOR SELECT SUM(a.col3) as sumCol3, arrayToMv(e.mcol1), a.col2  FROM a JOIN e on a.col1=e.col1 GROUP BY arrayToMv(e.mcol1), a.col2",
-        "expectedException": "Error composing query plan for.*"
+        "expectedException": ".*'ArrayToMv' is not supported.*"
       },
       {
         "description": "Select * with negative limit -1",
         "sql": "EXPLAIN PLAN FOR SELECT * FROM d LIMIT -1",
-        "expectedException": "Caught exception while parsing query.*"
+        "expectedException": "Encountered.*LIMIT.*"
       },
       {
         "description": "Select * with negative offset",
         "sql": "EXPLAIN PLAN FOR SELECT * FROM d LIMIT 10 OFFSET -1",
-        "expectedException": "Caught exception while parsing query.*"
+        "expectedException": "Encountered.*OFFSET.*"
       }
     ]
   }
diff --git a/pinot-query-planner/src/test/resources/queries/WindowFunctionPlans.json b/pinot-query-planner/src/test/resources/queries/WindowFunctionPlans.json
index 262a73b52b..fc04b684f4 100644
--- a/pinot-query-planner/src/test/resources/queries/WindowFunctionPlans.json
+++ b/pinot-query-planner/src/test/resources/queries/WindowFunctionPlans.json
@@ -3533,177 +3533,175 @@
           "\n                  LogicalTableScan(table=[[b]])",
           "\n"
         ]
-      }
-    ]
-  },
-  "exception_throwing_window_function_planning_tests": {
-    "queries": [
+      },
       {
         "description": "unsupported window functions such as NTILE()",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT NTILE(5) OVER(PARTITION BY a.col1 ORDER BY a.col3) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT NTILE(5) OVER(PARTITION BY a.col1 ORDER BY a.col3) FROM a"
       },
       {
         "description": "unsupported window functions such as LAG()",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT LAG(a.col2) OVER(PARTITION BY a.col1 ORDER BY a.col3) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT LAG(a.col2) OVER(PARTITION BY a.col1 ORDER BY a.col3) FROM a"
       },
       {
         "description": "unsupported custom frames",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT AVG(a.col3) OVER(PARTITION BY a.col1 ORDER BY a.col3 ROWS BETWEEN 5 PRECEDING AND 10 FOLLOWING) FROM a WHERE a.col3 >= 0",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT AVG(a.col3) OVER(PARTITION BY a.col1 ORDER BY a.col3 ROWS BETWEEN 5 PRECEDING AND 10 FOLLOWING) FROM a WHERE a.col3 >= 0"
       },
       {
         "description": "unsupported custom frames",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(ORDER BY a.col3 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a",
-        "expectedException": "Error explain query plan for.*"
-      },
-      {
-        "description": "unsupported custom frames - ORDER BY with two columns and RANGE",
-        "notes": "Apache Calcite throws error: RANGE clause cannot be used with compound ORDER BY clause, even though not specifying the frame results in RANGE itself",
-        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(ORDER BY a.col3, a.col1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a",
-        "expectedException": "Error explain query plan for.*"
-      },
-      {
-        "description": "unsupported custom frames - PARTITION BY and ORDER BY with two columns and RANGE",
-        "notes": "Apache Calcite throws error: RANGE clause cannot be used with compound ORDER BY clause, even though not specifying the frame results in RANGE itself",
-        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(PARTITION BY a.col2 ORDER BY a.col3, a.col1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(ORDER BY a.col3 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a"
       },
       {
         "description": "unsupported custom frames - ORDER BY with two columns and ROWS",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(ORDER BY a.col3, a.col1 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(ORDER BY a.col3, a.col1 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a"
       },
       {
         "description": "Multiple window groups",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(PARTITION BY a.col2 ORDER BY a.col3), MAX(a.col3) OVER(PARTITION BY a.col1 ORDER BY a.col3) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(PARTITION BY a.col2 ORDER BY a.col3), MAX(a.col3) OVER(PARTITION BY a.col1 ORDER BY a.col3) FROM a"
       },
       {
         "description": "Multiple window groups",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT COUNT(a.col3) OVER(PARTITION BY a.col2), SUM(a.col3) OVER(PARTITION BY a.col2 ORDER BY a.col3) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT COUNT(a.col3) OVER(PARTITION BY a.col2), SUM(a.col3) OVER(PARTITION BY a.col2 ORDER BY a.col3) FROM a"
       },
       {
         "description": "Multiple window groups",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT AVG(a.col3) OVER(), MAX(a.col3) OVER(PARTITION BY a.col2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT AVG(a.col3) OVER(), MAX(a.col3) OVER(PARTITION BY a.col2) FROM a"
       },
       {
         "description": "Multiple window groups",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT SUM(a.col3) OVER(ORDER BY a.col2), MIN(a.col3) OVER(PARTITION BY a.col2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT SUM(a.col3) OVER(ORDER BY a.col2), MIN(a.col3) OVER(PARTITION BY a.col2) FROM a"
       },
       {
         "description": "Multiple window groups",
         "notes": "not yet supported",
-        "sql": "EXPLAIN PLAN FOR SELECT SUM(a.col3) OVER(ORDER BY a.col2, a.col1), MIN(a.col3) OVER(ORDER BY a.col1, a.col2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "ignored": true,
+        "sql": "EXPLAIN PLAN FOR SELECT SUM(a.col3) OVER(ORDER BY a.col2, a.col1), MIN(a.col3) OVER(ORDER BY a.col1, a.col2) FROM a"
+      }
+    ]
+  },
+  "exception_throwing_window_function_planning_tests": {
+    "queries": [
+      {
+        "description": "unsupported custom frames - ORDER BY with two columns and RANGE",
+        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(ORDER BY a.col3, a.col1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a",
+        "expectedException": ".*RANGE clause cannot be used with compound ORDER BY clause.*"
+      },
+      {
+        "description": "unsupported custom frames - PARTITION BY and ORDER BY with two columns and RANGE",
+        "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(PARTITION BY a.col2 ORDER BY a.col3, a.col1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a",
+        "expectedException": ".*RANGE clause cannot be used with compound ORDER BY clause.*"
       },
       {
         "description": "Using aggregation inside ORDER BY within OVER",
         "sql": "EXPLAIN PLAN FOR SELECT SUM(a.col3) OVER(ORDER BY MAX(a.col3)) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Expression 'a.col3' is not being grouped.*"
       },
       {
         "description": "Using aggregation inside PARTITION BY within OVER",
         "sql": "EXPLAIN PLAN FOR SELECT COUNT(a.col1) OVER(PARTITION BY AVG(a.col3)) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Expression 'a.col1' is not being grouped.*"
       },
       {
         "description": "Select an aggregate along with OVER()",
         "sql": "EXPLAIN PLAN FOR SELECT SUM(a.col3), COUNT(a.col1) OVER() FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Expression 'a.col1' is not being grouped.*"
       },
       {
         "description": "External group by clause",
         "sql": "EXPLAIN PLAN FOR SELECT MIN(a.col3) OVER(PARTITION BY a.col2) FROM a GROUP BY a.col2",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Expression 'a.col3' is not being grouped.*"
       },
       {
         "description": "Global order by aggregate",
         "sql": "EXPLAIN PLAN FOR SELECT MAX(a.col3) OVER(PARTITION BY a.col1 ORDER BY a.col2) FROM a ORDER BY SUM(a.col3)",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Aggregate expression is illegal in ORDER BY clause of non-aggregating SELECT.*"
       },
       {
         "description": "Wrong table",
         "sql": "EXPLAIN PLAN FOR SELECT MAX(b.col3) OVER(PARTITION BY b.col1 ORDER BY b.col2) FROM a ORDER BY SUM(b.col3)",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Aggregate expression is illegal in ORDER BY clause of non-aggregating SELECT.*"
       },
       {
         "description": "Apache Calcite failures with ROW_NUMBER() window functions - even default frame cannot be specified",
         "sql": "EXPLAIN PLAN FOR SELECT ROW_NUMBER() OVER(PARTITION BY a.col1 ORDER BY a.col2 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*ROW/RANGE not allowed with RANK, DENSE_RANK or ROW_NUMBER functions.*"
       },
       {
         "description": "Apache Calcite failures with ROW_NUMBER() window functions - default frame for ROW_NUMBER is different from aggregation window functions, resulting in multiple window groups",
         "sql": "EXPLAIN PLAN FOR SELECT ROW_NUMBER() OVER(PARTITION BY a.col1 ORDER BY a.col2), SUM(a.col1) OVER(PARTITION BY a.col1 ORDER BY a.col2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Cannot generate a valid execution plan.*"
       },
       {
         "description": "Apache Calcite failures with ROW_NUMBER() window functions - custom frames not allowed",
         "sql": "EXPLAIN PLAN FOR SELECT ROW_NUMBER() OVER(PARTITION BY a.col1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*ROW/RANGE not allowed with RANK, DENSE_RANK or ROW_NUMBER functions.*"
       },
       {
         "description": "Apache Calcite failures with ROW_NUMBER() window functions - custom frames not allowed",
         "sql": "EXPLAIN PLAN FOR SELECT ROW_NUMBER() OVER(PARTITION BY a.col1 ROWS 2 PRECEDING) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*ROW/RANGE not allowed with RANK, DENSE_RANK or ROW_NUMBER functions.*"
       },
       {
         "description": "Apache Calcite failures with ROW_NUMBER() window functions - passing argument to ROW_NUMBER() should fail",
         "sql": "EXPLAIN PLAN FOR SELECT ROW_NUMBER(a.col3) OVER(PARTITION BY a.col2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Invalid number of arguments to function 'ROW_NUMBER'. Was expecting 0 arguments.*"
       },
       {
         "description": "Apache Calcite failures with RANK() window functions - needs ORDER BY",
         "sql": "EXPLAIN PLAN FOR SELECT RANK() OVER(PARTITION BY a.col2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*RANK or DENSE_RANK functions require ORDER BY clause in window specification.*"
       },
       {
         "description": "Apache Calcite failures with RANK() window functions - needs ORDER BY",
         "sql": "EXPLAIN PLAN FOR SELECT RANK() OVER() FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*RANK or DENSE_RANK functions require ORDER BY clause in window specification.*"
       },
       {
         "description": "Apache Calcite failures with DENSE_RANK() window functions - needs ORDER BY",
         "sql": "EXPLAIN PLAN FOR SELECT DENSE_RANK() OVER(PARTITION BY a.col2) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*RANK or DENSE_RANK functions require ORDER BY clause in window specification.*"
       },
       {
         "description": "Apache Calcite failures with DENSE_RANK() window functions - needs ORDER BY",
         "sql": "EXPLAIN PLAN FOR SELECT DENSE_RANK() OVER() FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*RANK or DENSE_RANK functions require ORDER BY clause in window specification.*"
       },
       {
         "description": "Apache Calcite failures with DENSE_RANK() window functions - passing argument to RANK() should fail",
         "sql": "EXPLAIN PLAN FOR SELECT RANK(a.col3) OVER(ORDER BY a.col1) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Invalid number of arguments to function 'RANK'. Was expecting 0 arguments.*"
       },
       {
         "description": "Apache Calcite failures with DENSE_RANK() window functions - passing argument to DENSE_RANK() should fail",
         "sql": "EXPLAIN PLAN FOR SELECT DENSE_RANK(a.col3) OVER(ORDER BY a.col1) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*Invalid number of arguments to function 'DENSE_RANK'. Was expecting 0 arguments.*"
       },
       {
         "description": "Apache Calcite failures with RANK() window functions - cannot take default frame specification, even though same as actual frame if no frame specified",
         "sql": "EXPLAIN PLAN FOR SELECT RANK() OVER(ORDER BY a.col1 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*ROW/RANGE not allowed with RANK, DENSE_RANK or ROW_NUMBER functions.*"
       },
       {
         "description": "Apache Calcite failures with DENSE_RANK() window functions - cannot take default frame specification, even though same as actual frame if no frame specified",
         "sql": "EXPLAIN PLAN FOR SELECT DENSE_RANK() OVER(ORDER BY a.col1 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM a",
-        "expectedException": "Error explain query plan for.*"
+        "expectedException": ".*ROW/RANGE not allowed with RANK, DENSE_RANK or ROW_NUMBER functions.*"
       }
     ]
   }


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