Search in sources :

Example 1 with SimpleColumn

use of io.confluent.ksql.schema.ksql.SimpleColumn in project ksql by confluentinc.

the class KsqlDelimitedDeserializer method buildParsers.

private static List<Parser> buildParsers(final PersistenceSchema schema) {
    final List<Parser> parsers = new ArrayList<>(schema.columns().size());
    for (final SimpleColumn column : schema.columns()) {
        final SqlBaseType baseType = column.type().baseType();
        final ParserFactory parserFactory = PARSERS.get(baseType);
        if (parserFactory == null) {
            throw new KsqlException("The '" + FormatFactory.DELIMITED.name() + "' format does not support type '" + baseType + "', column: " + column.name());
        }
        parsers.add(parserFactory.build(column.type()));
    }
    return parsers;
}
Also used : SqlBaseType(io.confluent.ksql.schema.ksql.types.SqlBaseType) ArrayList(java.util.ArrayList) SimpleColumn(io.confluent.ksql.schema.ksql.SimpleColumn) KsqlException(io.confluent.ksql.util.KsqlException) CSVParser(org.apache.commons.csv.CSVParser)

Example 2 with SimpleColumn

use of io.confluent.ksql.schema.ksql.SimpleColumn in project ksql by confluentinc.

the class ConnectFormatSchemaTranslatorTest method createColumn.

private static SimpleColumn createColumn(final String name, final SqlType sqlType) {
    final SimpleColumn column = mock(SimpleColumn.class);
    when(column.name()).thenReturn(ColumnName.of(name));
    when(column.type()).thenReturn(sqlType);
    return column;
}
Also used : SimpleColumn(io.confluent.ksql.schema.ksql.SimpleColumn)

Example 3 with SimpleColumn

use of io.confluent.ksql.schema.ksql.SimpleColumn in project ksql by confluentinc.

the class ConnectFormatTest method shouldCallSubclassToCreateOuterWhenWrapped.

@Test
public void shouldCallSubclassToCreateOuterWhenWrapped() {
    // Given:
    final SimpleColumn singleColumn = createColumn("bob", SqlTypes.INTEGER);
    when(persistenceSchema.columns()).thenReturn(ImmutableList.of(singleColumn));
    // When:
    format.getSerde(persistenceSchema, formatProps, config, srFactory, false);
    // Then:
    verify(format).getConnectSerde(SINGLE_FIELD_SCHEMA, formatProps, config, srFactory, Struct.class, false);
}
Also used : SimpleColumn(io.confluent.ksql.schema.ksql.SimpleColumn) Test(org.junit.Test)

Example 4 with SimpleColumn

use of io.confluent.ksql.schema.ksql.SimpleColumn in project ksql by confluentinc.

the class GenericKeySerDeTest method column.

private static SimpleColumn column(final SqlType type) {
    final SimpleColumn column = mock(SimpleColumn.class, type.toString());
    when(column.name()).thenReturn(COLUMN_NAME);
    when(column.type()).thenReturn(type);
    return column;
}
Also used : SimpleColumn(io.confluent.ksql.schema.ksql.SimpleColumn)

Example 5 with SimpleColumn

use of io.confluent.ksql.schema.ksql.SimpleColumn in project ksql by confluentinc.

the class AvroFormatTest method column.

private static SimpleColumn column(final String name) {
    final SimpleColumn column = mock(SimpleColumn.class);
    when(column.name()).thenReturn(ColumnName.of(name));
    when(column.type()).thenReturn(SqlTypes.BIGINT);
    return column;
}
Also used : SimpleColumn(io.confluent.ksql.schema.ksql.SimpleColumn)

Aggregations

SimpleColumn (io.confluent.ksql.schema.ksql.SimpleColumn)13 Test (org.junit.Test)4 KsqlException (io.confluent.ksql.util.KsqlException)3 ConnectSchema (org.apache.kafka.connect.data.ConnectSchema)3 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)1 CreateTable (io.confluent.ksql.parser.tree.CreateTable)1 SqlToConnectTypeConverter (io.confluent.ksql.schema.ksql.SchemaConverters.SqlToConnectTypeConverter)1 SqlBaseType (io.confluent.ksql.schema.ksql.types.SqlBaseType)1 Format (io.confluent.ksql.serde.Format)1 SchemaTranslator (io.confluent.ksql.serde.SchemaTranslator)1 UnwrappedDeserializer (io.confluent.ksql.serde.unwrapped.UnwrappedDeserializer)1 UnwrappedSerializer (io.confluent.ksql.serde.unwrapped.UnwrappedSerializer)1 KsqlVoidSerde (io.confluent.ksql.serde.voids.KsqlVoidSerde)1 ArrayList (java.util.ArrayList)1 CSVParser (org.apache.commons.csv.CSVParser)1 SerializationException (org.apache.kafka.common.errors.SerializationException)1 Schema (org.apache.kafka.connect.data.Schema)1 SchemaBuilder (org.apache.kafka.connect.data.SchemaBuilder)1