github-advanced-security[bot] commented on code in PR #16168:
URL: https://github.com/apache/druid/pull/16168#discussion_r1530125108
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerContext.java:
##########
@@ -53,32 +71,33 @@
DruidNode selfNode();
/**
- * Provide access to the Coordinator service.
+ * Provides an {@link InputSpecSlicer} that slices {@link TableInputSpec}
into {@link SegmentsInputSlice}.
*/
- CoordinatorClient coordinatorClient();
+ InputSpecSlicer newTableInputSpecSlicer(WorkerManager workerManager);
Review Comment:
## Useless parameter
The parameter 'workerManager' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7149)
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/rpc/ControllerResource.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.msq.rpc;
+
+import org.apache.druid.indexing.common.TaskReport;
+import org.apache.druid.msq.counters.CounterSnapshots;
+import org.apache.druid.msq.counters.CounterSnapshotsTree;
+import org.apache.druid.msq.exec.Controller;
+import org.apache.druid.msq.exec.ControllerClient;
+import org.apache.druid.msq.indexing.MSQTaskList;
+import org.apache.druid.msq.indexing.error.MSQErrorReport;
+import org.apache.druid.msq.kernel.StageId;
+import org.apache.druid.msq.statistics.PartialKeyStatisticsInformation;
+import org.apache.druid.server.security.AuthorizerMapper;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+import java.util.Map;
+
+public class ControllerResource
+{
+ private final Controller controller;
+ private final ResourcePermissionMapper permissionMapper;
+ private final AuthorizerMapper authorizerMapper;
+
+ public ControllerResource(
+ final Controller controller,
+ final ResourcePermissionMapper permissionMapper,
+ final AuthorizerMapper authorizerMapper
+ )
+ {
+ this.controller = controller;
+ this.permissionMapper = permissionMapper;
+ this.authorizerMapper = authorizerMapper;
+ }
+
+ /**
+ * Used by subtasks to post {@link PartialKeyStatisticsInformation} for
shuffling stages.
+ *
+ * See {@link ControllerClient#postPartialKeyStatistics(StageId, int,
PartialKeyStatisticsInformation)}
+ * for the client-side code that calls this API.
+ */
+ @POST
+
@Path("/partialKeyStatisticsInformation/{queryId}/{stageNumber}/{workerNumber}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response httpPostPartialKeyStatistics(
+ final Object partialKeyStatisticsObject,
+ @PathParam("queryId") final String queryId,
+ @PathParam("stageNumber") final int stageNumber,
+ @PathParam("workerNumber") final int workerNumber,
+ @Context final HttpServletRequest req
+ )
+ {
+ MSQResourceUtils.authorizeAdminRequest(permissionMapper, authorizerMapper,
req);
+ controller.updatePartialKeyStatisticsInformation(stageNumber,
workerNumber, partialKeyStatisticsObject);
+ return Response.status(Response.Status.ACCEPTED).build();
+ }
+
+ /**
+ * Used by subtasks to post system errors. Note that the errors are
organized by taskId, not by query/stage/worker,
+ * because system errors are associated with a task rather than a specific
query/stage/worker execution context.
+ *
+ * See {@link ControllerClient#postWorkerError} for the client-side code
that calls this API.
+ */
+ @POST
+ @Path("/workerError/{taskId}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response httpPostWorkerError(
+ final MSQErrorReport errorReport,
+ @PathParam("taskId") final String taskId,
Review Comment:
## Useless parameter
The parameter 'taskId' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7151)
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/rpc/ControllerResource.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.msq.rpc;
+
+import org.apache.druid.indexing.common.TaskReport;
+import org.apache.druid.msq.counters.CounterSnapshots;
+import org.apache.druid.msq.counters.CounterSnapshotsTree;
+import org.apache.druid.msq.exec.Controller;
+import org.apache.druid.msq.exec.ControllerClient;
+import org.apache.druid.msq.indexing.MSQTaskList;
+import org.apache.druid.msq.indexing.error.MSQErrorReport;
+import org.apache.druid.msq.kernel.StageId;
+import org.apache.druid.msq.statistics.PartialKeyStatisticsInformation;
+import org.apache.druid.server.security.AuthorizerMapper;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.List;
+import java.util.Map;
+
+public class ControllerResource
+{
+ private final Controller controller;
+ private final ResourcePermissionMapper permissionMapper;
+ private final AuthorizerMapper authorizerMapper;
+
+ public ControllerResource(
+ final Controller controller,
+ final ResourcePermissionMapper permissionMapper,
+ final AuthorizerMapper authorizerMapper
+ )
+ {
+ this.controller = controller;
+ this.permissionMapper = permissionMapper;
+ this.authorizerMapper = authorizerMapper;
+ }
+
+ /**
+ * Used by subtasks to post {@link PartialKeyStatisticsInformation} for
shuffling stages.
+ *
+ * See {@link ControllerClient#postPartialKeyStatistics(StageId, int,
PartialKeyStatisticsInformation)}
+ * for the client-side code that calls this API.
+ */
+ @POST
+
@Path("/partialKeyStatisticsInformation/{queryId}/{stageNumber}/{workerNumber}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response httpPostPartialKeyStatistics(
+ final Object partialKeyStatisticsObject,
+ @PathParam("queryId") final String queryId,
Review Comment:
## Useless parameter
The parameter 'queryId' is never used.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7152)
##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/report/MSQResultsReport.java:
##########
@@ -132,9 +72,9 @@
}
@JsonProperty("results")
- public Yielder<Object[]> getResultYielder()
+ public List<Object[]> getResults()
Review Comment:
## Exposing internal representation
getResults exposes the internal representation stored in field results. The
value may be modified [after this call to getResults](1).
[Show more
details](https://github.com/apache/druid/security/code-scanning/7154)
##########
extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/kernel/controller/MockQueryDefinitionBuilder.java:
##########
@@ -113,27 +126,60 @@
);
definedStages.add(stageNumber);
- ShuffleSpec shuffleSpec;
+ ShuffleSpec shuffleSpec = null;
- if (shuffling) {
- shuffleSpec = new GlobalSortMaxCountShuffleSpec(
- new ClusterBy(
- ImmutableList.of(
- new KeyColumn(SHUFFLE_KEY_COLUMN, KeyOrder.ASCENDING)
+ if (shuffleKind != null) {
+ switch (shuffleKind) {
+ case GLOBAL_SORT:
+ shuffleSpec = new GlobalSortMaxCountShuffleSpec(
+ new ClusterBy(
+ ImmutableList.of(
+ new KeyColumn(SHUFFLE_KEY_COLUMN, KeyOrder.ASCENDING)
+ ),
+ 0
),
- 0
- ),
- MAX_NUM_PARTITIONS,
- false
- );
- } else {
- shuffleSpec = null;
+ MAX_NUM_PARTITIONS,
+ false
+ );
+ break;
+
+ case HASH_LOCAL_SORT:
+ case HASH:
+ shuffleSpec = new HashShuffleSpec(
+ new ClusterBy(
+ ImmutableList.of(
+ new KeyColumn(
+ SHUFFLE_KEY_COLUMN,
+ shuffleKind == ShuffleKind.HASH ? KeyOrder.NONE :
KeyOrder.ASCENDING
+ )
+ ),
+ 0
+ ),
+ MAX_NUM_PARTITIONS
+ );
+ break;
+
+ case MIX:
+ shuffleSpec = MixShuffleSpec.instance();
+ break;
+ }
+
+ if (shuffleKind != shuffleSpec.kind()) {
Review Comment:
## Dereferenced variable may be null
Variable [shuffleSpec](1) may be null at this access because of [this](2)
assignment.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7153)
--
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]