sajjad-moradi commented on code in PR #8550:
URL: https://github.com/apache/pinot/pull/8550#discussion_r854338142
##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java:
##########
@@ -2151,6 +2152,18 @@ static void validateRequest(PinotQuery pinotQuery, int
queryResponseLimit) {
|| !QueryOptionsUtils.isResponseFormatSQL(queryOptions)) {
throw new IllegalStateException("SQL query should always have response
format and group-by mode set to SQL");
}
+ try {
+ // throw errors if options is less than 1 or invalid
+ Integer numReplicaGroupsToQuery =
QueryOptionsUtils.getNumReplicaGroupsToQuery(queryOptions);
+ if (numReplicaGroupsToQuery != null) {
+ Preconditions.checkState(numReplicaGroupsToQuery > 0,
"numReplicaGroups must be "
+ + "positive number, got: %d", numReplicaGroupsToQuery);
+ }
+ } catch (NumberFormatException ex) {
+ String numReplicaGroupsToQuery =
queryOptions.get(Broker.Request.QueryOptionKey.NUM_REPLICA_GROUPS_TO_QUERY);
+ throw new IllegalStateException(String.format("numReplicaGroups must be
a positive number, got: %d",
Review Comment:
`%d` -> `%s`
##########
pinot-broker/src/test/java/org/apache/pinot/broker/routing/instanceselector/InstanceSelectorTest.java:
##########
@@ -46,6 +47,7 @@
public class InstanceSelectorTest {
+ private static List<String> _segments = null;
Review Comment:
```java
private static final List<String> SEGMENTS = IntStream.range(0,
12).mapToObj(i -> "segment" + i).collect(Collectors.toList());
```
or
```java
private static final List<String> SEGMENTS = Arrays.asList("segment0",
"segment1", ..., "segment11");
```
##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/BaseInstanceSelector.java:
##########
@@ -265,7 +265,14 @@ private List<String>
calculateEnabledInstancesForSegment(String segment, List<St
@Override
public SelectionResult select(BrokerRequest brokerRequest, List<String>
segments) {
int requestId = (int) (_requestId.getAndIncrement() % MAX_REQUEST_ID);
- Map<String, String> segmentToInstanceMap = select(segments, requestId,
_segmentToEnabledInstancesMap);
+ Map<String, String> queryOptions = null;
+ if (brokerRequest.getPinotQuery() != null) {
+ queryOptions = brokerRequest.getPinotQuery().getQueryOptions();
+ }
+ if (queryOptions == null) {
+ queryOptions = Collections.emptyMap();
+ }
Review Comment:
```suggestion
Map<String, String> queryOptions = brokerRequest.getPinotQuery() != null
? brokerRequest.getPinotQuery().getQueryOptions()
: Collections.emptyMap();
```
--
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]