Search in sources :

Example 1 with SelectInfo

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();
}
Also used : ColumnName(io.confluent.ksql.name.ColumnName) SelectInfo(io.confluent.ksql.execution.transform.select.SelectValueMapper.SelectInfo) Column(io.confluent.ksql.schema.ksql.Column) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema)

Aggregations

SelectInfo (io.confluent.ksql.execution.transform.select.SelectValueMapper.SelectInfo)1 ColumnName (io.confluent.ksql.name.ColumnName)1 Column (io.confluent.ksql.schema.ksql.Column)1 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)1