surekhasaharan commented on a change in pull request #6830: Add null checks in
DruidSchema
URL: https://github.com/apache/incubator-druid/pull/6830#discussion_r252792185
##########
File path:
sql/src/test/java/org/apache/druid/sql/calcite/schema/DruidSchemaTest.java
##########
@@ -237,4 +238,36 @@ public void testGetTableMapFoo2()
Assert.assertEquals("m1", fields.get(2).getName());
Assert.assertEquals(SqlTypeName.BIGINT,
fields.get(2).getType().getSqlTypeName());
}
+
+ @Test
+ public void testNullDatasource() throws IOException
+ {
+ Map<DataSegment, SegmentMetadataHolder> segmentsMetadata =
schema.getSegmentMetadata();
+ Set<DataSegment> segments = segmentsMetadata.keySet();
+ Assert.assertEquals(segments.size(), 3);
+ final DataSegment segmentToRemove =
segments.stream().findFirst().orElse(null);
+ Assert.assertFalse(segmentToRemove == null);
+ schema.removeSegment(segmentToRemove);
+ schema.refreshSegments(segments); // can cause NPE without
dataSourceSegments null check in DruidSchema#refreshSegmentsForDataSource
Review comment:
yeah, changed to get segment with datasource 'foo2'
----------------------------------------------------------------
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]