gianm commented on a change in pull request #10030:
URL: https://github.com/apache/druid/pull/10030#discussion_r476204166
##########
File path:
server/src/main/java/org/apache/druid/server/coordination/ServerManager.java
##########
@@ -204,22 +224,45 @@ public ServerManager(
analysis.getBaseQuery().orElse(query)
);
- final FunctionalIterable<QueryRunner<T>> queryRunners = FunctionalIterable
- .create(specs)
- .transformCat(
- descriptor -> Collections.singletonList(
- buildQueryRunnerForSegment(
+ final FunctionalIterable<QueryRunner<T>> queryRunners;
+ // This is to handle cases where multiple datasources may have the same
SegmentDescriptor for an interval.
Review comment:
I don't think this is going to work in all cases. Consider the case
where two datasources that are being unioned both have a segment with version
V1, interval 2000/P1D, and partition 0. But let's say the second datasource
_also_ has one with version V2. In this case V1 should be overshadowed, but
with this logic, it won't be. Both V1 and V2 will be processed for the second
datasource.
I think to properly push this down to historicals, we'll need to change
MultipleSpecificSegmentSpec to associate datasources with segment descriptors.
##########
File path:
processing/src/main/java/org/apache/druid/query/MultiTableDataSource.java
##########
@@ -0,0 +1,53 @@
+/*
+ * 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.query;
+
+import org.apache.druid.timeline.Overshadowable;
+import org.apache.druid.timeline.TimelineLookup;
+import org.apache.druid.timeline.TimelineObjectHolder;
+import org.joda.time.Interval;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiFunction;
+
+/**
+ * Represents a source of data for a query obtained from multiple base tables.
Implementations of this interface
+ * must handle more than one table dataSource.
Review comment:
Hmm, why not make TableDataSource an implementation of this interface,
and give it a pretty basic `retrieveSegmentsForIntervals` method? Then, we know
that anything that access tables directly is an implementation of this
interface. It might make some of the logic in DataSourceAnalysis simpler.
##########
File path: processing/src/main/java/org/apache/druid/query/UnionDataSource.java
##########
@@ -26,12 +26,19 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.timeline.Overshadowable;
+import org.apache.druid.timeline.TimelineLookup;
+import org.apache.druid.timeline.TimelineObjectHolder;
+import org.joda.time.Interval;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.function.BiFunction;
import java.util.stream.Collectors;
-public class UnionDataSource implements DataSource
+public class UnionDataSource implements MultiTableDataSource
Review comment:
In the future, if we wanted to extend UnionDataSource to support
unioning nontables (like, perhaps, unioning the results of queries) then do you
see a good migration path to get there?
----------------------------------------------------------------
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]