Search in sources :

Example 6 with PersistenceSchema

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]"));
}
Also used : PersistenceSchema(io.confluent.ksql.schema.ksql.PersistenceSchema) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 7 with PersistenceSchema

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'"));
}
Also used : PersistenceSchema(io.confluent.ksql.schema.ksql.PersistenceSchema) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 8 with PersistenceSchema

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'"));
}
Also used : PersistenceSchema(io.confluent.ksql.schema.ksql.PersistenceSchema) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 9 with PersistenceSchema

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);
}
Also used : SerdeFeature(io.confluent.ksql.serde.SerdeFeature) PersistenceSchema(io.confluent.ksql.schema.ksql.PersistenceSchema) SerdeFeatures(io.confluent.ksql.serde.SerdeFeatures)

Example 10 with 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"));
}
Also used : PersistenceSchema(io.confluent.ksql.schema.ksql.PersistenceSchema) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Aggregations

PersistenceSchema (io.confluent.ksql.schema.ksql.PersistenceSchema)23 Test (org.junit.Test)20 KsqlException (io.confluent.ksql.util.KsqlException)10 ImmutableList (com.google.common.collect.ImmutableList)5 BigDecimal (java.math.BigDecimal)5 List (java.util.List)5 SerializationException (org.apache.kafka.common.errors.SerializationException)3 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)2 SerdeFeature (io.confluent.ksql.serde.SerdeFeature)1 SerdeFeatures (io.confluent.ksql.serde.SerdeFeatures)1