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 ee78a0367d1 Fix serialization bug in PassthroughAggregatorFactory
(#15830)
ee78a0367d1 is described below
commit ee78a0367d1512463d5b9e53b9444fc8052aaa43
Author: Laksh Singla <[email protected]>
AuthorDate: Mon Feb 5 15:11:10 2024 +0530
Fix serialization bug in PassthroughAggregatorFactory (#15830)
PassthroughAggregatorFactory overrides a deprecated method in the
AggregatorFactory, on which it relies on for serializing one of its fields
complexTypeName. This was accidentally removed, leading to a bug in the
factory, where the type name doesn't get serialized properly, and places null
in the type name. This PR revives that method with a different name and adds
tests for the same.
---
.../druid/msq/util/PassthroughAggregatorFactory.java | 13 ++++++++++++-
.../msq/util/PassthroughAggregatorFactoryTest.java | 18 ++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java
index 9d76f8eb895..8de47936eb4 100644
---
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java
+++
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/util/PassthroughAggregatorFactory.java
@@ -66,12 +66,23 @@ public class PassthroughAggregatorFactory extends
AggregatorFactory
this.complexTypeName = complexTypeName;
}
- @JsonProperty
+ @JsonProperty("columnName")
public String getColumnName()
{
return columnName;
}
+ /**
+ * The getter for this variable is named differently because the
'getComplexTypeName' is a deprecated method present
+ * in the super class {@link AggregatorFactory}, and can be removed
discriminately here, leading to incorrect serde of
+ * the aggregator factory over the wire
+ */
+ @JsonProperty("complexTypeName")
+ public String getComplexName()
+ {
+ return complexTypeName;
+ }
+
@Override
public byte[] getCacheKey()
{
diff --git
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/PassthroughAggregatorFactoryTest.java
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/PassthroughAggregatorFactoryTest.java
index 288d14ac994..00cd5715a85 100644
---
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/PassthroughAggregatorFactoryTest.java
+++
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/util/PassthroughAggregatorFactoryTest.java
@@ -19,8 +19,11 @@
package org.apache.druid.msq.util;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import nl.jqno.equalsverifier.EqualsVerifier;
+import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.query.aggregation.AggregatorFactory;
import
org.apache.druid.query.aggregation.AggregatorFactoryNotMergeableException;
import org.junit.Assert;
@@ -28,6 +31,21 @@ import org.junit.Test;
public class PassthroughAggregatorFactoryTest
{
+
+ @Test
+ public void testSerde() throws JsonProcessingException
+ {
+ ObjectMapper objectMapper = new DefaultObjectMapper();
+ objectMapper.registerSubtypes(PassthroughAggregatorFactory.class);
+ AggregatorFactory aggregatorFactory = new
PassthroughAggregatorFactory("x", "y");
+ String serializedvalue =
objectMapper.writeValueAsString(aggregatorFactory);
+ Assert.assertEquals(
+
"{\"type\":\"passthrough\",\"columnName\":\"x\",\"complexTypeName\":\"y\"}",
+ serializedvalue
+ );
+ Assert.assertEquals(aggregatorFactory,
objectMapper.readValue(serializedvalue, AggregatorFactory.class));
+ }
+
@Test
public void testRequiredFields()
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]