mirror of https://github.com/apache/druid.git
Convert MSQTerminalStageSpecFactory into an interface (#16996)
* Convert MSQTerminalStageSpecFactory into an interface * Rename class and remove useless constructor
This commit is contained in:
parent
476b205efa
commit
73ff9f9047
|
@ -54,7 +54,7 @@ public class MSQSqlModule implements DruidModule
|
|||
// We want this module to bring InputSourceModule along for the ride.
|
||||
binder.install(new InputSourceModule());
|
||||
|
||||
binder.bind(MSQTerminalStageSpecFactory.class).toInstance(new MSQTerminalStageSpecFactory());
|
||||
binder.bind(MSQTerminalStageSpecFactory.class).to(SegmentGenerationTerminalStageSpecFactory.class).in(LazySingleton.class);
|
||||
|
||||
binder.bind(MSQTaskSqlEngine.class).in(LazySingleton.class);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 SegmentGenerationTerminalStageSpecFactory implements MSQTerminalStageSpecFactory
|
||||
{
|
||||
@Override
|
||||
public TerminalStageSpec createTerminalStageSpec(DruidQuery druidQuery, PlannerContext plannerContext)
|
||||
{
|
||||
return SegmentGenerationStageSpec.instance();
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
package org.apache.druid.msq.sql;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Inject;
|
||||
|
@ -90,12 +89,6 @@ public class MSQTaskSqlEngine implements SqlEngine
|
|||
private final MSQTerminalStageSpecFactory terminalStageSpecFactory;
|
||||
|
||||
@Inject
|
||||
public MSQTaskSqlEngine(final OverlordClient overlordClient, final ObjectMapper jsonMapper)
|
||||
{
|
||||
this(overlordClient, jsonMapper, new MSQTerminalStageSpecFactory());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public MSQTaskSqlEngine(
|
||||
final OverlordClient overlordClient,
|
||||
final ObjectMapper jsonMapper,
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.google.inject.Provides;
|
|||
import org.apache.druid.guice.LazySingleton;
|
||||
import org.apache.druid.initialization.ServerInjectorBuilderTest.TestDruidModule;
|
||||
import org.apache.druid.msq.guice.MultiStageQuery;
|
||||
import org.apache.druid.msq.guice.SegmentGenerationTerminalStageSpecFactory;
|
||||
import org.apache.druid.msq.sql.MSQTaskSqlEngine;
|
||||
import org.apache.druid.msq.test.MSQTestBase;
|
||||
import org.apache.druid.msq.test.MSQTestOverlordServiceClient;
|
||||
|
@ -53,7 +54,7 @@ public class TestMSQSqlModule extends TestDruidModule
|
|||
ObjectMapper queryJsonMapper,
|
||||
MSQTestOverlordServiceClient indexingServiceClient)
|
||||
{
|
||||
return new MSQTaskSqlEngine(indexingServiceClient, queryJsonMapper);
|
||||
return new MSQTaskSqlEngine(indexingServiceClient, queryJsonMapper, new SegmentGenerationTerminalStageSpecFactory());
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -91,8 +91,8 @@ import org.apache.druid.msq.guice.MSQDurableStorageModule;
|
|||
import org.apache.druid.msq.guice.MSQExternalDataSourceModule;
|
||||
import org.apache.druid.msq.guice.MSQIndexingModule;
|
||||
import org.apache.druid.msq.guice.MSQSqlModule;
|
||||
import org.apache.druid.msq.guice.MSQTerminalStageSpecFactory;
|
||||
import org.apache.druid.msq.guice.MultiStageQuery;
|
||||
import org.apache.druid.msq.guice.SegmentGenerationTerminalStageSpecFactory;
|
||||
import org.apache.druid.msq.indexing.InputChannelFactory;
|
||||
import org.apache.druid.msq.indexing.MSQControllerTask;
|
||||
import org.apache.druid.msq.indexing.MSQSpec;
|
||||
|
@ -551,7 +551,7 @@ public class MSQTestBase extends BaseCalciteQueryTest
|
|||
final SqlEngine engine = new MSQTaskSqlEngine(
|
||||
indexingServiceClient,
|
||||
qf.queryJsonMapper().copy().registerModules(new MSQSqlModule().getJacksonModules()),
|
||||
new MSQTerminalStageSpecFactory()
|
||||
new SegmentGenerationTerminalStageSpecFactory()
|
||||
);
|
||||
|
||||
PlannerFactory plannerFactory = new PlannerFactory(
|
||||
|
|
Loading…
Reference in New Issue