This is an automated email from the ASF dual-hosted git repository.
abhishek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 52fbc6939e Fix the bug in string last vector aggregation (#14655)
52fbc6939e is described below
commit 52fbc6939e0caaaa636946a62d256d60723e441f
Author: Abhishek Agarwal <[email protected]>
AuthorDate: Wed Jul 26 09:18:03 2023 +0530
Fix the bug in string last vector aggregation (#14655)
---
.../aggregation/last/StringLastVectorAggregator.java | 5 ++++-
.../last/StringLastVectorAggregatorTest.java | 19 +++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git
a/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregator.java
b/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregator.java
index 045360ba61..f10584a2c7 100644
---
a/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregator.java
+++
b/processing/src/main/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregator.java
@@ -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();
diff --git
a/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregatorTest.java
b/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregatorTest.java
index 428ff3e374..6e5c027510 100644
---
a/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregatorTest.java
+++
b/processing/src/test/java/org/apache/druid/query/aggregation/last/StringLastVectorAggregatorTest.java
@@ -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()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]