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


##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java:
##########
@@ -1473,14 +1480,47 @@
     );
   }
 
+  /**
+   * Create an OperatorQuery which runs an order on top of a scan.
+   */
+  // FIXME: could have a better name...
+  @Nullable
+  private WindowOperatorQuery toScanAndSortQuery()
+  {
+    if (sorting == null || !sorting.isPureOrder()) {
+      return null;
+    }
+
+    ScanQuery scan = toScanQuery(false);
+    if (scan == null) {
+      return null;
+    }
+
+    QueryDataSource newDataSource = new QueryDataSource(scan);
+
+    ArrayList<ColumnWithDirection> sortColumns = 
ColumnWithDirection.fromOrderBysColumnSpecs(sorting.getOrderBys());
+    NaiveSortOperatorFactory sortOperator = new 
NaiveSortOperatorFactory(sortColumns);
+
+    RowSignature signature = getOutputRowSignature();
+    return new WindowOperatorQuery(
+        newDataSource,
+        new LegacySegmentSpec(Intervals.ETERNITY),
+        plannerContext.queryContextMap(),
+        signature,
+        Collections.singletonList(sortOperator),
+        null);
+  }
+
   /**
    * Return this query as a Scan query, or null if this query is not 
compatible with Scan.
    *
    * @return query or null
    */
   @Nullable
-  private ScanQuery toScanQuery()
+  private ScanQuery toScanQuery(boolean considerSorting)
   {
+    final Sorting sorting = considerSorting ? this.sorting : null;

Review Comment:
   ## Possible confusion of local and field
   
   Potentially confusing name: method [toScanQuery](1) also refers to field 
[sorting](2) (as this.sorting).
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/5928)



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