use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFactory in project beam by apache.
the class SqlOperators method createSqlType.
private static RelDataType createSqlType(SqlTypeName typeName, boolean withNullability) {
final RelDataTypeFactory typeFactory = createTypeFactory();
RelDataType type = typeFactory.createSqlType(typeName);
if (withNullability) {
type = typeFactory.createTypeWithNullability(type, true);
}
return type;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFactory in project beam by apache.
the class TypedCombineFnDelegateTest method testParameterExtractionFromCombineFn_CombineFnDelegate_WithListInsteadOfArray.
@Test
public void testParameterExtractionFromCombineFn_CombineFnDelegate_WithListInsteadOfArray() {
Combine.BinaryCombineFn<List<List<String>>> max = Max.of((Comparator<List<List<String>>> & Serializable) (a, b) -> Integer.compare(a.get(0).get(0).length(), b.get(0).get(0).length()));
UdafImpl<List<List<String>>, Combine.Holder<List<List<String>>>, List<List<String>>> udaf = new UdafImpl<>(new TypedCombineFnDelegate<List<List<String>>, Combine.Holder<List<List<String>>>, List<List<String>>>(max) {
});
RelDataTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
List<FunctionParameter> parameters = udaf.getParameters();
assertEquals(1, parameters.size());
assertEquals(SqlTypeName.ARRAY, parameters.get(0).getType(typeFactory).getSqlTypeName());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFactory in project beam by apache.
the class TypedCombineFnDelegateTest method testParameterExtractionFromCombineFn_CombineFnDelegate.
@Test
public void testParameterExtractionFromCombineFn_CombineFnDelegate() {
Combine.BinaryCombineFn<String> max = Max.of((Comparator<String> & Serializable) (a, b) -> Integer.compare(a.length(), b.length()));
UdafImpl<String, Combine.Holder<String>, String> udaf = new UdafImpl<>(new TypedCombineFnDelegate<String, Combine.Holder<String>, String>(max) {
});
RelDataTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
List<FunctionParameter> parameters = udaf.getParameters();
assertEquals(1, parameters.size());
assertEquals(SqlTypeName.VARCHAR, parameters.get(0).getType(typeFactory).getSqlTypeName());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFactory in project beam by apache.
the class TypedCombineFnDelegateTest method testParameterExtractionFromCombineFn_CombineFnDelegate_WithGenericArray.
@Test
public void testParameterExtractionFromCombineFn_CombineFnDelegate_WithGenericArray() {
Combine.BinaryCombineFn<List<String>[]> max = Max.of((Comparator<List<String>[]> & Serializable) (a, b) -> Integer.compare(a[0].get(0).length(), b[0].get(0).length()));
UdafImpl<List<String>[], Combine.Holder<List<String>[]>, List<String>[]> udaf = new UdafImpl<>(new TypedCombineFnDelegate<List<String>[], Combine.Holder<List<String>[]>, List<String>[]>(max) {
});
exceptions.expect(IllegalArgumentException.class);
RelDataTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
udaf.getParameters().get(0).getType(typeFactory);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFactory in project beam by apache.
the class CalciteUtils method toRelDataType.
private static RelDataType toRelDataType(RelDataTypeFactory dataTypeFactory, Schema schema, int fieldIndex) {
Schema.Field field = schema.getField(fieldIndex);
RelDataType type = toRelDataType(dataTypeFactory, field.getType());
return dataTypeFactory.createTypeWithNullability(type, field.getType().getNullable());
}
Aggregations