You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "adarshsanjeev (via GitHub)" <gi...@apache.org> on 2024/09/04 07:48:27 UTC

[PR] Convert MSQTerminalStageSpecFactory into an interface (druid)

adarshsanjeev opened a new pull request, #16996:
URL: https://github.com/apache/druid/pull/16996

   This PR performs a minor refactor which converts MSQTerminalStageSpecFactory into an interface.
   MSQTerminalStageSpecFactory was introduced in https://github.com/apache/druid/pull/16699. 
   
   Changing this class into an interface will allow configuring the behavior directly by binding the required implementation.
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Convert MSQTerminalStageSpecFactory into an interface (druid)

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #16996:
URL: https://github.com/apache/druid/pull/16996#discussion_r1743280101


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/MSQTerminalStageSpecFactory.java:
##########
@@ -19,19 +19,14 @@
 
 package org.apache.druid.msq.guice;
 
-import org.apache.druid.msq.indexing.destination.SegmentGenerationStageSpec;
 import org.apache.druid.msq.indexing.destination.TerminalStageSpec;
 import org.apache.druid.sql.calcite.planner.PlannerContext;
 import org.apache.druid.sql.calcite.rel.DruidQuery;
 
-public class MSQTerminalStageSpecFactory
+public interface MSQTerminalStageSpecFactory
 {
   /**
-   * Creates a {@link TerminalStageSpec} which determines the final of a query. Currently, always returns a segment
-   * generation spec, but this can be used to configure a wide range of behaviours.
+   * Creates a {@link TerminalStageSpec} which determines the final of a query.
    */
-  public TerminalStageSpec createTerminalStageSpec(DruidQuery druidQuery, PlannerContext plannerContext)
-  {
-    return SegmentGenerationStageSpec.instance();
-  }
+  TerminalStageSpec createTerminalStageSpec(DruidQuery druidQuery, PlannerContext plannerContext);

Review Comment:
   ## Useless parameter
   
   The parameter 'druidQuery' is never used.
   
   [Show more details](https://github.com/apache/druid/security/code-scanning/7780)



##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/MSQTerminalStageSpecFactory.java:
##########
@@ -19,19 +19,14 @@
 
 package org.apache.druid.msq.guice;
 
-import org.apache.druid.msq.indexing.destination.SegmentGenerationStageSpec;
 import org.apache.druid.msq.indexing.destination.TerminalStageSpec;
 import org.apache.druid.sql.calcite.planner.PlannerContext;
 import org.apache.druid.sql.calcite.rel.DruidQuery;
 
-public class MSQTerminalStageSpecFactory
+public interface MSQTerminalStageSpecFactory
 {
   /**
-   * Creates a {@link TerminalStageSpec} which determines the final of a query. Currently, always returns a segment
-   * generation spec, but this can be used to configure a wide range of behaviours.
+   * Creates a {@link TerminalStageSpec} which determines the final of a query.
    */
-  public TerminalStageSpec createTerminalStageSpec(DruidQuery druidQuery, PlannerContext plannerContext)
-  {
-    return SegmentGenerationStageSpec.instance();
-  }
+  TerminalStageSpec createTerminalStageSpec(DruidQuery druidQuery, PlannerContext plannerContext);

Review Comment:
   ## Useless parameter
   
   The parameter 'plannerContext' is never used.
   
   [Show more details](https://github.com/apache/druid/security/code-scanning/7781)



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Convert MSQTerminalStageSpecFactory into an interface (druid)

Posted by "adarshsanjeev (via GitHub)" <gi...@apache.org>.
adarshsanjeev commented on code in PR #16996:
URL: https://github.com/apache/druid/pull/16996#discussion_r1745246049


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/NewSegmentsStageSpecFactory.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.guice;
+
+import org.apache.druid.msq.indexing.destination.SegmentGenerationStageSpec;
+import org.apache.druid.msq.indexing.destination.TerminalStageSpec;
+import org.apache.druid.sql.calcite.planner.PlannerContext;
+import org.apache.druid.sql.calcite.rel.DruidQuery;
+
+/**
+ * Configures ingestion queries to create new segments with the results in all cases.
+ */
+public class NewSegmentsStageSpecFactory implements MSQTerminalStageSpecFactory

Review Comment:
   Changed



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Convert MSQTerminalStageSpecFactory into an interface (druid)

Posted by "adarshsanjeev (via GitHub)" <gi...@apache.org>.
adarshsanjeev commented on code in PR #16996:
URL: https://github.com/apache/druid/pull/16996#discussion_r1745246510


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/MSQTaskSqlEngine.java:
##########
@@ -92,7 +93,7 @@ public class MSQTaskSqlEngine implements SqlEngine
   @Inject
   public MSQTaskSqlEngine(final OverlordClient overlordClient, final ObjectMapper jsonMapper)
   {
-    this(overlordClient, jsonMapper, new MSQTerminalStageSpecFactory());
+    this(overlordClient, jsonMapper, new NewSegmentsStageSpecFactory());

Review Comment:
   Removed this constructor



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Convert MSQTerminalStageSpecFactory into an interface (druid)

Posted by "cryptoe (via GitHub)" <gi...@apache.org>.
cryptoe commented on code in PR #16996:
URL: https://github.com/apache/druid/pull/16996#discussion_r1743886547


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/MSQTaskSqlEngine.java:
##########
@@ -92,7 +93,7 @@ public class MSQTaskSqlEngine implements SqlEngine
   @Inject
   public MSQTaskSqlEngine(final OverlordClient overlordClient, final ObjectMapper jsonMapper)
   {
-    this(overlordClient, jsonMapper, new MSQTerminalStageSpecFactory());
+    this(overlordClient, jsonMapper, new NewSegmentsStageSpecFactory());

Review Comment:
   This factory should come from the MSQ module. I donot think a new is required here no ?



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Convert MSQTerminalStageSpecFactory into an interface (druid)

Posted by "cryptoe (via GitHub)" <gi...@apache.org>.
cryptoe commented on code in PR #16996:
URL: https://github.com/apache/druid/pull/16996#discussion_r1743889068


##########
extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/guice/NewSegmentsStageSpecFactory.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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.guice;
+
+import org.apache.druid.msq.indexing.destination.SegmentGenerationStageSpec;
+import org.apache.druid.msq.indexing.destination.TerminalStageSpec;
+import org.apache.druid.sql.calcite.planner.PlannerContext;
+import org.apache.druid.sql.calcite.rel.DruidQuery;
+
+/**
+ * Configures ingestion queries to create new segments with the results in all cases.
+ */
+public class NewSegmentsStageSpecFactory implements MSQTerminalStageSpecFactory

Review Comment:
   Nit : can this be called `SegmentGenerationTerminalStageSpecFactory` ?



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Convert MSQTerminalStageSpecFactory into an interface (druid)

Posted by "cryptoe (via GitHub)" <gi...@apache.org>.
cryptoe merged PR #16996:
URL: https://github.com/apache/druid/pull/16996


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org