cryptoe commented on code in PR #14981:
URL: https://github.com/apache/druid/pull/14981#discussion_r1348625288
##########
processing/src/main/java/org/apache/druid/query/UnionDataSource.java:
##########
@@ -51,18 +63,41 @@ public UnionDataSource(@JsonProperty("dataSources")
List<TableDataSource> dataSo
this.dataSources = dataSources;
}
+ public List<DataSource> getDataSources()
+ {
+ return dataSources;
+ }
+
+
+ /**
+ * Asserts that the children of the union are all table data sources before
returning the table names
+ */
@Override
public Set<String> getTableNames()
{
return dataSources.stream()
- .map(input ->
Iterables.getOnlyElement(input.getTableNames()))
+ .map(input -> {
+ if (!(input instanceof TableDataSource)) {
+ throw DruidException.defensive("should be table");
+ }
+ return Iterables.getOnlyElement(input.getTableNames());
Review Comment:
Nit:Lets avoid using Iterables.getOnlyElement(). Lets use
CollectionUtils.getOnlyElement()
##########
extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/test/CalciteUnionQueryMSQTest.java:
##########
@@ -0,0 +1,179 @@
+/*
+ * 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.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.WorkerMemoryParameters;
+import org.apache.druid.msq.sql.MSQTaskSqlEngine;
+import org.apache.druid.query.QueryDataSource;
+import org.apache.druid.query.TableDataSource;
+import org.apache.druid.query.UnionDataSource;
+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.filtration.Filtration;
+import org.apache.druid.sql.calcite.run.SqlEngine;
+import org.apache.druid.sql.calcite.util.CalciteTests;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Runs {@link CalciteUnionQueryTest} but with MSQ engine
+ */
+public class CalciteUnionQueryMSQTest extends CalciteUnionQueryTest
+{
+ private TestGroupByBuffers groupByBuffers;
+
+ @Before
+ public void setup2()
+ {
+ groupByBuffers = TestGroupByBuffers.createDefault();
+ }
+
+ @After
+ public void teardown2()
+ {
+ groupByBuffers.close();
+ }
+
+ @Override
+ public void configureGuice(DruidInjectorBuilder builder)
+ {
+ super.configureGuice(builder);
+ builder.addModules(CalciteMSQTestsHelper.fetchModules(temporaryFolder,
groupByBuffers).toArray(new Module[0]));
+ }
+
+
+ @Override
+ public SqlEngine createEngine(
+ QueryLifecycleFactory qlf,
+ ObjectMapper queryJsonMapper,
+ Injector injector
+ )
+ {
+ final WorkerMemoryParameters workerMemoryParameters =
+ WorkerMemoryParameters.createInstance(
+ WorkerMemoryParameters.PROCESSING_MINIMUM_BYTES * 50,
+ 2,
+ 10,
+ 2,
+ 0,
+ 0
+ );
+ final MSQTestOverlordServiceClient indexingServiceClient = new
MSQTestOverlordServiceClient(
+ queryJsonMapper,
+ injector,
+ new MSQTestTaskActionClient(queryJsonMapper),
+ workerMemoryParameters
+ );
+ return new MSQTaskSqlEngine(indexingServiceClient, queryJsonMapper);
+ }
+
+ @Override
+ protected QueryTestBuilder testBuilder()
+ {
+ return new QueryTestBuilder(new
BaseCalciteQueryTest.CalciteTestConfig(true))
+ .addCustomRunner(new ExtractResultsFactory(() ->
(MSQTestOverlordServiceClient) ((MSQTaskSqlEngine)
queryFramework().engine()).overlordClient()))
+ .skipVectorize(true)
+ .verifyNativeQueries(new VerifyMSQSupportedNativeQueriesPredicate())
+ .msqCompatible(msqCompatible);
+ }
+
+ /**
+ * Doesn't pass through Druid however the planning error is different as it
rewrites to a union datasource.
+ * This test is disabled because MSQ wants to support union datasources, and
it makes little sense to add highly
Review Comment:
This comment seems outdated.
--
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]