diff --git a/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java b/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java index b16f880c803c..b3e48f25aebd 100644 --- a/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java +++ b/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java @@ -88,10 +88,15 @@ public BrokerResponse handleRequest(JsonNode request, @Nullable SqlNodeAndOption return new BrokerResponseNative(QueryException.getException(QueryException.SQL_PARSING_ERROR, e)); } } - if (_multiStageBrokerRequestHandler != null && QueryOptionsUtils.isUseMultistageEngine( - sqlNodeAndOptions.getOptions())) { - return _multiStageBrokerRequestHandler.handleRequest(request, sqlNodeAndOptions, requesterIdentity, - requestContext, httpHeaders); + + if (QueryOptionsUtils.isUseMultistageEngine(sqlNodeAndOptions.getOptions())) { + if (_multiStageBrokerRequestHandler != null) { + return _multiStageBrokerRequestHandler.handleRequest(request, sqlNodeAndOptions, requesterIdentity, + requestContext, httpHeaders); + } else { + return new BrokerResponseNative(QueryException.getException(QueryException.INTERNAL_ERROR, + "V2 Multi-Stage query engine not enabled.")); + } } else { return _singleStageBrokerRequestHandler.handleRequest(request, sqlNodeAndOptions, requesterIdentity, requestContext, httpHeaders);