diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/MSQDrillWindowQueryTest.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/MSQDrillWindowQueryTest.java index 76187a2188a..c3d5b80af3a 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/MSQDrillWindowQueryTest.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/exec/MSQDrillWindowQueryTest.java @@ -44,6 +44,7 @@ import org.apache.druid.msq.test.MSQTestTaskActionClient; import org.apache.druid.msq.test.VerifyMSQSupportedNativeQueriesPredicate; import org.apache.druid.query.DefaultQueryConfig; import org.apache.druid.query.groupby.TestGroupByBuffers; +import org.apache.druid.quidem.TestSqlModule; import org.apache.druid.server.QueryLifecycleFactory; import org.apache.druid.server.QueryScheduler; import org.apache.druid.server.QuerySchedulerProvider; @@ -53,7 +54,6 @@ import org.apache.druid.server.metrics.NoopServiceEmitter; import org.apache.druid.server.security.AuthenticatorMapper; import org.apache.druid.server.security.AuthorizerMapper; import org.apache.druid.server.security.Escalator; -import org.apache.druid.sql.SqlLifecycleManager; import org.apache.druid.sql.SqlStatementFactory; import org.apache.druid.sql.SqlToolbox; import org.apache.druid.sql.calcite.DrillWindowQueryTest; @@ -62,7 +62,6 @@ import org.apache.druid.sql.calcite.SqlTestFrameworkConfig; import org.apache.druid.sql.calcite.TempDirProducer; import org.apache.druid.sql.calcite.planner.CalciteRulesManager; import org.apache.druid.sql.calcite.planner.CatalogResolver; -import org.apache.druid.sql.calcite.planner.PlannerFactory; import org.apache.druid.sql.calcite.run.SqlEngine; import org.apache.druid.sql.calcite.schema.DruidSchemaName; import org.apache.druid.sql.calcite.util.CalciteTests; @@ -87,7 +86,7 @@ public class MSQDrillWindowQueryTest extends DrillWindowQueryTest builder.addModule(new TestMSQSqlModule()); } - static class TestSqlModule extends TestDruidModule + static class TestSqlModule0 extends TestDruidModule { @Override public void configure(Binder binder) @@ -111,31 +110,9 @@ public class MSQDrillWindowQueryTest extends DrillWindowQueryTest binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER); binder.bind(Escalator.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR); } - } - static class TestMSQSqlModule extends TestDruidModule { -// @Provides - @LazySingleton - public SqlToolbox makeSqlToolbox( - final PlannerFactory plannerFactory, - final ServiceEmitter emitter, - final RequestLogger requestLogger, - final QueryScheduler queryScheduler, - final Supplier defaultQueryConfig, - final SqlLifecycleManager sqlLifecycleManager - ) - { - return new SqlToolbox( - null, - plannerFactory, - emitter, - requestLogger, - queryScheduler, - defaultQueryConfig.get(), - sqlLifecycleManager - ); - } + static class TestMSQSqlModule extends TestDruidModule { @Provides @MultiStageQuery diff --git a/sql/src/test/java/org/apache/druid/quidem/TestSqlModule.java b/sql/src/test/java/org/apache/druid/quidem/TestSqlModule.java new file mode 100644 index 00000000000..53c0976db01 --- /dev/null +++ b/sql/src/test/java/org/apache/druid/quidem/TestSqlModule.java @@ -0,0 +1,51 @@ +package org.apache.druid.quidem; + +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Binder; +import com.google.inject.TypeLiteral; +import org.apache.druid.guice.LazySingleton; +import org.apache.druid.initialization.ServerInjectorBuilderTest.TestDruidModule; +import org.apache.druid.java.util.emitter.service.ServiceEmitter; +import org.apache.druid.query.DefaultQueryConfig; +import org.apache.druid.server.QueryScheduler; +import org.apache.druid.server.QuerySchedulerProvider; +import org.apache.druid.server.log.RequestLogger; +import org.apache.druid.server.log.TestRequestLogger; +import org.apache.druid.server.metrics.NoopServiceEmitter; +import org.apache.druid.server.security.AuthenticatorMapper; +import org.apache.druid.server.security.AuthorizerMapper; +import org.apache.druid.server.security.Escalator; +import org.apache.druid.sql.calcite.planner.CalciteRulesManager; +import org.apache.druid.sql.calcite.planner.CatalogResolver; +import org.apache.druid.sql.calcite.schema.DruidSchemaName; +import org.apache.druid.sql.calcite.util.CalciteTests; +import org.apache.druid.sql.guice.SqlModule; + +public class TestSqlModule extends TestDruidModule +{ + @Override + public void configure(Binder binder) + { + binder.install(new SqlModule.SqlStatementFactoryModule()); + binder.bind(String.class) + .annotatedWith(DruidSchemaName.class) + .toInstance(CalciteTests.DRUID_SCHEMA_NAME); + binder.bind(new TypeLiteral>() + { + }).toInstance(Suppliers.ofInstance(new DefaultQueryConfig(ImmutableMap.of()))); + binder.bind(CalciteRulesManager.class).toInstance(new CalciteRulesManager(ImmutableSet.of())); + TestRequestLogger testRequestLogger = new TestRequestLogger(); + binder.bind(RequestLogger.class).toInstance(testRequestLogger); + binder.bind(CatalogResolver.class).toInstance(CatalogResolver.NULL_RESOLVER); + binder.bind(ServiceEmitter.class).to(NoopServiceEmitter.class); + binder.bind(QueryScheduler.class) + .toProvider(QuerySchedulerProvider.class) + .in(LazySingleton.class); + binder.bind(AuthenticatorMapper.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_MAPPER); + binder.bind(AuthorizerMapper.class).toInstance(CalciteTests.TEST_AUTHORIZER_MAPPER); + binder.bind(Escalator.class).toInstance(CalciteTests.TEST_AUTHENTICATOR_ESCALATOR); + } +}