kfaraz commented on code in PR #17382:
URL: https://github.com/apache/druid/pull/17382#discussion_r1808048471


##########
sql/src/main/java/org/apache/druid/sql/guice/BrokerServiceModule.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * 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.sql.guice;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.inject.Provides;
+import org.apache.druid.discovery.DruidNodeDiscoveryProvider;
+import org.apache.druid.discovery.NodeRole;
+import org.apache.druid.guice.LazySingleton;
+import org.apache.druid.guice.ManageLifecycle;
+import org.apache.druid.guice.annotations.EscalatedGlobal;
+import org.apache.druid.guice.annotations.Json;
+import org.apache.druid.rpc.DiscoveryServiceLocator;
+import org.apache.druid.rpc.ServiceClientFactory;
+import org.apache.druid.rpc.ServiceLocator;
+import org.apache.druid.rpc.StandardRetryPolicy;
+import org.apache.druid.rpc.guice.ServiceClientModule;
+import org.apache.druid.sql.client.Broker;
+import org.apache.druid.sql.client.BrokerClient;
+import org.apache.druid.sql.client.BrokerClientImpl;
+
+/**
+ * Module that processes can bind to if they require a {@link BrokerClient}.
+ * <p>
+ * This extend {@link ServiceClientModule} because the {@link BrokerClient} 
requires
+ * classes present in the sql module.
+ * </p>
+ */
+public class BrokerServiceModule extends ServiceClientModule

Review Comment:
   Instead of extending, you could add a static method in `ServiceClientModule` 
which is used both by `ServiceClientModule` and this new `BrokerServiceModule`.
   
   The reason I am unsure about extending is it is a little confusing.
   - Firstly we don't need the overlord/coordinator methods exposed by 
`ServiceClientModule`.
   - Secondly, if we install both modules, which one ends up providing the 
`OverlordClient`/`CoordinatorClient` implementation.



##########
sql/src/main/java/org/apache/druid/sql/http/ExplainPlanInformation.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.sql.http;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import org.apache.druid.sql.calcite.planner.ExplainAttributes;
+
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * Class that encapsulates the information of a single plan for an {@code 
EXPLAIN PLAN FOR} query.
+ * <p>
+ * Similar to {@link #getAttributes()}, it's possible to provide more 
structure to {@link #getPlan()},
+ * at least for the native query explain, but there's currently no use case 
for it.
+ * </p>
+ */
+public class ExplainPlanInformation
+{
+  @JsonProperty("PLAN")
+  private final String plan;
+
+  @JsonProperty("RESOURCES")
+  private final String resources;
+
+  @JsonProperty("ATTRIBUTES")
+  @JsonDeserialize(using = ExplainAttributesDeserializer.class)
+  private final ExplainAttributes attributes;
+
+  @JsonCreator
+  public ExplainPlanInformation(
+      @JsonProperty("PLAN") final String plan,
+      @JsonProperty("RESOURCES") final String resources,
+      @JsonProperty("ATTRIBUTES") final ExplainAttributes attributes
+  )
+  {
+    this.plan = plan;
+    this.resources = resources;
+    this.attributes = attributes;
+  }
+
+  public String getPlan()
+  {
+    return plan;
+  }
+
+  public String getResources()
+  {
+    return resources;
+  }
+
+  public ExplainAttributes getAttributes()
+  {
+    return attributes;
+  }
+
+  private static class ExplainAttributesDeserializer extends 
JsonDeserializer<ExplainAttributes>

Review Comment:
   I see, thanks for the clarification. No, using the deserializer is fine.



##########
sql/src/test/java/org/apache/druid/sql/calcite/planner/ExplainAttributesTest.java:
##########
@@ -19,23 +19,31 @@
 
 package org.apache.druid.sql.calcite.planner;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.error.DruidException;
 import org.apache.druid.jackson.DefaultObjectMapper;
 import org.apache.druid.java.util.common.granularity.Granularities;
 import org.junit.Assert;
 import org.junit.Test;
 
 import java.util.Arrays;
 
+import static org.junit.Assert.assertEquals;
+
 public class ExplainAttributesTest
 {
-  private static final ObjectMapper DEFAULT_OBJECT_MAPPER = new 
DefaultObjectMapper();
+  private static final ObjectMapper MAPPER = new DefaultObjectMapper();
 
   @Test
-  public void testSimpleGetters()
+  public void testGetters()
   {
-    ExplainAttributes selectAttributes = new ExplainAttributes("SELECT", null, 
null, null, null);
+    final ExplainAttributes selectAttributes = new ExplainAttributes(
+        "SELECT",
+        null,
+        null,
+        null,
+        null

Review Comment:
   nit: all in one line seemed neater and concise.



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