use of org.apache.druid.segment.VirtualColumns in project druid by druid-io.
the class VirtualColumnsTest method testNonExistentSelector.
@Test
public void testNonExistentSelector() {
final VirtualColumns virtualColumns = makeVirtualColumns();
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("No such virtual column[bar]");
virtualColumns.makeColumnValueSelector("bar", null);
}
use of org.apache.druid.segment.VirtualColumns in project druid by druid-io.
the class VirtualColumnsTest method testGetCacheKey.
@Test
public void testGetCacheKey() {
final VirtualColumns virtualColumns = VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("expr", "x + y", ColumnType.FLOAT, TestExprMacroTable.INSTANCE)));
final VirtualColumns virtualColumns2 = VirtualColumns.create(ImmutableList.of(new ExpressionVirtualColumn("expr", "x + y", ColumnType.FLOAT, TestExprMacroTable.INSTANCE)));
Assert.assertArrayEquals(virtualColumns.getCacheKey(), virtualColumns2.getCacheKey());
Assert.assertFalse(Arrays.equals(virtualColumns.getCacheKey(), VirtualColumns.EMPTY.getCacheKey()));
}
use of org.apache.druid.segment.VirtualColumns in project druid by druid-io.
the class VirtualColumnsTest method testGetColumnCapabilitiesNilBase.
@Test
public void testGetColumnCapabilitiesNilBase() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final ColumnInspector baseInspector = column -> null;
Assert.assertEquals(ValueType.FLOAT, virtualColumns.getColumnCapabilities(baseInspector, "expr").getType());
Assert.assertEquals(ValueType.LONG, virtualColumns.getColumnCapabilities(baseInspector, "expr2").getType());
Assert.assertNull(virtualColumns.getColumnCapabilities(baseInspector, REAL_COLUMN_NAME));
}
use of org.apache.druid.segment.VirtualColumns in project druid by druid-io.
the class VirtualColumnsTest method testWrapInspectorNilBase.
@Test
public void testWrapInspectorNilBase() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final ColumnInspector baseInspector = column -> null;
final ColumnInspector wrappedInspector = virtualColumns.wrapInspector(baseInspector);
Assert.assertEquals(ValueType.FLOAT, wrappedInspector.getColumnCapabilities("expr").getType());
Assert.assertEquals(ValueType.LONG, wrappedInspector.getColumnCapabilities("expr2").getType());
Assert.assertNull(wrappedInspector.getColumnCapabilities(REAL_COLUMN_NAME));
}
use of org.apache.druid.segment.VirtualColumns in project druid by druid-io.
the class VirtualColumnsTest method testMakeSelectorsWithDotSupport.
@Test
public void testMakeSelectorsWithDotSupport() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final BaseObjectColumnValueSelector objectSelector = virtualColumns.makeColumnValueSelector("foo.5", null);
final DimensionSelector dimensionSelector = virtualColumns.makeDimensionSelector(new DefaultDimensionSpec("foo.5", "x"), null);
final BaseFloatColumnValueSelector floatSelector = virtualColumns.makeColumnValueSelector("foo.5", null);
final BaseLongColumnValueSelector longSelector = virtualColumns.makeColumnValueSelector("foo.5", null);
Assert.assertEquals(5L, objectSelector.getObject());
Assert.assertEquals("5", dimensionSelector.lookupName(dimensionSelector.getRow().get(0)));
Assert.assertEquals(5.0f, floatSelector.getFloat(), 0.0f);
Assert.assertEquals(5L, longSelector.getLong());
}
Aggregations