use of io.confluent.ksql.schema.ksql.SchemaConverters.SqlToConnectTypeConverter in project ksql by confluentinc.
the class ConnectSchemas method columnsToConnectSchema.
/**
* Convert a list of columns into a Connect Struct schema with fields to match.
*
* @param columns the list of columns.
* @return the Struct schema.
*/
public static ConnectSchema columnsToConnectSchema(final List<? extends SimpleColumn> columns) {
final SqlToConnectTypeConverter converter = SchemaConverters.sqlToConnectConverter();
final SchemaBuilder builder = SchemaBuilder.struct();
for (final SimpleColumn column : columns) {
final Schema colSchema = converter.toConnectSchema(column.type());
builder.field(column.name().text(), colSchema);
}
return (ConnectSchema) builder.build();
}
Aggregations