use of org.apache.arrow.adapter.jdbc.JdbcToArrowConfigBuilder in project Mycat2 by MyCATApache.
the class NewVertxConnectionImpl method resultSetColumnToVectorRowSchema.
public static Schema resultSetColumnToVectorRowSchema(List<ColumnDefinition> columnDefinitions) {
int columnCount = columnDefinitions.size();
ImmutableList.Builder<Field> builder = ImmutableList.builder();
JdbcToArrowConfigBuilder jdbcToArrowConfigBuilder = new JdbcToArrowConfigBuilder();
JdbcToArrowConfig jdbcToArrowConfig = jdbcToArrowConfigBuilder.build();
for (int i = 0; i < columnCount; i++) {
ColumnDefinition columnDefinition = columnDefinitions.get(i);
String columnName = columnDefinition.name();
int columnType = columnDefinition.jdbcType().getVendorTypeNumber();
boolean signed = (columnDefinition.flags() & MySQLFieldsType.UNSIGNED_FLAG) == 0;
boolean nullable = (columnDefinition.flags() & MySQLFieldsType.UNSIGNED_FLAG) == 0;
ArrowType arrowType = (ArrowType) jdbcToArrowConfig.getJdbcToArrowTypeConverter().apply(new JdbcFieldInfo(columnType, 0, 0));
FieldType fieldType = new FieldType(nullable, arrowType, null);
builder.add(new org.apache.arrow.vector.types.pojo.Field(columnName, fieldType, Collections.emptyList()));
}
return new org.apache.arrow.vector.types.pojo.Schema(builder.build());
}
Aggregations