Add missing type for MapVirtualColumn (#5598)

This commit is contained in:
Jihoon Son 2018-04-09 17:37:24 -07:00 committed by Fangjin Yang
parent 685f4063d4
commit 3a5d516308
2 changed files with 20 additions and 1 deletions

View File

@ -20,6 +20,7 @@
package io.druid.segment;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
@ -34,7 +35,12 @@ public class DruidVirtualColumnsModule implements DruidModule
@Override
public List<? extends Module> getJacksonModules()
{
return ImmutableList.of(new SimpleModule().registerSubtypes(MapVirtualColumn.class));
return ImmutableList.of(
new SimpleModule(getClass().getSimpleName())
.registerSubtypes(
new NamedType(MapVirtualColumn.class, "map")
)
);
}
@Override

View File

@ -19,6 +19,7 @@
package io.druid.segment;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
@ -140,6 +141,18 @@ public class MapVirtualColumnTest
.pagingSpec(new PagingSpec(null, 3));
}
@Test
public void testSerde() throws IOException
{
final ObjectMapper mapper = new DefaultObjectMapper();
new DruidVirtualColumnsModule().getJacksonModules().forEach(mapper::registerModule);
final MapVirtualColumn column = new MapVirtualColumn("keys", "values", "params");
final String json = mapper.writeValueAsString(column);
final VirtualColumn fromJson = mapper.readValue(json, VirtualColumn.class);
Assert.assertEquals(column, fromJson);
}
@Test
public void testBasic()
{