mirror of
https://github.com/apache/druid.git
synced 2025-03-08 10:30:38 +00:00
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.
This commit is contained in:
parent
de959e513d
commit
ee78a0367d
@ -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()
|
||||
{
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user