clintropolis commented on code in PR #15241:
URL: https://github.com/apache/druid/pull/15241#discussion_r1375104355


##########
processing/src/test/java/org/apache/druid/query/operator/NaivePartitioningOperatorFactoryTest.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.query.operator;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import java.util.Arrays;
+
+public class NaivePartitioningOperatorFactoryTest
+{
+  @Test
+  public void testEquals()
+  {
+    new EqualsTester()

Review Comment:
   nit: we've been using `EqualsVerifier` for many equals/hashcode tests, is it 
easier to use this one for these classes for some reason? (I don't see anything 
using this anywhere else in codebase)



##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java:
##########
@@ -1474,12 +1487,93 @@ private WindowOperatorQuery toWindowQuery()
   }
 
   /**
-   * Return this query as a Scan query, or null if this query is not 
compatible with Scan.
+   * Create an OperatorQuery which runs an order on top of a scan.
+   */
+  @Nullable
+  private WindowOperatorQuery toScanAndSortQuery()
+  {
+    if (sorting == null
+        || sorting.getOrderBys().isEmpty()
+        || sorting.getProjection() != null) {
+      return null;
+    }
+
+    ScanQuery scan = toScanQuery(false);
+    if (scan == null) {
+      return null;
+    }
+
+    if (queryRunsOnHistorical()) {
+      // Currently only non-time orderings of subqueries are allowed.
+      List<String> orderByColumnNames = sorting.getOrderBys()
+          .stream().map(OrderByColumnSpec::getDimension)
+          .collect(Collectors.toList());
+      plannerContext.setPlanningError(
+          "SQL query requires ordering a table by non-time column [%s], which 
is not supported.",
+          orderByColumnNames);

Review Comment:
   super nitpick, but much of codebase puts trailing `)` on newlines so stuff 
is symmetrical ⚖️  (noticed this in lots of other places too)
   ```suggestion
         plannerContext.setPlanningError(
             "SQL query requires ordering a table by non-time column [%s], 
which is not supported.",
             orderByColumnNames
         );
   ```
   not a blocker by any means, just throwing this out there since i find it 
more aesthetically pleasing 😅 
   



##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidOuterQueryRel.java:
##########
@@ -47,7 +47,7 @@
  */
 public class DruidOuterQueryRel extends DruidRel<DruidOuterQueryRel>
 {
-  private static final TableDataSource DUMMY_DATA_SOURCE = new 
TableDataSource("__subquery__");
+  public static final TableDataSource DUMMY_DATA_SOURCE = new 
TableDataSource("__subquery__");

Review Comment:
   i wonder if we should just override `isConcrete` to return false instead of 
making this public and checking specifically for this, because we could 
simplify the scan query conversion to just check for `!isConcrete` instead of 
checking for this instance or concrete



##########
sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java:
##########
@@ -1474,12 +1487,93 @@ private WindowOperatorQuery toWindowQuery()
   }
 
   /**
-   * Return this query as a Scan query, or null if this query is not 
compatible with Scan.
+   * Create an OperatorQuery which runs an order on top of a scan.
+   */
+  @Nullable
+  private WindowOperatorQuery toScanAndSortQuery()
+  {
+    if (sorting == null
+        || sorting.getOrderBys().isEmpty()
+        || sorting.getProjection() != null) {
+      return null;
+    }
+
+    ScanQuery scan = toScanQuery(false);
+    if (scan == null) {
+      return null;
+    }
+
+    if (queryRunsOnHistorical()) {
+      // Currently only non-time orderings of subqueries are allowed.
+      List<String> orderByColumnNames = sorting.getOrderBys()
+          .stream().map(OrderByColumnSpec::getDimension)
+          .collect(Collectors.toList());
+      plannerContext.setPlanningError(
+          "SQL query requires ordering a table by non-time column [%s], which 
is not supported.",
+          orderByColumnNames);

Review Comment:
   super nitpick, but much of codebase puts trailing `)` on newlines so stuff 
is symmetrical ⚖️  (noticed this in lots of other places too)
   ```suggestion
         plannerContext.setPlanningError(
             "SQL query requires ordering a table by non-time column [%s], 
which is not supported.",
             orderByColumnNames
         );
   ```
   not a blocker by any means, just throwing this out there since i find it 
more aesthetically pleasing 😅 
   



##########
processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java:
##########
@@ -207,6 +208,19 @@ public RowSignature resultArraySignature(final ScanQuery 
query)
     }
   }
 
+  private ColumnType getDataSoruceColumnType(DataSource dataSource, String 
columnName)

Review Comment:
   typo, should be `getDataSourceColumnType`, also mark `@Nullable`



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