mirror of https://github.com/apache/druid.git
Fix the bug in string last vector aggregation (#14655)
This commit is contained in:
parent
4804630c78
commit
52fbc6939e
|
@ -42,7 +42,7 @@ public class StringLastVectorAggregator implements VectorAggregator
|
|||
protected long lastTime;
|
||||
|
||||
public StringLastVectorAggregator(
|
||||
final BaseLongVectorValueSelector timeSelector,
|
||||
@Nullable final BaseLongVectorValueSelector timeSelector,
|
||||
final VectorObjectSelector valueSelector,
|
||||
final int maxStringBytes
|
||||
)
|
||||
|
@ -124,6 +124,9 @@ public class StringLastVectorAggregator implements VectorAggregator
|
|||
int positionOffset
|
||||
)
|
||||
{
|
||||
if (timeSelector == null) {
|
||||
return;
|
||||
}
|
||||
long[] timeVector = timeSelector.getLongVector();
|
||||
Object[] objectsWhichMightBeStrings = valueSelector.getObjectVector();
|
||||
|
||||
|
|
|
@ -129,6 +129,25 @@ public class StringLastVectorAggregatorTest extends InitializedNullHandlingTest
|
|||
Assert.assertEquals(VALUES[3], result.rhs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aggregateNoOp()
|
||||
{
|
||||
// Test that aggregates run just fine when the input field does not exist
|
||||
StringLastVectorAggregator aggregator = new StringLastVectorAggregator(null, selector, 10);
|
||||
aggregator.aggregate(buf, 0, 0, VALUES.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aggregateBatchNoOp()
|
||||
{
|
||||
// Test that aggregates run just fine when the input field does not exist
|
||||
StringLastVectorAggregator aggregator = new StringLastVectorAggregator(null, selector, 10);
|
||||
int[] positions = new int[]{0, 43, 70};
|
||||
int positionOffset = 2;
|
||||
clearBufferForPositions(positionOffset, positions);
|
||||
aggregator.aggregate(buf, 3, positions, null, positionOffset);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aggregateBatchWithoutRows()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue