From c40474285c8d73e7a28d2aa2e405ad4cac11a0f9 Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Mon, 5 Aug 2024 13:49:08 +0000 Subject: [PATCH] updates --- .../msq/test/CalciteArraysQueryMSQTest.java | 40 +------------ .../test/CalciteNestedDataQueryMSQTest.java | 40 +------------ .../test/CalciteSelectJoinQueryMSQTest.java | 42 +------------ .../msq/test/CalciteSelectQueryMSQTest.java | 29 +-------- .../msq/test/CalciteUnionQueryMSQTest.java | 41 +------------ .../test/StandardMSQComponentSupplier.java | 60 +++++++++++++++++++ .../apache/druid/quidem/TestSqlModule.java | 2 + .../sql/calcite/CalciteArraysQueryTest.java | 18 +----- .../calcite/CalciteNestedDataQueryTest.java | 1 - 9 files changed, 69 insertions(+), 204 deletions(-) create mode 100644 extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/StandardMSQComponentSupplier.java diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteArraysQueryMSQTest.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteArraysQueryMSQTest.java index 90428f1353d..b761e402d35 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteArraysQueryMSQTest.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteArraysQueryMSQTest.java @@ -19,55 +19,17 @@ package org.apache.druid.msq.test; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.apache.druid.guice.DruidInjectorBuilder; -import org.apache.druid.msq.exec.TestMSQSqlModule; import org.apache.druid.msq.sql.MSQTaskSqlEngine; -import org.apache.druid.msq.test.CalciteArraysQueryMSQTest.ArraysQueryMSQComponentSupplier; -import org.apache.druid.query.groupby.TestGroupByBuffers; -import org.apache.druid.server.QueryLifecycleFactory; import org.apache.druid.sql.calcite.CalciteArraysQueryTest; import org.apache.druid.sql.calcite.QueryTestBuilder; import org.apache.druid.sql.calcite.SqlTestFrameworkConfig; -import org.apache.druid.sql.calcite.TempDirProducer; -import org.apache.druid.sql.calcite.run.SqlEngine; /** * Runs {@link CalciteArraysQueryTest} but with MSQ engine */ -@SqlTestFrameworkConfig.ComponentSupplier(ArraysQueryMSQComponentSupplier.class) +@SqlTestFrameworkConfig.ComponentSupplier(StandardMSQComponentSupplier.class) public class CalciteArraysQueryMSQTest extends CalciteArraysQueryTest { - public static class ArraysQueryMSQComponentSupplier extends ArraysComponentSupplier - { - public ArraysQueryMSQComponentSupplier(TempDirProducer tempFolderProducer) - { - super(tempFolderProducer); - } - - @Override - public void configureGuice(DruidInjectorBuilder builder) - { - super.configureGuice(builder); - builder.addModules( - CalciteMSQTestsHelper.fetchModules(tempDirProducer::newTempFolder, TestGroupByBuffers.createDefault()).toArray(new Module[0]) - ); - builder.addModule(new TestMSQSqlModule()); - } - - @Override - public SqlEngine createEngine( - QueryLifecycleFactory qlf, - ObjectMapper queryJsonMapper, - Injector injector - ) - { - return injector.getInstance(MSQTaskSqlEngine.class); - } - } - @Override protected QueryTestBuilder testBuilder() { diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteNestedDataQueryMSQTest.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteNestedDataQueryMSQTest.java index 0a2b8955a3d..3788d442da2 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteNestedDataQueryMSQTest.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteNestedDataQueryMSQTest.java @@ -19,59 +19,21 @@ package org.apache.druid.msq.test; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.apache.druid.guice.DruidInjectorBuilder; import org.apache.druid.java.util.common.ISE; -import org.apache.druid.msq.exec.TestMSQSqlModule; import org.apache.druid.msq.sql.MSQTaskSqlEngine; -import org.apache.druid.query.groupby.TestGroupByBuffers; -import org.apache.druid.server.QueryLifecycleFactory; import org.apache.druid.sql.calcite.CalciteNestedDataQueryTest; import org.apache.druid.sql.calcite.QueryTestBuilder; import org.apache.druid.sql.calcite.SqlTestFrameworkConfig; -import org.apache.druid.sql.calcite.TempDirProducer; -import org.apache.druid.sql.calcite.run.SqlEngine; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * Runs {@link CalciteNestedDataQueryTest} but with MSQ engine */ -@SqlTestFrameworkConfig.ComponentSupplier(CalciteNestedDataQueryMSQTest.NestedDataQueryMSQComponentSupplier.class) +@SqlTestFrameworkConfig.ComponentSupplier(StandardMSQComponentSupplier.class) public class CalciteNestedDataQueryMSQTest extends CalciteNestedDataQueryTest { - - public static class NestedDataQueryMSQComponentSupplier extends NestedComponentSupplier - { - public NestedDataQueryMSQComponentSupplier(TempDirProducer tempFolderProducer) - { - super(tempFolderProducer); - } - - @Override - public void configureGuice(DruidInjectorBuilder builder) - { - super.configureGuice(builder); - builder.addModules( - CalciteMSQTestsHelper.fetchModules(tempDirProducer::newTempFolder, TestGroupByBuffers.createDefault()).toArray(new Module[0]) - ); - builder.addModule(new TestMSQSqlModule()); - } - - @Override - public SqlEngine createEngine( - QueryLifecycleFactory qlf, - ObjectMapper queryJsonMapper, - Injector injector - ) - { - return injector.getInstance(MSQTaskSqlEngine.class); - } - } - @Override protected QueryTestBuilder testBuilder() { diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectJoinQueryMSQTest.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectJoinQueryMSQTest.java index de5c2042630..78ceb0c80a3 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectJoinQueryMSQTest.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectJoinQueryMSQTest.java @@ -19,24 +19,14 @@ package org.apache.druid.msq.test; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.apache.druid.guice.DruidInjectorBuilder; -import org.apache.druid.msq.exec.TestMSQSqlModule; import org.apache.druid.msq.sql.MSQTaskSqlEngine; -import org.apache.druid.query.groupby.TestGroupByBuffers; -import org.apache.druid.server.QueryLifecycleFactory; import org.apache.druid.sql.calcite.BaseCalciteQueryTest; import org.apache.druid.sql.calcite.CalciteJoinQueryTest; import org.apache.druid.sql.calcite.QueryTestBuilder; import org.apache.druid.sql.calcite.SqlTestFrameworkConfig; -import org.apache.druid.sql.calcite.TempDirProducer; import org.apache.druid.sql.calcite.planner.JoinAlgorithm; import org.apache.druid.sql.calcite.planner.PlannerContext; -import org.apache.druid.sql.calcite.run.SqlEngine; -import org.apache.druid.sql.calcite.util.SqlTestFramework.StandardComponentSupplier; import java.util.Map; @@ -48,7 +38,7 @@ public class CalciteSelectJoinQueryMSQTest /** * Run all tests with {@link JoinAlgorithm#BROADCAST}. */ - @SqlTestFrameworkConfig.ComponentSupplier(JoinComponentSupplier.class) + @SqlTestFrameworkConfig.ComponentSupplier(StandardMSQComponentSupplier.class) public static class BroadcastTest extends Base { @Override @@ -68,7 +58,7 @@ public class CalciteSelectJoinQueryMSQTest /** * Run all tests with {@link JoinAlgorithm#SORT_MERGE}. */ - @SqlTestFrameworkConfig.ComponentSupplier(JoinComponentSupplier.class) + @SqlTestFrameworkConfig.ComponentSupplier(StandardMSQComponentSupplier.class) public static class SortMergeTest extends Base { @Override @@ -112,32 +102,4 @@ public class CalciteSelectJoinQueryMSQTest .skipVectorize(true); } } - - public static final class JoinComponentSupplier extends StandardComponentSupplier - { - public JoinComponentSupplier(TempDirProducer tempFolderProducer) - { - super(tempFolderProducer); - } - - @Override - public void configureGuice(DruidInjectorBuilder builder) - { - super.configureGuice(builder); - builder.addModules( - CalciteMSQTestsHelper.fetchModules(tempDirProducer::newTempFolder, TestGroupByBuffers.createDefault()).toArray(new Module[0]) - ); - builder.addModule(new TestMSQSqlModule()); - } - - @Override - public SqlEngine createEngine( - QueryLifecycleFactory qlf, - ObjectMapper queryJsonMapper, - Injector injector - ) - { - return injector.getInstance(MSQTaskSqlEngine.class); - } - } } diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectQueryMSQTest.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectQueryMSQTest.java index 2039b2f2426..6cd253e3b1c 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectQueryMSQTest.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteSelectQueryMSQTest.java @@ -29,7 +29,6 @@ import org.apache.druid.guice.DruidInjectorBuilder; import org.apache.druid.java.util.common.ISE; import org.apache.druid.msq.exec.TestMSQSqlModule; import org.apache.druid.msq.sql.MSQTaskSqlEngine; -import org.apache.druid.msq.test.CalciteSelectQueryMSQTest.SelectMSQComponentSupplier; import org.apache.druid.query.groupby.TestGroupByBuffers; import org.apache.druid.server.QueryLifecycleFactory; import org.apache.druid.sql.calcite.CalciteQueryTest; @@ -48,35 +47,9 @@ import java.util.concurrent.TimeUnit; /** * Runs {@link CalciteQueryTest} but with MSQ engine */ -@SqlTestFrameworkConfig.ComponentSupplier(SelectMSQComponentSupplier.class) +@SqlTestFrameworkConfig.ComponentSupplier(StandardMSQComponentSupplier.class) public class CalciteSelectQueryMSQTest extends CalciteQueryTest { - public static class SelectMSQComponentSupplier extends StandardComponentSupplier - { - public SelectMSQComponentSupplier(TempDirProducer tempFolderProducer) - { - super(tempFolderProducer); - } - - @Override - public void configureGuice(DruidInjectorBuilder builder) - { - super.configureGuice(builder); - builder.addModules(CalciteMSQTestsHelper.fetchModules(tempDirProducer::newTempFolder, TestGroupByBuffers.createDefault()).toArray(new Module[0])); - builder.addModule(new TestMSQSqlModule()); - } - - @Override - public SqlEngine createEngine( - QueryLifecycleFactory qlf, - ObjectMapper queryJsonMapper, - Injector injector - ) - { - return injector.getInstance(MSQTaskSqlEngine.class); - } - } - @Override protected QueryTestBuilder testBuilder() { diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteUnionQueryMSQTest.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteUnionQueryMSQTest.java index 96760418d78..f0686498786 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteUnionQueryMSQTest.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteUnionQueryMSQTest.java @@ -19,14 +19,9 @@ package org.apache.druid.msq.test; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; -import com.google.inject.Injector; -import com.google.inject.Module; import org.apache.druid.common.config.NullHandling; -import org.apache.druid.guice.DruidInjectorBuilder; import org.apache.druid.java.util.common.granularity.Granularities; -import org.apache.druid.msq.exec.TestMSQSqlModule; import org.apache.druid.msq.sql.MSQTaskSqlEngine; import org.apache.druid.query.QueryDataSource; import org.apache.druid.query.TableDataSource; @@ -35,55 +30,21 @@ import org.apache.druid.query.aggregation.CountAggregatorFactory; import org.apache.druid.query.aggregation.LongSumAggregatorFactory; import org.apache.druid.query.dimension.DefaultDimensionSpec; import org.apache.druid.query.groupby.GroupByQuery; -import org.apache.druid.query.groupby.TestGroupByBuffers; -import org.apache.druid.server.QueryLifecycleFactory; import org.apache.druid.sql.calcite.BaseCalciteQueryTest; import org.apache.druid.sql.calcite.CalciteUnionQueryTest; import org.apache.druid.sql.calcite.QueryTestBuilder; import org.apache.druid.sql.calcite.SqlTestFrameworkConfig; -import org.apache.druid.sql.calcite.TempDirProducer; import org.apache.druid.sql.calcite.filtration.Filtration; -import org.apache.druid.sql.calcite.run.SqlEngine; import org.apache.druid.sql.calcite.util.CalciteTests; -import org.apache.druid.sql.calcite.util.SqlTestFramework.StandardComponentSupplier; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** * Runs {@link CalciteUnionQueryTest} but with MSQ engine */ -@SqlTestFrameworkConfig.ComponentSupplier(CalciteUnionQueryMSQTest.UnionQueryMSQComponentSupplier.class) +@SqlTestFrameworkConfig.ComponentSupplier(StandardMSQComponentSupplier.class) public class CalciteUnionQueryMSQTest extends CalciteUnionQueryTest { - - public static class UnionQueryMSQComponentSupplier extends StandardComponentSupplier - { - public UnionQueryMSQComponentSupplier(TempDirProducer tempFolderProducer) - { - super(tempFolderProducer); - } - - @Override - public void configureGuice(DruidInjectorBuilder builder) - { - super.configureGuice(builder); - builder.addModules( - CalciteMSQTestsHelper.fetchModules(tempDirProducer::newTempFolder, TestGroupByBuffers.createDefault()).toArray(new Module[0]) - ); - builder.addModule(new TestMSQSqlModule()); - } - - @Override - public SqlEngine createEngine( - QueryLifecycleFactory qlf, - ObjectMapper queryJsonMapper, - Injector injector - ) - { - return injector.getInstance(MSQTaskSqlEngine.class); - } - } - @Override protected QueryTestBuilder testBuilder() { diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/StandardMSQComponentSupplier.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/StandardMSQComponentSupplier.java new file mode 100644 index 00000000000..2bf64408c14 --- /dev/null +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/StandardMSQComponentSupplier.java @@ -0,0 +1,60 @@ +/* + * 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.test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Injector; +import com.google.inject.Module; +import org.apache.druid.guice.DruidInjectorBuilder; +import org.apache.druid.msq.exec.TestMSQSqlModule; +import org.apache.druid.msq.sql.MSQTaskSqlEngine; +import org.apache.druid.query.groupby.TestGroupByBuffers; +import org.apache.druid.server.QueryLifecycleFactory; +import org.apache.druid.sql.calcite.TempDirProducer; +import org.apache.druid.sql.calcite.run.SqlEngine; +import org.apache.druid.sql.calcite.util.SqlTestFramework.StandardComponentSupplier; + +public final class StandardMSQComponentSupplier extends StandardComponentSupplier +{ + public StandardMSQComponentSupplier(TempDirProducer tempFolderProducer) + { + super(tempFolderProducer); + } + + @Override + public void configureGuice(DruidInjectorBuilder builder) + { + super.configureGuice(builder); + builder.addModules( + CalciteMSQTestsHelper.fetchModules(tempDirProducer::newTempFolder, TestGroupByBuffers.createDefault()) + .toArray(new Module[0]) + ); + builder.addModule(new TestMSQSqlModule()); + } + + @Override + public SqlEngine createEngine( + QueryLifecycleFactory qlf, + ObjectMapper queryJsonMapper, + Injector injector) + { + return injector.getInstance(MSQTaskSqlEngine.class); + } +} \ No newline at end of file diff --git a/sql/src/test/java/org/apache/druid/quidem/TestSqlModule.java b/sql/src/test/java/org/apache/druid/quidem/TestSqlModule.java index 2b4ca258507..51e56258785 100644 --- a/sql/src/test/java/org/apache/druid/quidem/TestSqlModule.java +++ b/sql/src/test/java/org/apache/druid/quidem/TestSqlModule.java @@ -25,6 +25,7 @@ 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.BuiltInTypesModule; import org.apache.druid.guice.LazySingleton; import org.apache.druid.initialization.ServerInjectorBuilderTest.TestDruidModule; import org.apache.druid.java.util.emitter.service.ServiceEmitter; @@ -67,5 +68,6 @@ public class TestSqlModule extends TestDruidModule 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); + binder.install(new BuiltInTypesModule()); } } diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java index 2e89c2eeb04..358f059767f 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java @@ -70,7 +70,6 @@ import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.RowSignature; import org.apache.druid.segment.join.JoinType; import org.apache.druid.segment.virtual.ExpressionVirtualColumn; -import org.apache.druid.sql.calcite.CalciteArraysQueryTest.ArraysComponentSupplier; import org.apache.druid.sql.calcite.filtration.Filtration; import org.apache.druid.sql.calcite.util.CalciteTests; import org.apache.druid.sql.calcite.util.SqlTestFramework.StandardComponentSupplier; @@ -86,7 +85,7 @@ import java.util.Map; /** * Tests for array functions and array types */ -@SqlTestFrameworkConfig.ComponentSupplier(ArraysComponentSupplier.class) +@SqlTestFrameworkConfig.ComponentSupplier(StandardComponentSupplier.class) public class CalciteArraysQueryTest extends BaseCalciteQueryTest { private static final Map QUERY_CONTEXT_UNNEST = @@ -119,21 +118,6 @@ public class CalciteArraysQueryTest extends BaseCalciteQueryTest } } - protected static class ArraysComponentSupplier extends StandardComponentSupplier - { - public ArraysComponentSupplier(TempDirProducer tempFolderProducer) - { - super(tempFolderProducer); - } - - @Override - public void configureGuice(DruidInjectorBuilder builder) - { - super.configureGuice(builder); - builder.addModule(new BuiltInTypesModule()); - } - } - // test some query stuffs, sort of limited since no native array column types so either need to use constructor or // array aggregator @Test diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java index 5efc59420ad..88ad05a4a27 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteNestedDataQueryTest.java @@ -196,7 +196,6 @@ public class CalciteNestedDataQueryTest extends BaseCalciteQueryTest public void configureGuice(DruidInjectorBuilder builder) { super.configureGuice(builder); - builder.addModule(new BuiltInTypesModule()); } @SuppressWarnings("resource")