use of io.crate.types.ObjectType in project crate by crate.
the class SubscriptObjectFunction method tryToInferReturnTypeFromObjectTypeAndArguments.
static Symbol tryToInferReturnTypeFromObjectTypeAndArguments(Function func) {
if (!func.valueType().equals(DataTypes.UNDEFINED)) {
return func;
}
var arguments = func.arguments();
ObjectType objectType = (ObjectType) arguments.get(0).valueType();
List<String> path = maybeCreatePath(arguments);
if (path == null) {
return func;
} else {
DataType<?> returnType = objectType.resolveInnerType(path);
return returnType.equals(DataTypes.UNDEFINED) ? func : new Function(func.signature(), func.arguments(), returnType);
}
}
use of io.crate.types.ObjectType in project crate by crate.
the class DataTypeTest method test_is_compatible_type_with_same_names_same_inner_types.
@Test
public void test_is_compatible_type_with_same_names_same_inner_types() {
ObjectType obj1 = ObjectType.builder().setInnerType("a", DataTypes.STRING).build();
ObjectType obj2 = ObjectType.builder().setInnerType("a", DataTypes.STRING).build();
assertThat(DataTypes.isCompatibleType(obj1, obj2), is(true));
}
use of io.crate.types.ObjectType in project crate by crate.
the class DataTypeTest method test_is_compatible_type_on_nested_types_with_same_names_same_inner_types.
@Test
public void test_is_compatible_type_on_nested_types_with_same_names_same_inner_types() {
ObjectType obj1 = ObjectType.builder().setInnerType("obj", ObjectType.builder().setInnerType("a", DataTypes.INTEGER).build()).build();
ObjectType obj2 = ObjectType.builder().setInnerType("obj", ObjectType.builder().setInnerType("a", DataTypes.INTEGER).build()).build();
assertThat(DataTypes.isCompatibleType(obj1, obj2), is(true));
}
use of io.crate.types.ObjectType in project crate by crate.
the class DataTypeTest method test_is_compatible_type_on_nested_types_with_same_names_different_inner_types.
@Test
public void test_is_compatible_type_on_nested_types_with_same_names_different_inner_types() {
ObjectType obj1 = ObjectType.builder().setInnerType("obj", ObjectType.builder().setInnerType("a", DataTypes.INTEGER).build()).build();
ObjectType obj2 = ObjectType.builder().setInnerType("obj", ObjectType.builder().setInnerType("a", DataTypes.STRING).build()).build();
assertThat(DataTypes.isCompatibleType(obj1, obj2), is(false));
}
use of io.crate.types.ObjectType in project crate by crate.
the class DataTypeTest method test_is_compatible_type_with_same_names_different_inner_types.
@Test
public void test_is_compatible_type_with_same_names_different_inner_types() {
ObjectType obj1 = ObjectType.builder().setInnerType("a", DataTypes.INTEGER).build();
ObjectType obj2 = ObjectType.builder().setInnerType("a", DataTypes.STRING).build();
assertThat(DataTypes.isCompatibleType(obj1, obj2), is(false));
}
Aggregations