adarshsanjeev commented on code in PR #14527:
URL: https://github.com/apache/druid/pull/14527#discussion_r1254411392


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/MSQTaskQueryMaker.java:
##########
@@ -229,8 +231,11 @@ public QueryResponse<Object[]> runQuery(final DruidQuery 
druidQuery)
       if (ctxDestination != null && 
!DESTINATION_REPORT.equals(ctxDestination)) {
         throw new IAE("Cannot SELECT with destination [%s]", ctxDestination);
       }
-
-      destination = TaskReportMSQDestination.instance();
+      if 
(MultiStageQueryContext.getSelectDestination(sqlQueryContext).equals(MSQSelectDestination.TASK_REPORT))
 {
+        destination = TaskReportMSQDestination.instance();
+      } else {

Review Comment:
   nit: this should have a separate if else check for durable storage.



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/shuffle/output/DurableStorageOutputChannelFactory.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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.shuffle.output;
+
+import com.google.common.base.Preconditions;
+import org.apache.druid.frame.channel.ByteTracker;
+import org.apache.druid.frame.file.FrameFileWriter;
+import org.apache.druid.frame.processor.OutputChannel;
+import org.apache.druid.frame.processor.OutputChannelFactory;
+import org.apache.druid.java.util.common.ISE;
+import org.apache.druid.java.util.common.concurrent.Execs;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.storage.StorageConnector;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.channels.Channels;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public abstract class DurableStorageOutputChannelFactory implements 
OutputChannelFactory
+{
+  private static final Logger LOG = new 
Logger(DurableStorageTaskOutputChannelFactoryImpl.class);

Review Comment:
   DurableStorageOutputChannelFactory.class



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/shuffle/output/DurableStorageTaskOutputChannelFactoryImpl.java:
##########
@@ -33,100 +33,63 @@
 import org.apache.druid.frame.file.FrameFileFooter;
 import org.apache.druid.frame.file.FrameFileWriter;
 import org.apache.druid.frame.processor.OutputChannel;
-import org.apache.druid.frame.processor.OutputChannelFactory;
 import org.apache.druid.frame.processor.PartitionedOutputChannel;
 import org.apache.druid.frame.util.DurableStorageUtils;
 import org.apache.druid.java.util.common.FileUtils;
 import org.apache.druid.java.util.common.ISE;
 import org.apache.druid.java.util.common.MappedByteBufferHandler;
 import org.apache.druid.java.util.common.StringUtils;
-import org.apache.druid.java.util.common.concurrent.Execs;
-import org.apache.druid.java.util.common.logger.Logger;
 import org.apache.druid.storage.StorageConnector;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStreamWriter;
 import java.io.UncheckedIOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.channels.Channels;
-import java.nio.charset.StandardCharsets;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 import java.util.function.Supplier;
 
-public class DurableStorageOutputChannelFactory implements OutputChannelFactory
+public class DurableStorageTaskOutputChannelFactoryImpl

Review Comment:
   We can drop the Impl here



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/shuffle/output/DurableStorageResultsOutputChannelFactory.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.shuffle.output;
+
+import org.apache.druid.frame.allocation.ArenaMemoryAllocator;
+import org.apache.druid.frame.channel.ByteTracker;
+import org.apache.druid.frame.channel.ReadableNilFrameChannel;
+import org.apache.druid.frame.channel.WritableFrameFileChannel;
+import org.apache.druid.frame.file.FrameFileWriter;
+import org.apache.druid.frame.processor.OutputChannel;
+import org.apache.druid.frame.processor.PartitionedOutputChannel;
+import org.apache.druid.frame.util.DurableStorageUtils;
+import org.apache.druid.java.util.common.UOE;
+import org.apache.druid.storage.StorageConnector;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.channels.Channels;
+
+public class DurableStorageResultsOutputChannelFactory extends 
DurableStorageOutputChannelFactory

Review Comment:
   nit: Since the input factory is called 
`DurableStorageQueryResultsInputChannelFactory`, we should call this 
`DurableStorageQueryResultsOutputChannelFactory`



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java:
##########
@@ -306,76 +315,127 @@ public Response doGetResults(
       }
 
       MSQControllerTask msqControllerTask = 
getMSQControllerTaskOrThrow(queryId, authenticationResult.getIdentity());
-      SqlStatementState sqlStatementState = 
SqlStatementResourceHelper.getSqlStatementState(statusPlus);
+      throwIfQueryIsNotSuccessful(queryId, statusPlus);
 
-      if (sqlStatementState == SqlStatementState.RUNNING || sqlStatementState 
== SqlStatementState.ACCEPTED) {
-        return buildNonOkResponse(
-            DruidException.forPersona(DruidException.Persona.USER)
-                          .ofCategory(DruidException.Category.INVALID_INPUT)
-                          .build(
-                              "Query[%s] is currently in [%s] state. Please 
wait for it to complete.",
-                              queryId,
-                              sqlStatementState
-                          )
-        );
-      } else if (sqlStatementState == SqlStatementState.FAILED) {
-        return buildNonOkResponse(
-            DruidException.forPersona(DruidException.Persona.USER)
-                          .ofCategory(DruidException.Category.INVALID_INPUT)
-                          .build(
-                              "Query[%s] failed. Hit status api for more 
details.",
-                              queryId
-                          )
-        );
-      } else {
-        Optional<List<ColumnNameAndTypes>> signature = 
SqlStatementResourceHelper.getSignature(msqControllerTask);
-        if (!signature.isPresent()) {
-          return Response.ok().build();
-        }
+      Optional<List<ColumnNameAndTypes>> signature = 
SqlStatementResourceHelper.getSignature(msqControllerTask);
+      if (!signature.isPresent() || 
MSQControllerTask.isIngestion(msqControllerTask.getQuerySpec())) {

Review Comment:
   Is there a need for both these conditions? Shouldn't signature be present 
only for selects?



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/SqlStatementResourceHelper.java:
##########
@@ -137,6 +164,66 @@ public static long getLastIndex(Long numberOfRows, long 
start)
     return last;
   }
 
+  public static Optional<List<PageInformation>> populatePageList(

Review Comment:
   I think this function could use a javadoc on how the page information is 
gathered from the counters.



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