pranavbhole commented on code in PR #15434:
URL: https://github.com/apache/druid/pull/15434#discussion_r1407001551
##########
processing/src/test/java/org/apache/druid/query/aggregation/any/StringAnyAggregatorFactoryTest.java:
##########
@@ -72,43 +68,107 @@ public void
canVectorizeWithoutCapabilitiesShouldReturnTrue()
@Test
public void
factorizeVectorWithoutCapabilitiesShouldReturnAggregatorWithMultiDimensionSelector()
{
-
Mockito.doReturn(null).when(vectorSelectorFactory).getColumnCapabilities(FIELD_NAME);
- Mockito.doReturn(singleValueDimensionVectorSelector)
- .when(vectorSelectorFactory)
- .makeSingleValueDimensionSelector(any());
StringAnyVectorAggregator aggregator =
target.factorizeVector(vectorSelectorFactory);
Assert.assertNotNull(aggregator);
}
@Test
public void
factorizeVectorWithUnknownCapabilitiesShouldReturnAggregatorWithMultiDimensionSelector()
{
- Mockito.doReturn(multiValueDimensionVectorSelector)
- .when(vectorSelectorFactory)
- .makeMultiValueDimensionSelector(any());
StringAnyVectorAggregator aggregator =
target.factorizeVector(vectorSelectorFactory);
Assert.assertNotNull(aggregator);
}
@Test
public void
factorizeVectorWithMultipleValuesCapabilitiesShouldReturnAggregatorWithMultiDimensionSelector()
{
-
Mockito.doReturn(ColumnCapabilities.Capable.TRUE).when(capabilities).hasMultipleValues();
- Mockito.doReturn(multiValueDimensionVectorSelector)
- .when(vectorSelectorFactory)
- .makeMultiValueDimensionSelector(any());
StringAnyVectorAggregator aggregator =
target.factorizeVector(vectorSelectorFactory);
Assert.assertNotNull(aggregator);
}
@Test
public void
factorizeVectorWithoutMultipleValuesCapabilitiesShouldReturnAggregatorWithSingleDimensionSelector()
{
-
Mockito.doReturn(ColumnCapabilities.Capable.FALSE).when(capabilities).hasMultipleValues();
- Mockito.doReturn(singleValueDimensionVectorSelector)
- .when(vectorSelectorFactory)
- .makeSingleValueDimensionSelector(any());
StringAnyVectorAggregator aggregator =
target.factorizeVector(vectorSelectorFactory);
Assert.assertNotNull(aggregator);
}
+
+ @Test
+ public void testFactorize()
+ {
+ Aggregator res = target.factorize(new TestColumnSelectorFactory());
+ Assert.assertTrue(res instanceof StringAnyAggregator);
+ res.aggregate();
+ Assert.assertEquals(null, res.get());
+ StringAnyVectorAggregator vectorAggregator =
target.factorizeVector(vectorSelectorFactory);
+ Assert.assertTrue(vectorAggregator.aggregateMultipleValues);
+ }
+
+ @Test
+ public void testSvdStringAnyAggregator()
+ {
+ TestColumnSelectorFactory columnSelectorFactory = new
TestColumnSelectorFactory();
+ Aggregator res = target.factorize(columnSelectorFactory);
+ Assert.assertTrue(res instanceof StringAnyAggregator);
+ columnSelectorFactory.moveSelectorCursorToNext();
+ res.aggregate();
+ Assert.assertEquals("CCCC", res.get());
+ }
+
+ @Test
+ public void testMvdStringAnyAggregator()
+ {
+ TestColumnSelectorFactory columnSelectorFactory = new
TestColumnSelectorFactory();
+ Aggregator res = target.factorize(columnSelectorFactory);
+ Assert.assertTrue(res instanceof StringAnyAggregator);
+ columnSelectorFactory.moveSelectorCursorToNext();
+ columnSelectorFactory.moveSelectorCursorToNext();
+ res.aggregate();
Review Comment:
oh yes, I should have probably mention it in comment, Dummy
TestColumnSelectorFactory Selector that I wrote at the end of class has MVD
present on 3rd place, this moved cursor twice.
--
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]