shauryachats commented on code in PR #15760: URL: https://github.com/apache/pinot/pull/15760#discussion_r2082655600
########## pinot-query-planner/src/main/java/org/apache/pinot/query/planner/physical/v2/opt/rules/LeafStageWorkerAssignmentRule.java: ########## @@ -326,6 +345,53 @@ static TableScanWorkerAssignmentResult attemptPartitionedDistribution(String tab return new TableScanWorkerAssignmentResult(dataDistribution, workerIdToSegmentsMap); } + /** + * Infers partition from invalid segments if the passed flag is set to true. + */ + @VisibleForTesting + static Map<Integer, List<String>> getInvalidSegmentsByInferredPartition(@Nullable List<String> invalidSegments, + boolean inferPartitionsForInvalidSegments, String tableNameWithType) { + if (CollectionUtils.isEmpty(invalidSegments)) { + return Map.of(); + } else if (!Objects.equals(TableNameBuilder.getTableTypeFromTableName(tableNameWithType), TableType.REALTIME) + || !inferPartitionsForInvalidSegments) { + throw new IllegalStateException(String.format("Table %s has %s segments with invalid partition info. Will " + + "assume un-partitioned distribution. Sampled: %s", tableNameWithType, invalidSegments.size(), + sampleSegmentsForLogging(invalidSegments))); + } + Map<Integer, List<String>> invalidSegmentsByInferredPartition = new HashMap<>(); + for (String invalidPartitionSegment : invalidSegments) { + int partitionId = -1; + if (LLCSegmentName.isLLCSegment(invalidPartitionSegment)) { Review Comment: nit: Can separate into a separate `inferPartitionId` method for clarity. ``` private static int inferPartitionId(String segmentName) { if (LLCSegmentName.isLLCSegment(segmentName)) { LLCSegmentName llc = LLCSegmentName.of(segmentName); return llc != null ? llc.getPartitionGroupId() : -1; } else if (UploadedRealtimeSegmentName.isUploadedRealtimeSegmentName(segmentName)) { UploadedRealtimeSegmentName uploaded = UploadedRealtimeSegmentName.of(segmentName); return uploaded != null ? uploaded.getPartitionId() : -1; } return -1; } ``` -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org