use of io.confluent.ksql.schema.ksql.PersistenceSchema in project ksql by confluentinc.
the class KafkaSerdeFactoryTest method shouldThroIfMultipleFields.
@Test
public void shouldThroIfMultipleFields() {
// Given:
final PersistenceSchema schema = getPersistenceSchema(LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(ColumnName.of("f0"), SqlTypes.INTEGER).valueColumn(ColumnName.of("f1"), SqlTypes.BIGINT).build());
// When:
final Exception e = assertThrows(KsqlException.class, () -> KafkaSerdeFactory.createSerde(schema));
// Then:
assertThat(e.getMessage(), containsString("The 'KAFKA' format only supports a single field. Got: [`f0` INTEGER, `f1` BIGINT]"));
}
use of io.confluent.ksql.schema.ksql.PersistenceSchema in project ksql by confluentinc.
the class KafkaSerdeFactoryTest method shouldThroIfBoolean.
@Test
public void shouldThroIfBoolean() {
// Given:
final PersistenceSchema schema = schemaWithFieldOfType(SqlTypes.BOOLEAN);
// When:
final Exception e = assertThrows(KsqlException.class, () -> KafkaSerdeFactory.createSerde(schema));
// Then:
assertThat(e.getMessage(), containsString("The 'KAFKA' format does not support type 'BOOLEAN'"));
}
use of io.confluent.ksql.schema.ksql.PersistenceSchema in project ksql by confluentinc.
the class KafkaSerdeFactoryTest method shouldThrowIfStruct.
@Test
public void shouldThrowIfStruct() {
// Given:
final PersistenceSchema schema = schemaWithFieldOfType(SqlTypes.struct().field("f0", SqlTypes.STRING).build());
// When:
final Exception e = assertThrows(KsqlException.class, () -> KafkaSerdeFactory.createSerde(schema));
// Then:
assertThat(e.getMessage(), containsString("The 'KAFKA' format does not support type 'STRUCT'"));
}
use of io.confluent.ksql.schema.ksql.PersistenceSchema in project ksql by confluentinc.
the class DataGenProducer method getKeySerializer.
private Serializer<GenericKey> getKeySerializer(final LogicalSchema schema) {
final Set<SerdeFeature> supported = keySerializerFactory.format().supportedFeatures();
final SerdeFeatures features = supported.contains(SerdeFeature.UNWRAP_SINGLES) ? SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES) : SerdeFeatures.of();
final PersistenceSchema persistenceSchema = PersistenceSchema.from(schema.key(), features);
return keySerializerFactory.create(persistenceSchema);
}
use of io.confluent.ksql.schema.ksql.PersistenceSchema in project ksql by confluentinc.
the class AvroFormatTest method shouldThrowWhenCreatingSerdeIfSchemaContainsInvalidAvroNames.
@Test
public void shouldThrowWhenCreatingSerdeIfSchemaContainsInvalidAvroNames() {
// Given:
final PersistenceSchema schema = PersistenceSchema.from(ImmutableList.of(column("1AintRight")), SerdeFeatures.of());
// When:
final Exception e = assertThrows(KsqlException.class, () -> format.getSerde(schema, formatProps, config, srFactory, false));
// Then:
assertThat(e.getMessage(), is("Schema is not compatible with Avro: Illegal initial character: 1AintRight"));
}
Aggregations