jackjlli commented on a change in pull request #3568: Add guava cache to cache
table schema in pinot broker
URL: https://github.com/apache/incubator-pinot/pull/3568#discussion_r255386197
##########
File path:
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
##########
@@ -332,6 +340,31 @@ private void validateRequest(BrokerRequest brokerRequest)
{
"Value for 'LIMIT' (" + limit + ") exceeds maximum allowed value
of " + _queryResponseLimit);
}
}
+
+ // Checks whether the query contains non-existent columns.
+ // Table name has already been verified before hitting this line.
+ if (requestParams.isValidateQuery()) {
+ String tableName = brokerRequest.getQuerySource().getTableName();
+ Schema schema = _tableSchemaCache.getIfTableSchemaPresent(tableName);
+ if (schema != null) {
+ RequestInfo requestInfo =
RequestUtils.preComputeRequestInfo(brokerRequest);
+ // gets all the columns from broker request
+ Set<String> columnsFromBrokerRequest = requestInfo.getAllColumns();
+ // filters out virtual columns in the query.
+ columnsFromBrokerRequest.removeIf(column -> column.startsWith("$"));
+ columnsFromBrokerRequest.removeAll(schema.getColumnNames());
+ if (!columnsFromBrokerRequest.isEmpty()) {
+ _brokerMetrics.addMeteredTableValue(tableName,
BrokerMeter.QUERY_NON_EXISTENT_COLUMNS, 1L);
+ throw new RuntimeException(
Review comment:
This runtime exception will be captured in caller's exception block and thus
throws a `QUERY_VALIDATION_EXCEPTIONS` back to the client. So we're good here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]