mirror of https://github.com/apache/druid.git
Add missing type for MapVirtualColumn (#5598)
This commit is contained in:
parent
685f4063d4
commit
3a5d516308
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue