use of io.confluent.ksql.execution.transform.select.SelectValueMapper.SelectInfo in project ksql by confluentinc.
the class Selection method buildSchema.
private static LogicalSchema buildSchema(final LogicalSchema sourceSchema, final SelectValueMapper<?> mapper, final List<ColumnName> keyColumnNames) {
final List<ColumnName> keyNames = keyColumnNames.isEmpty() ? getKeyColumnNames(sourceSchema) : keyColumnNames;
final List<Column> keyCols = sourceSchema.key();
if (keyNames.size() != keyCols.size()) {
throw new IllegalArgumentException("key name count mismatch. " + "names: " + keyNames + ", " + "keys: " + keyCols);
}
final LogicalSchema.Builder schemaBuilder = LogicalSchema.builder();
for (int i = 0; i != keyCols.size(); ++i) {
schemaBuilder.keyColumn(keyNames.get(i), keyCols.get(i).type());
}
for (final SelectInfo select : mapper.getSelects()) {
schemaBuilder.valueColumn(select.getFieldName(), select.getEvaluator().getExpressionType());
}
return schemaBuilder.build();
}
Aggregations