use of io.confluent.ksql.serde.SerdeFeatures in project ksql by confluentinc.
the class DefaultSchemaInjector method getCreateAsKeySchema.
private Optional<SchemaAndId> getCreateAsKeySchema(final ConfiguredStatement<CreateAsSelect> statement, final CreateSourceCommand createSourceCommand) {
final CreateAsSelect csStmt = statement.getStatement();
final CreateSourceAsProperties props = csStmt.getProperties();
final FormatInfo keyFormat = createSourceCommand.getFormats().getKeyFormat();
if (!shouldInferSchema(props.getKeySchemaId(), statement, keyFormat, true)) {
return Optional.empty();
}
// until we support user-configuration of single key wrapping/unwrapping, we choose
// to have key schema inference always result in an unwrapped key
final SerdeFeatures serdeFeatures = SerdeFeaturesFactory.buildKeyFeatures(FormatFactory.of(keyFormat), true);
if (!shouldInferSchema(props.getKeySchemaId(), statement, keyFormat, true)) {
return Optional.empty();
}
final SchemaAndId schemaAndId = getSchema(props.getKafkaTopic(), props.getKeySchemaId(), keyFormat, serdeFeatures, statement.getStatementText(), true);
final List<Column> tableColumns = createSourceCommand.getSchema().key();
checkColumnsCompatibility(props.getKeySchemaId(), tableColumns, schemaAndId.columns, true);
return Optional.of(schemaAndId);
}
use of io.confluent.ksql.serde.SerdeFeatures in project ksql by confluentinc.
the class SchemaRegisterInjector method registerForCreateSource.
private void registerForCreateSource(final ConfiguredStatement<? extends CreateSource> cs) {
// since this injector is chained after the TopicCreateInjector,
// we can assume that the kafka topic is always present in the
// statement properties
final CreateSource statement = cs.getStatement();
final LogicalSchema schema = statement.getElements().toLogicalSchema();
final FormatInfo keyFormatInfo = SourcePropertiesUtil.getKeyFormat(statement.getProperties(), statement.getName());
final Format keyFormat = tryGetFormat(keyFormatInfo, true, cs.getStatementText());
final SerdeFeatures keyFeatures = SerdeFeaturesFactory.buildKeyFeatures(schema, keyFormat);
final FormatInfo valueFormatInfo = SourcePropertiesUtil.getValueFormat(statement.getProperties());
final Format valueFormat = tryGetFormat(valueFormatInfo, false, cs.getStatementText());
final SerdeFeatures valFeatures = SerdeFeaturesFactory.buildValueFeatures(schema, valueFormat, statement.getProperties().getValueSerdeFeatures(), cs.getSessionConfig().getConfig(false));
final SchemaAndId rawKeySchema = (SchemaAndId) cs.getSessionConfig().getOverrides().get(CommonCreateConfigs.KEY_SCHEMA_ID);
final SchemaAndId rawValueSchema = (SchemaAndId) cs.getSessionConfig().getOverrides().get(CommonCreateConfigs.VALUE_SCHEMA_ID);
registerSchemas(schema, Pair.of(rawKeySchema, rawValueSchema), statement.getProperties().getKafkaTopic(), keyFormatInfo, keyFeatures, valueFormatInfo, valFeatures, cs.getSessionConfig().getConfig(false), cs.getStatementText(), false);
}
Aggregations