github-advanced-security[bot] commented on code in PR #17895:
URL: https://github.com/apache/druid/pull/17895#discussion_r2053920556


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/LegacyMSQSpec.java:
##########
@@ -0,0 +1,207 @@
+/*
+ * 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.indexing;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.msq.indexing.destination.MSQDestination;
+import org.apache.druid.msq.indexing.destination.TaskReportMSQDestination;
+import org.apache.druid.msq.kernel.QueryDefinition;
+import org.apache.druid.msq.kernel.WorkerAssignmentStrategy;
+import org.apache.druid.query.BaseQuery;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.QueryContext;
+import org.apache.druid.sql.calcite.planner.ColumnMappings;
+
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Old MSQSpec with a native query in it.
+ *
+ * Usage of this class should be avoided in favor of {@link MSQSpec}.
+ */
+public class LegacyMSQSpec extends MSQSpec
+{
+  private final Query<?> query;
+
+  // jackson defaults
+  public LegacyMSQSpec()
+  {
+    super();
+    this.query = null;
+  }
+
+  public LegacyMSQSpec(
+      @JsonProperty("query") Query<?> query,
+      @JsonProperty("columnMappings") ColumnMappings columnMappings,
+      @JsonProperty("destination") MSQDestination destination,
+      @JsonProperty("assignmentStrategy") WorkerAssignmentStrategy 
assignmentStrategy,
+      @JsonProperty("tuningConfig") MSQTuningConfig tuningConfig)
+  {
+    this(
+        query, columnMappings, destination, assignmentStrategy, tuningConfig, 
null
+    );
+  }
+
+  @JsonCreator
+  public LegacyMSQSpec(
+      @JsonProperty("query") Query<?> query,
+      @JsonProperty("columnMappings") ColumnMappings columnMappings,
+      @JsonProperty("destination") MSQDestination destination,
+      @JsonProperty("assignmentStrategy") WorkerAssignmentStrategy 
assignmentStrategy,
+      @JsonProperty("tuningConfig") MSQTuningConfig tuningConfig,
+      @JsonProperty("queryDef") QueryDefinition queryDef
+  )
+  {
+    super(columnMappings, destination, assignmentStrategy, tuningConfig, 
queryDef);
+    Preconditions.checkArgument(query == null ^ queryDef != null, "Either 
query or queryDef must be null!");
+    this.query = query;
+  }
+
+  public static Builder builder()
+  {
+    return new Builder();
+  }
+
+  @JsonProperty
+  public Query<?> getQuery()
+  {
+    return query;
+  }
+
+  public String getId()

Review Comment:
   ## Missing Override annotation
   
   This method overrides [MSQSpec.getId](1); it is advisable to add an Override 
annotation.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/8929)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/DartQueryMaker.java:
##########
@@ -186,6 +185,20 @@
     }
   }
 
+  private LegacyMSQSpec makeMSQSpec(DruidQuery druidQuery, final String 
dartQueryId, final ControllerContext controllerContext,

Review Comment:
   ## Useless parameter
   
   The parameter 'dartQueryId' is never used.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/8926)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/DartQueryMaker.java:
##########
@@ -186,6 +185,20 @@
     }
   }
 
+  private LegacyMSQSpec makeMSQSpec(DruidQuery druidQuery, final String 
dartQueryId, final ControllerContext controllerContext,

Review Comment:
   ## Useless parameter
   
   The parameter 'controllerContext' is never used.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/8927)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/MSQCompactionRunner.java:
##########
@@ -263,11 +265,20 @@
         query = buildScanQuery(compactionTask, interval, dataSchema, 
inputColToVirtualCol);
       }
       QueryContext compactionTaskContext = new 
QueryContext(compactionTask.getContext());
+      DataSourceMSQDestination destination = 
buildMSQDestination(compactionTask, dataSchema);
 
-      MSQSpec msqSpec = MSQSpec.builder()
+      boolean isReindex = 
MSQControllerTask.isReplaceInputDataSourceTask(query, destination);
+      final ImmutableMap<String, Object> queryContext = ImmutableMap.<String, 
Object>builder()
+          .putAll(query.getContext())
+          // I don't suspect that this is really necessary - but this is the 
equiv behaviour
+          .put(MultiStageQueryContext.CTX_IS_REINDEX, isReindex)
+          .build();
+
+      LegacyMSQSpec msqSpec = LegacyMSQSpec.builder()

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [Builder.query](1) should be avoided because it has been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/8811)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/DartQueryMaker.java:
##########
@@ -186,6 +185,20 @@
     }
   }
 
+  private LegacyMSQSpec makeMSQSpec(DruidQuery druidQuery, final String 
dartQueryId, final ControllerContext controllerContext,
+      final ResultsContext resultsContext)

Review Comment:
   ## Useless parameter
   
   The parameter 'resultsContext' is never used.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/8928)



-- 
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