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


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/destination/MSQTerminalStageSpecFactory.java:
##########
@@ -20,12 +20,11 @@
 package org.apache.druid.msq.indexing.destination;
 
 import org.apache.druid.sql.calcite.planner.PlannerContext;
-import org.apache.druid.sql.calcite.rel.DruidQuery;
 
 public interface MSQTerminalStageSpecFactory
 {
   /**
    * Creates a {@link TerminalStageSpec} which determines the final of a query.
    */
-  TerminalStageSpec createTerminalStageSpec(DruidQuery druidQuery, 
PlannerContext plannerContext);
+  TerminalStageSpec createTerminalStageSpec(PlannerContext plannerContext);

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



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/MSQTaskQueryMaker.java:
##########
@@ -236,17 +244,26 @@
 
     // This flag is to ensure backward compatibility, as brokers are upgraded 
after indexers/middlemanagers.
     
nativeQueryContextOverrides.put(MultiStageQueryContext.WINDOW_FUNCTION_OPERATOR_TRANSFORMATION,
 true);
+    boolean isReindex = 
MSQControllerTask.isReplaceInputDataSourceTask(druidQuery.getQuery(), 
destination);
+    if (isReindex) {
+      nativeQueryContextOverrides.put(MultiStageQueryContext.CTX_IS_REINDEX, 
isReindex);
+    }
 
-    final MSQSpec querySpec =
-        MSQSpec.builder()
-               
.query(druidQuery.getQuery().withOverriddenContext(nativeQueryContextOverrides))
+    QueryContext queryContext = 
queryContext3.override(nativeQueryContextOverrides);
+
+    final LegacyMSQSpec querySpec =
+        LegacyMSQSpec.builder()
+               
.query(druidQuery==null?null:druidQuery.getQuery().withOverriddenContext(nativeQueryContextOverrides))

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/8812)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/MSQTaskQueryMaker.java:
##########
@@ -236,17 +244,26 @@
 
     // This flag is to ensure backward compatibility, as brokers are upgraded 
after indexers/middlemanagers.
     
nativeQueryContextOverrides.put(MultiStageQueryContext.WINDOW_FUNCTION_OPERATOR_TRANSFORMATION,
 true);
+    boolean isReindex = 
MSQControllerTask.isReplaceInputDataSourceTask(druidQuery.getQuery(), 
destination);

Review Comment:
   ## Dereferenced variable may be null
   
   Variable [druidQuery](1) may be null at this access as suggested by 
[this](2) null guard.
   Variable [druidQuery](1) may be null at this access as suggested by 
[this](3) null guard.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/8810)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/indexing/LegacyMSQSpec.java:
##########
@@ -0,0 +1,235 @@
+/*
+ * 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 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.query.aggregation.AggregatorFactory;
+import org.apache.druid.sql.calcite.planner.ColumnMappings;
+
+import java.util.Collections;
+import java.util.List;
+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,
+      @JsonProperty("compactionMetricSpec") List<AggregatorFactory> 
compactionMetricSpec1,
+      @JsonProperty("queryContext") QueryContext queryContext)
+  {
+    this(
+        query, columnMappings, destination, assignmentStrategy, tuningConfig, 
compactionMetricSpec1, queryContext, 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("compactionMetricSpec") List<AggregatorFactory> 
compactionMetricSpec1,
+      @JsonProperty("queryContext") QueryContext queryContext,
+      @JsonProperty("queryDef") QueryDefinition queryDef
+  )
+  {
+    super(columnMappings, destination, assignmentStrategy, tuningConfig, 
compactionMetricSpec1, queryContext, queryDef);
+    this.query = query;//Preconditions.checkNotNull(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/8905)



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