Search in sources :

Example 1 with ConstantMultiValueDimensionSelector

use of org.apache.druid.segment.ConstantMultiValueDimensionSelector in project druid by druid-io.

the class ExpressionVirtualColumnTest method testConstantDimensionSelectors.

@Test
public void testConstantDimensionSelectors() {
    ExpressionVirtualColumn constant = new ExpressionVirtualColumn("constant", Parser.parse("1 + 2", TestExprMacroTable.INSTANCE), ColumnType.LONG);
    DimensionSelector constantSelector = constant.makeDimensionSelector(DefaultDimensionSpec.of("constant"), COLUMN_SELECTOR_FACTORY);
    Assert.assertTrue(constantSelector instanceof ConstantDimensionSelector);
    Assert.assertEquals("3", constantSelector.getObject());
    ExpressionVirtualColumn multiConstant = new ExpressionVirtualColumn("multi", Parser.parse("string_to_array('a,b,c', ',')", TestExprMacroTable.INSTANCE), ColumnType.STRING);
    DimensionSelector multiConstantSelector = multiConstant.makeDimensionSelector(DefaultDimensionSpec.of("multiConstant"), COLUMN_SELECTOR_FACTORY);
    Assert.assertTrue(multiConstantSelector instanceof ConstantMultiValueDimensionSelector);
    Assert.assertEquals(ImmutableList.of("a", "b", "c"), multiConstantSelector.getObject());
}
Also used : ConstantMultiValueDimensionSelector(org.apache.druid.segment.ConstantMultiValueDimensionSelector) DimensionSelector(org.apache.druid.segment.DimensionSelector) ConstantDimensionSelector(org.apache.druid.segment.ConstantDimensionSelector) ConstantMultiValueDimensionSelector(org.apache.druid.segment.ConstantMultiValueDimensionSelector) ConstantDimensionSelector(org.apache.druid.segment.ConstantDimensionSelector) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

ConstantDimensionSelector (org.apache.druid.segment.ConstantDimensionSelector)1 ConstantMultiValueDimensionSelector (org.apache.druid.segment.ConstantMultiValueDimensionSelector)1 DimensionSelector (org.apache.druid.segment.DimensionSelector)1 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1 Test (org.junit.Test)1