use of org.apache.druid.segment.column.ColumnCapabilities in project druid by druid-io.
the class ExpressionPlannerTest method testScalarNumeric.
@Test
public void testScalarNumeric() {
ExpressionPlan thePlan = plan("long1 + 5");
Assert.assertTrue(thePlan.is(ExpressionPlan.Trait.SINGLE_INPUT_SCALAR, ExpressionPlan.Trait.VECTORIZABLE));
Assert.assertFalse(thePlan.is(ExpressionPlan.Trait.SINGLE_INPUT_MAPPABLE, ExpressionPlan.Trait.INCOMPLETE_INPUTS, ExpressionPlan.Trait.UNKNOWN_INPUTS, ExpressionPlan.Trait.NEEDS_APPLIED, ExpressionPlan.Trait.NON_SCALAR_INPUTS, ExpressionPlan.Trait.NON_SCALAR_OUTPUT));
Assert.assertEquals("(\"long1\" + 5)", thePlan.getAppliedExpression().stringify());
Assert.assertEquals("(\"long1\" + 5)", thePlan.getAppliedFoldExpression("__acc").stringify());
Assert.assertEquals("(\"long1\" + 5)", thePlan.getAppliedFoldExpression("long1").stringify());
Assert.assertEquals(ExpressionType.LONG, thePlan.getOutputType());
ColumnCapabilities inferred = thePlan.inferColumnCapabilities(null);
Assert.assertNotNull(inferred);
Assert.assertEquals(ValueType.LONG, inferred.getType());
if (NullHandling.sqlCompatible()) {
Assert.assertTrue(inferred.hasNulls().isMaybeTrue());
} else {
Assert.assertFalse(inferred.hasNulls().isMaybeTrue());
}
Assert.assertFalse(inferred.isDictionaryEncoded().isMaybeTrue());
Assert.assertFalse(inferred.areDictionaryValuesSorted().isMaybeTrue());
Assert.assertFalse(inferred.areDictionaryValuesUnique().isMaybeTrue());
Assert.assertFalse(inferred.hasMultipleValues().isMaybeTrue());
Assert.assertFalse(inferred.hasBitmapIndexes());
Assert.assertFalse(inferred.hasSpatialIndexes());
thePlan = plan("long1 + 5.0");
Assert.assertEquals(ExpressionType.DOUBLE, thePlan.getOutputType());
thePlan = plan("double1 * double2");
Assert.assertTrue(thePlan.is(ExpressionPlan.Trait.VECTORIZABLE));
Assert.assertFalse(thePlan.is(ExpressionPlan.Trait.SINGLE_INPUT_SCALAR, ExpressionPlan.Trait.SINGLE_INPUT_MAPPABLE, ExpressionPlan.Trait.INCOMPLETE_INPUTS, ExpressionPlan.Trait.UNKNOWN_INPUTS, ExpressionPlan.Trait.NEEDS_APPLIED, ExpressionPlan.Trait.NON_SCALAR_INPUTS, ExpressionPlan.Trait.NON_SCALAR_OUTPUT));
Assert.assertEquals("(\"double1\" * \"double2\")", thePlan.getAppliedExpression().stringify());
Assert.assertEquals("(\"double1\" * \"double2\")", thePlan.getAppliedFoldExpression("__acc").stringify());
Assert.assertEquals("(\"double1\" * \"double2\")", thePlan.getAppliedFoldExpression("double1").stringify());
Assert.assertEquals(ExpressionType.DOUBLE, thePlan.getOutputType());
inferred = thePlan.inferColumnCapabilities(null);
Assert.assertNotNull(inferred);
Assert.assertEquals(ValueType.DOUBLE, inferred.getType());
if (NullHandling.sqlCompatible()) {
Assert.assertTrue(inferred.hasNulls().isMaybeTrue());
} else {
Assert.assertFalse(inferred.hasNulls().isMaybeTrue());
}
Assert.assertFalse(inferred.isDictionaryEncoded().isMaybeTrue());
Assert.assertFalse(inferred.areDictionaryValuesSorted().isMaybeTrue());
Assert.assertFalse(inferred.areDictionaryValuesUnique().isMaybeTrue());
Assert.assertFalse(inferred.hasMultipleValues().isMaybeTrue());
Assert.assertFalse(inferred.hasBitmapIndexes());
Assert.assertFalse(inferred.hasSpatialIndexes());
}
use of org.apache.druid.segment.column.ColumnCapabilities in project druid by druid-io.
the class ExpressionPlannerTest method testScalarOutputMultiValueInput.
@Test
public void testScalarOutputMultiValueInput() {
ExpressionPlan thePlan = plan("array_to_string(array_append(scalar_string, 'x'), ',')");
assertArrayInput(thePlan);
ColumnCapabilities inferred = thePlan.inferColumnCapabilities(ColumnType.STRING);
Assert.assertNotNull(inferred);
Assert.assertEquals(ValueType.STRING, inferred.getType());
Assert.assertTrue(inferred.hasNulls().isTrue());
Assert.assertFalse(inferred.isDictionaryEncoded().isMaybeTrue());
Assert.assertFalse(inferred.areDictionaryValuesSorted().isMaybeTrue());
Assert.assertFalse(inferred.areDictionaryValuesUnique().isMaybeTrue());
Assert.assertFalse(inferred.hasMultipleValues().isMaybeTrue());
Assert.assertFalse(inferred.hasBitmapIndexes());
Assert.assertFalse(inferred.hasSpatialIndexes());
Assert.assertEquals("array_to_string(array_append(\"scalar_string\", 'x'), ',')", thePlan.getAppliedExpression().stringify());
Assert.assertEquals("array_to_string(array_append(\"scalar_string\", 'x'), ',')", thePlan.getAppliedFoldExpression("__acc").stringify());
Assert.assertEquals(ExpressionType.STRING, thePlan.getOutputType());
// what about a multi-valued input
thePlan = plan("array_to_string(array_append(scalar_string, multi_dictionary_string), ',')");
assertArrayInput(thePlan);
Assert.assertEquals("array_to_string(map((\"multi_dictionary_string\") -> array_append(\"scalar_string\", \"multi_dictionary_string\"), \"multi_dictionary_string\"), ',')", thePlan.getAppliedExpression().stringify());
Assert.assertEquals("array_to_string(fold((\"multi_dictionary_string\", \"scalar_string\") -> array_append(\"scalar_string\", \"multi_dictionary_string\"), \"multi_dictionary_string\", \"scalar_string\"), ',')", thePlan.getAppliedFoldExpression("scalar_string").stringify());
// why is this null
Assert.assertEquals(ExpressionType.STRING, thePlan.getOutputType());
}
use of org.apache.druid.segment.column.ColumnCapabilities in project druid by druid-io.
the class LookupJoinableTest method getColumnCapabilitiesForValueColumnShouldReturnStringCaps.
@Test
public void getColumnCapabilitiesForValueColumnShouldReturnStringCaps() {
ColumnCapabilities capabilities = target.getColumnCapabilities(LookupColumnSelectorFactory.VALUE_COLUMN);
Assert.assertEquals(ValueType.STRING, capabilities.getType());
}
use of org.apache.druid.segment.column.ColumnCapabilities in project druid by druid-io.
the class LookupJoinableTest method getColumnCapabilitiesForKeyColumnShouldReturnStringCaps.
@Test
public void getColumnCapabilitiesForKeyColumnShouldReturnStringCaps() {
ColumnCapabilities capabilities = target.getColumnCapabilities(LookupColumnSelectorFactory.KEY_COLUMN);
Assert.assertEquals(ValueType.STRING, capabilities.getType());
}
use of org.apache.druid.segment.column.ColumnCapabilities in project druid by druid-io.
the class RowBasedStorageAdapterTest method test_getColumnCapabilities_complex.
@Test
public void test_getColumnCapabilities_complex() {
final RowBasedStorageAdapter<Integer> adapter = createIntAdapter(0, 1, 2);
final ColumnCapabilities capabilities = adapter.getColumnCapabilities(ValueType.COMPLEX.name());
// Note: unlike numeric types, COMPLEX-typed columns report that they are incomplete.
Assert.assertEquals(ColumnType.UNKNOWN_COMPLEX, capabilities.toColumnType());
Assert.assertTrue(capabilities.hasMultipleValues().isUnknown());
}
Aggregations