Fix the bug in string last vector aggregation (#14655)

This commit is contained in:
Abhishek Agarwal 2023-07-26 09:18:03 +05:30 committed by GitHub
parent 4804630c78
commit 52fbc6939e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -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();

View File

@ -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()
{