jtuglu1 commented on code in PR #19654:
URL: https://github.com/apache/druid/pull/19654#discussion_r3688692778


##########
server/src/main/java/org/apache/druid/server/QueryLifecycle.java:
##########
@@ -212,61 +220,41 @@ public void after(final boolean isDone, final Throwable 
thrown)
    * @throws DruidException if the current state is not NEW, which indicates a 
bug
    */
   public void initialize(final Query<?> baseQuery)
+  {
+    initialize(baseQuery, null);
+  }
+
+  /**
+   * As {@link #initialize(Query)}, but takes the context keys the client 
actually set. Pass {@code null} to treat the
+   * whole context as client-set (native queries). The SQL layer merges static 
defaults into the context, so it must
+   * pass the real client-set keys so dynamic overrides can beat a merged-in 
default without overriding the client.
+   *
+   * @throws DruidException if the current state is not NEW, which indicates a 
bug
+   */
+  public void initialize(final Query<?> baseQuery, @Nullable final Set<String> 
clientProvidedQueryContextKeys)
   {
     transition(State.NEW, State.INITIALIZED);
 
-    userContextKeys = new HashSet<>(baseQuery.getContext().keySet());
+    final Map<String, Object> baseContext = baseQuery.getContext();
+    authorizationContextKeys = new HashSet<>(baseContext.keySet());
+
+    // Keys the client actually set (native queries pass null, so the whole 
context is client-set).
+    final Set<String> effectiveClientProvidedQueryContextKeys =
+        clientProvidedQueryContextKeys != null ? 
clientProvidedQueryContextKeys : baseContext.keySet();
+
     String queryId = baseQuery.getId();
     if (Strings.isNullOrEmpty(queryId)) {
       queryId = UUID.randomUUID().toString();
     }
 
-    // Start with system defaults, apply per-datasource override, then user 
context wins
-    Map<String, Object> contextWithDefaults = new 
HashMap<>(queryConfigProvider.getContext());
-    applyPerDatasourcePerSegmentTimeout(baseQuery, contextWithDefaults, 
queryId);
-    Map<String, Object> finalContext = 
QueryContexts.override(contextWithDefaults, baseQuery.getContext());

Review Comment:
   The dynamic config would never override the per-segment timeout context 
value (assuming it wasn't set directly by the client) if there was a static 
default per-segment timeout context value.



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