cryptoe commented on code in PR #17985: URL: https://github.com/apache/druid/pull/17985#discussion_r2086316541
########## extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/PrePlannedDartQueryMaker.java: ########## @@ -0,0 +1,134 @@ +/* + * 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.dart.controller.sql; + +import org.apache.druid.msq.exec.QueryKitBasedMSQPlanner; +import org.apache.druid.msq.exec.ResultsContext; +import org.apache.druid.msq.indexing.LegacyMSQSpec; +import org.apache.druid.msq.indexing.QueryDefMSQSpec; +import org.apache.druid.msq.kernel.QueryDefinition; +import org.apache.druid.msq.logical.DruidLogicalToQueryDefinitionTranslator; +import org.apache.druid.msq.sql.MSQTaskQueryMaker; +import org.apache.druid.query.QueryContext; +import org.apache.druid.query.QueryContexts; +import org.apache.druid.server.QueryResponse; +import org.apache.druid.server.security.ForbiddenException; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.rel.DruidQuery; +import org.apache.druid.sql.calcite.rel.logical.DruidLogicalNode; +import org.apache.druid.sql.calcite.run.QueryMaker; + +import java.util.List; +import java.util.Map.Entry; + +/** + * Executes Dart queries with up-front planned {@link QueryDefinition}. + * + * Normal execution flow utilizes {@link QueryKit} to prdocue the plan; + * meanwhile it also supports planning the {@link QueryDefinition} directly from + * the {@link DruidLogicalNode}. + */ +class PrePlannedDartQueryMaker implements QueryMaker, QueryMaker.FromDruidLogical +{ + private PlannerContext plannerContext; + private DartQueryMaker dartQueryMaker; + + public PrePlannedDartQueryMaker(PlannerContext plannerContext, QueryMaker queryMaker) Review Comment: ```suggestion public PrePlannedDartQueryMaker(PlannerContext plannerContext, DartQueryMaker queryMaker) ``` ########## extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/logical/DruidLogicalToQueryDefinitionTranslator.java: ########## @@ -0,0 +1,141 @@ +/* + * 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.logical; + +import org.apache.calcite.rel.RelNode; +import org.apache.druid.error.DruidException; +import org.apache.druid.java.util.common.Intervals; +import org.apache.druid.msq.input.InputSpec; +import org.apache.druid.msq.kernel.QueryDefinition; +import org.apache.druid.msq.logical.LogicalStageBuilder.RootStage; +import org.apache.druid.msq.querykit.DataSourcePlan; +import org.apache.druid.query.DataSource; +import org.apache.druid.query.InlineDataSource; +import org.apache.druid.query.TableDataSource; +import org.apache.druid.sql.calcite.planner.PlannerContext; +import org.apache.druid.sql.calcite.planner.querygen.DruidQueryGenerator.DruidNodeStack; +import org.apache.druid.sql.calcite.planner.querygen.SourceDescProducer.SourceDesc; +import org.apache.druid.sql.calcite.rel.logical.DruidLogicalNode; +import org.apache.druid.sql.calcite.rel.logical.DruidTableScan; +import org.apache.druid.sql.calcite.rel.logical.DruidValues; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +public class DruidLogicalToQueryDefinitionTranslator +{ + private PlannerContext plannerContext; + private LogicalStageBuilder stageBuilder; + + public DruidLogicalToQueryDefinitionTranslator(PlannerContext plannerContext) + { + this.plannerContext = plannerContext; + this.stageBuilder = new LogicalStageBuilder(plannerContext); + } + + public QueryDefinition translate(DruidLogicalNode relRoot) + { + DruidNodeStack stack = new DruidNodeStack(); + stack.push(relRoot); + LogicalStage logicalStage = buildStageFor(stack); + return logicalStage.build(); + } + + private LogicalStage buildStageFor(DruidNodeStack stack) Review Comment: Could you please add java docs here. That would help for future maintenance. -- 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]
