diff --git a/processing/src/main/java/io/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java b/processing/src/main/java/io/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java index dfe20e1bc32..9144f01e763 100644 --- a/processing/src/main/java/io/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java +++ b/processing/src/main/java/io/druid/query/metadata/SegmentMetadataQueryQueryToolChest.java @@ -36,7 +36,6 @@ import com.metamx.emitter.service.ServiceMetricEvent; import io.druid.collections.OrderedMergeSequence; import io.druid.common.guava.CombiningSequence; import io.druid.common.utils.JodaUtils; -import io.druid.data.input.Row; import io.druid.query.CacheStrategy; import io.druid.query.DruidMetrics; import io.druid.query.Query; @@ -53,6 +52,7 @@ import org.joda.time.Interval; import javax.annotation.Nullable; import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; @@ -149,7 +149,7 @@ public class SegmentMetadataQueryQueryToolChest extends QueryToolChest newIntervals = null; if (query.hasInterval()) { - newIntervals = arg1.getIntervals(); + newIntervals = new ArrayList<>(arg1.getIntervals()); newIntervals.addAll(arg2.getIntervals()); } diff --git a/processing/src/test/java/io/druid/query/metadata/SegmentMetadataQueryTest.java b/processing/src/test/java/io/druid/query/metadata/SegmentMetadataQueryTest.java index a269d468a72..5289e3439ae 100644 --- a/processing/src/test/java/io/druid/query/metadata/SegmentMetadataQueryTest.java +++ b/processing/src/test/java/io/druid/query/metadata/SegmentMetadataQueryTest.java @@ -122,6 +122,53 @@ public class SegmentMetadataQueryTest Assert.assertEquals(Arrays.asList(expectedSegmentAnalysis), results); } + @Test + public void testSegmentMetadataQueryWithDefaultAnalysisMerge() + { + SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis( + "merged", + ImmutableList.of( + expectedSegmentAnalysis.getIntervals().get(0), + expectedSegmentAnalysis.getIntervals().get(0) + ), + ImmutableMap.of( + "placement", + new ColumnAnalysis( + ValueType.STRING.toString(), + 21762, + 1, + null + ) + ), + expectedSegmentAnalysis.getSize()*2, + expectedSegmentAnalysis.getNumRows()*2 + ); + + QueryToolChest toolChest = factory.getToolchest(); + + QueryRunner singleSegmentQueryRunner = toolChest.preMergeQueryDecoration(runner); + ExecutorService exec = Executors.newCachedThreadPool(); + QueryRunner myRunner = new FinalizeResultsQueryRunner<>( + toolChest.mergeResults( + factory.mergeRunners( + Executors.newCachedThreadPool(), + Lists.>newArrayList(singleSegmentQueryRunner, singleSegmentQueryRunner) + ) + ), + toolChest + ); + + TestHelper.assertExpectedObjects( + ImmutableList.of(mergedSegmentAnalysis), + myRunner.run( + testQuery, + Maps.newHashMap() + ), + "failed SegmentMetadata bySegment query" + ); + exec.shutdownNow(); + } + @Test public void testBySegmentResults() {