Jackie-Jiang commented on code in PR #12537:
URL: https://github.com/apache/pinot/pull/12537#discussion_r1719414769


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java:
##########
@@ -269,10 +271,22 @@ private String getQueryResponse(String query, @Nullable 
SqlNode sqlNode, String
       return 
QueryException.getException(QueryException.QUERY_VALIDATION_ERROR, 
e).toString();
     }
     try {
-      String inputTableName =
-          sqlNode != null ? 
RequestUtils.getTableNames(CalciteSqlParser.compileSqlNodeToPinotQuery(sqlNode)).iterator()
-              .next() : 
CalciteSqlCompiler.compileToBrokerRequest(query).getQuerySource().getTableName();
-      tableName = 
_pinotHelixResourceManager.getActualTableName(inputTableName, database);
+      List<String> inputTableNames = new ArrayList<>();
+      if (sqlNode != null) {
+        if (sqlNode instanceof SqlShowTables) {
+          
inputTableNames.addAll(_pinotHelixResourceManager.getAllTables(database));

Review Comment:
   We don't need query access to all tables in order to run SHOW TABLES. 
Instead, we can take the same action as 
`PinotTableRestletResource.listTables()` which also list all tables.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotQueryResource.java:
##########
@@ -269,10 +271,22 @@ private String getQueryResponse(String query, @Nullable 
SqlNode sqlNode, String
       return 
QueryException.getException(QueryException.QUERY_VALIDATION_ERROR, 
e).toString();
     }
     try {
-      String inputTableName =
-          sqlNode != null ? 
RequestUtils.getTableNames(CalciteSqlParser.compileSqlNodeToPinotQuery(sqlNode)).iterator()
-              .next() : 
CalciteSqlCompiler.compileToBrokerRequest(query).getQuerySource().getTableName();
-      tableName = 
_pinotHelixResourceManager.getActualTableName(inputTableName, database);
+      List<String> inputTableNames = new ArrayList<>();
+      if (sqlNode != null) {
+        if (sqlNode instanceof SqlShowTables) {
+          
inputTableNames.addAll(_pinotHelixResourceManager.getAllTables(database));
+        } else if (sqlNode instanceof SqlDescribeTable) {
+          inputTableNames.add(((SqlDescribeTable) 
sqlNode).getTable().toString());

Review Comment:
   Similarly, we should check for access with same action as 
`PinotTableSchema.getTableSchema()`



##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java:
##########
@@ -1857,4 +1868,65 @@ private static class QueryServers {
       }
     }
   }
+
+  private BrokerResponseNative processShowTablesQuery(SqlNodeAndOptions 
sqlNodeAndOptions, HttpHeaders httpHeaders,
+      long compilationStartTimeNs, RequestContext requestContext) {
+    Map<String, String> queryOptions = sqlNodeAndOptions.getOptions();

Review Comment:
   Currently the access control is only added on the controller side 
(`PinotQueryResource`). We should also perform access control on broker (in 
this class)



-- 
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-unsubscr...@pinot.apache.org

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


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

Reply via email to