gianm commented on a change in pull request #10318:
URL: https://github.com/apache/druid/pull/10318#discussion_r477580012
##########
File path: processing/src/main/java/org/apache/druid/query/UnionQueryRunner.java
##########
@@ -41,34 +44,51 @@ public UnionQueryRunner(
public Sequence<T> run(final QueryPlus<T> queryPlus, final ResponseContext
responseContext)
{
Query<T> query = queryPlus.getQuery();
- DataSource dataSource = query.getDataSource();
- if (dataSource instanceof UnionDataSource) {
- return new MergeSequence<>(
- query.getResultOrdering(),
- Sequences.simple(
- Lists.transform(
- ((UnionDataSource) dataSource).getDataSources(),
- new Function<DataSource, Sequence<T>>()
- {
- @Override
- public Sequence<T> apply(DataSource singleSource)
- {
- return baseRunner.run(
- queryPlus.withQuery(
- query.withDataSource(singleSource)
- // assign the subqueryId. this will be used
to validate that every query servers
- // have responded per subquery in
RetryQueryRunner
- .withDefaultSubQueryId()
- ),
- responseContext
- );
- }
- }
- )
- )
- );
+ final DataSourceAnalysis analysis =
DataSourceAnalysis.forDataSource(query.getDataSource());
+
+ if (analysis.isConcreteTableBased() &&
analysis.getBaseUnionDataSource().isPresent()) {
+ // Union of tables.
+
+ final UnionDataSource unionDataSource =
analysis.getBaseUnionDataSource().get();
+
+ if (unionDataSource.getDataSources().isEmpty()) {
+ // Shouldn't happen, because UnionDataSource doesn't allow empty
unions.
+ throw new ISE("Unexpectedly received empty union");
+ } else if (unionDataSource.getDataSources().size() == 1) {
Review comment:
Yeah, the idea is let's not create a MergeSequence if there's only going
to be 1 thing.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]