jihoonson commented on a change in pull request #6888: Fix num_rows in
sys.segments
URL: https://github.com/apache/incubator-druid/pull/6888#discussion_r255241404
##########
File path:
sql/src/test/java/org/apache/druid/sql/calcite/schema/DruidSchemaTest.java
##########
@@ -239,6 +246,62 @@ public void testGetTableMapFoo2()
Assert.assertEquals(SqlTypeName.BIGINT,
fields.get(2).getType().getSqlTypeName());
}
+ /**
+ * This tests that {@link SegmentMetadataHolder#getNumRows()} is correct in
case
+ * of multiple replicas i.e. when {@link
DruidSchema#addSegment(DruidServerMetadata, DataSegment)}
+ * is called more than once for same segment
+ */
+ @Test
+ public void testSegmentMetadataHolderNumRows()
+ {
+ Map<DataSegment, SegmentMetadataHolder> segmentsMetadata =
schema.getSegmentMetadata();
+ final Set<DataSegment> segments = segmentsMetadata.keySet();
+ Assert.assertEquals(3, segments.size());
+ // find the only segment with datasource "foo2"
+ final DataSegment existingSegment = segments.stream()
+ .filter(segment ->
segment.getDataSource().equals("foo2"))
+ .findFirst()
+ .orElse(null);
+ Assert.assertNotNull(existingSegment);
+ final SegmentMetadataHolder existingHolder =
segmentsMetadata.get(existingSegment);
+ //update SegmentMetadataHolder of existingSegment with numRows=5
Review comment:
nit: please make the style of comments consistent. I think it's better to
add a space after `//` because most of comments do.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]