IndexMergerTest: Empty column test

This commit is contained in:
Gian Merlino 2013-02-14 21:07:17 -08:00
parent 53e801ecb3
commit 22d1f2a0c0
1 changed files with 30 additions and 0 deletions

View File

@ -19,6 +19,7 @@
package com.metamx.druid.index.v1; package com.metamx.druid.index.v1;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.io.Files; import com.google.common.io.Files;
@ -111,4 +112,33 @@ public class IndexMergerTest
FileUtils.deleteQuietly(mergedDir); FileUtils.deleteQuietly(mergedDir);
} }
} }
@Test
public void testPersistEmptyColumn() throws Exception
{
final IncrementalIndex toPersist = new IncrementalIndex(0L, QueryGranularity.NONE, new AggregatorFactory[]{});
final File tmpDir = Files.createTempDir();
try {
toPersist.add(
new MapBasedInputRow(
1L,
ImmutableList.of("dim1", "dim2"),
ImmutableMap.<String, Object>of("dim1", ImmutableList.of(), "dim2", "foo")
)
);
final QueryableIndex merged = IndexIO.loadIndex(
IndexMerger.persist(toPersist, tmpDir)
);
Assert.assertEquals(1, merged.getTimeColumn().getLength());
Assert.assertEquals(ImmutableList.of("dim1", "dim2"), ImmutableList.copyOf(merged.getAvailableDimensions()));
Assert.assertEquals(null, merged.getColumn("dim1"));
} finally {
FileUtils.deleteQuietly(tmpDir);
}
}
} }