somandal commented on code in PR #10534:
URL: https://github.com/apache/pinot/pull/10534#discussion_r1159053443


##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java:
##########
@@ -169,6 +185,36 @@ private BrokerResponse handleRequest(long requestId, 
String query,
       return new 
BrokerResponseNative(QueryException.getException(QueryException.SQL_PARSING_ERROR,
 e));
     }
 
+    QueryPlan queryPlan = queryPlanResult.getQueryPlan();
+    Set<String> tableNames = 
getTableNamesFromRelRoot(queryPlanResult.getRelRoot());
+
+    // Compilation Time. This includes the time taken for parsing, compiling, 
create stage plans and assigning workers.
+    long compilationEndTimeNs = System.nanoTime();
+    long compilationTime = (compilationEndTimeNs - compilationStartTimeNs) + 
sqlNodeAndOptions.getParseTimeNs();
+    updatePhaseTimingForTables(tableNames, 
BrokerQueryPhase.REQUEST_COMPILATION, compilationTime);
+
+    // Validate table access.
+    if (!hasTableAccess(requesterIdentity, tableNames)) {
+      
_brokerMetrics.addMeteredGlobalValue(BrokerMeter.REQUEST_DROPPED_DUE_TO_ACCESS_ERROR,
 1);
+      LOGGER.info("Access denied for requestId {}", requestId);
+      requestContext.setErrorCode(QueryException.ACCESS_DENIED_ERROR_CODE);

Review Comment:
   nit: Since this code is reused in two places, can you make a function? 
optionally can the metrics update, logging, and setting the error code be 
handled in the `hasTableAccess` function itself?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to