You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/10/21 15:37:15 UTC

[GitHub] [pinot] yupeng9 commented on a change in pull request #7590: Reject query with identifiers not in schema

yupeng9 commented on a change in pull request #7590:
URL: https://github.com/apache/pinot/pull/7590#discussion_r733804365



##########
File path: pinot-broker/src/test/java/org/apache/pinot/broker/requesthandler/QueryValidationTest.java
##########
@@ -120,6 +122,38 @@ public void testUnsupportedDistinctQueries() {
     testUnsupportedPQLQuery(pql, "Aggregation functions cannot be used with DISTINCT");
   }
 
+  @Test
+  public void testUnsupportedNonExistColumnsQueries() {
+    String sql = "SELECT DISTINCT(col1, col2) FROM foo OPTION(groupByMode=sql,responseFormat=sql)";
+    testNonExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col1", "col1"), sql,
+        "Unknown columnName 'col2' found in the query");
+    testNonExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col2", "col2"), sql,
+        "Unknown columnName 'col1' found in the query");
+    testExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col2", "col2", "col1", "col1"), sql);
+    sql = "SELECT sum(Col1) FROM foo OPTION(groupByMode=sql,responseFormat=sql)";
+    testNonExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col1", "col1"), sql,
+        "Unknown columnName 'Col1' found in the query");
+    testExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col1", "Col1"), sql);
+    testExistedColumnInSQLQuery("foo", true, ImmutableMap.of("col1", "col1"), sql);
+    sql = "SELECT sum(Col1) AS sum_col1 FROM foo OPTION(groupByMode=sql,responseFormat=sql)";
+    testNonExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col1", "col1"), sql,
+        "Unknown columnName 'Col1' found in the query");
+    testExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col1", "Col1"), sql);
+    testExistedColumnInSQLQuery("foo", true, ImmutableMap.of("col1", "col1"), sql);
+    sql = "SELECT sum(Col1) AS sum_col1 FROM foo HAVING sum_col1 > 10 OPTION(groupByMode=sql,responseFormat=sql)";
+    testNonExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col1", "col1"), sql,
+        "Unknown columnName 'Col1' found in the query");
+    testExistedColumnInSQLQuery("foo", false, ImmutableMap.of("col1", "Col1"), sql);
+    testExistedColumnInSQLQuery("foo", true, ImmutableMap.of("col1", "col1"), sql);
+    sql =
+        "SELECT sum(Col1) AS sum_col1, b AS B, c as D FROM foo GROUP BY B, D OPTION(groupByMode=sql,"

Review comment:
       shall we have a test to show `SELECT sum(Col1) AS sum_col1, b AS B, c as D FROM foo GROUP BY 2, 3` also works?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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