abhishekagarwal87 commented on code in PR #14560:
URL: https://github.com/apache/druid/pull/14560#discussion_r1262479620
##########
processing/src/main/java/org/apache/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java:
##########
@@ -268,16 +270,30 @@ public static SegmentAnalysis mergeAnalyses(
return arg1;
}
- // Swap arg1, arg2 so the later-ending interval is first. This ensures we
prefer the latest column order.
- // We're preserving it so callers can see columns in their natural order.
- if (dataSource != null) {
+ // This is a defensive check since SegementMetadata query instantiation
guarantees this
+ if (CollectionUtils.isNullOrEmpty(dataSources)) {
+ throw InvalidInput.exception("SegementMetadata queries require at least
one datasource.");
+ }
+
+ SegmentId mergedSegmentId = null;
+
+ for (String dataSource : dataSources) {
final SegmentId id1 = SegmentId.tryParse(dataSource, arg1.getId());
final SegmentId id2 = SegmentId.tryParse(dataSource, arg2.getId());
- if (id1 != null && id2 != null &&
id2.getIntervalEnd().isAfter(id1.getIntervalEnd())) {
- final SegmentAnalysis tmp = arg1;
- arg1 = arg2;
- arg2 = tmp;
+ // Swap arg1, arg2 so the later-ending interval is first. This ensures
we prefer the latest column order.
+ // We're preserving it so callers can see columns in their natural order.
+ if (id1 != null && id2 != null) {
+ if (id2.getIntervalEnd().isAfter(id1.getIntervalEnd()) ||
+ (id2.getIntervalEnd().isEqual(id1.getIntervalEnd()) &&
id2.getPartitionNum() > id1.getPartitionNum())) {
+ mergedSegmentId = SegmentId.merged(dataSource, id2.getInterval(),
id2.getPartitionNum());
+ final SegmentAnalysis tmp = arg1;
+ arg1 = arg2;
+ arg2 = tmp;
+ } else {
+ mergedSegmentId = SegmentId.merged(dataSource, id1.getInterval(),
id1.getPartitionNum());
+ }
+ break;
}
Review Comment:
what's the motivation behind this change? why will there be segment metadata
queries on multiple datasources? is that something we want to support?
--
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]