This is an automated email from the ASF dual-hosted git repository.

adarshsanjeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new bfe47dba6ec Add guard rails for Dart around select destination (#18350)
bfe47dba6ec is described below

commit bfe47dba6ec04bb443051172f16ecabcd31431e3
Author: Adarsh Sanjeev <[email protected]>
AuthorDate: Wed Aug 6 12:15:05 2025 +0530

    Add guard rails for Dart around select destination (#18350)
    
    Druid currently does not support values of the selectDestination other than 
taskReport for Dart. This can cause queries to start failing with cryptic 
exceptions.
    
    This PR adds a validation when choosing the select destination, to use task 
report for Dart queries.
---
 .../apache/druid/msq/util/MultiStageQueryContext.java  | 18 +++++++++++++++++-
 .../druid/msq/util/MultiStageQueryContextTest.java     | 17 +++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/MultiStageQueryContext.java
 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/MultiStageQueryContext.java
index 483646ac379..9cef4899496 100644
--- 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/MultiStageQueryContext.java
+++ 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/MultiStageQueryContext.java
@@ -377,14 +377,30 @@ public class MultiStageQueryContext
     return queryContext.getBoolean(CTX_REMOVE_NULL_BYTES, 
DEFAULT_REMOVE_NULL_BYTES);
   }
 
+  public static boolean isDartQuery(final QueryContext queryContext)
+  {
+    return queryContext.get(QueryContexts.CTX_DART_QUERY_ID) != null;
+  }
 
   public static MSQSelectDestination getSelectDestination(final QueryContext 
queryContext)
   {
-    return QueryContexts.getAsEnum(
+    MSQSelectDestination destination = QueryContexts.getAsEnum(
         CTX_SELECT_DESTINATION,
         queryContext.getString(CTX_SELECT_DESTINATION, 
DEFAULT_SELECT_DESTINATION),
         MSQSelectDestination.class
     );
+
+    if (isDartQuery(queryContext)) {
+      if (!MSQSelectDestination.TASKREPORT.equals(destination)) {
+        log.warn(
+            "Dart does not support [%s]. Using [%s] instead.",
+            destination,
+            MSQSelectDestination.TASKREPORT
+        );
+      }
+      return MSQSelectDestination.TASKREPORT;
+    }
+    return destination;
   }
 
   public static int getRowsInMemory(final QueryContext queryContext)
diff --git 
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/MultiStageQueryContextTest.java
 
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/MultiStageQueryContextTest.java
index bdd5270321a..bd3cf2b8e1b 100644
--- 
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/MultiStageQueryContextTest.java
+++ 
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/MultiStageQueryContextTest.java
@@ -28,6 +28,7 @@ import 
org.apache.druid.msq.indexing.destination.MSQSelectDestination;
 import org.apache.druid.msq.kernel.WorkerAssignmentStrategy;
 import org.apache.druid.query.BadQueryContextException;
 import org.apache.druid.query.QueryContext;
+import org.apache.druid.query.QueryContexts;
 import org.apache.druid.segment.IndexSpec;
 import org.apache.druid.segment.column.StringEncodingStrategy;
 import org.hamcrest.CoreMatchers;
@@ -326,6 +327,22 @@ public class MultiStageQueryContextTest
     );
   }
 
+  @Test
+  public void testDartSelectDestination()
+  {
+    final QueryContext context = QueryContext.of(
+        ImmutableMap.of(
+            QueryContexts.CTX_DART_QUERY_ID, "test",
+            MultiStageQueryContext.CTX_SELECT_DESTINATION, "durablestorage"
+        )
+    );
+
+    Assert.assertEquals(
+        MSQSelectDestination.TASKREPORT,
+        MultiStageQueryContext.getSelectDestination(context)
+    );
+  }
+
   private static List<String> decodeSortOrder(@Nullable final String input)
   {
     return 
MultiStageQueryContext.decodeList(MultiStageQueryContext.CTX_SORT_ORDER, input);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to