Search in sources :

Example 1 with TypeList

use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.

the class ClientTest method shouldFailToListTypesViaExecuteStatement.

@Test
public void shouldFailToListTypesViaExecuteStatement() {
    // Given
    final TypeList entity = new TypeList("list types;", Collections.emptyMap());
    testEndpoints.setKsqlEndpointResponse(Collections.singletonList(entity));
    // When
    final Exception e = assertThrows(// thrown from .get() when the future completes exceptionally
    ExecutionException.class, () -> javaClient.executeStatement("list types;").get());
    // Then
    assertThat(e.getCause(), instanceOf(KsqlClientException.class));
    assertThat(e.getCause().getMessage(), containsString(EXECUTE_STATEMENT_USAGE_DOC));
    assertThat(e.getCause().getMessage(), containsString("does not currently support listing custom types"));
}
Also used : KsqlClientException(io.confluent.ksql.api.client.exception.KsqlClientException) TypeList(io.confluent.ksql.rest.entity.TypeList) KafkaResponseGetFailedException(io.confluent.ksql.exception.KafkaResponseGetFailedException) KsqlClientException(io.confluent.ksql.api.client.exception.KsqlClientException) KsqlApiException(io.confluent.ksql.api.server.KsqlApiException) ExecutionException(java.util.concurrent.ExecutionException) ParseFailedException(io.confluent.ksql.parser.exception.ParseFailedException) KsqlException(io.confluent.ksql.api.client.exception.KsqlException) BaseApiTest(io.confluent.ksql.api.BaseApiTest) Test(org.junit.Test)

Example 2 with TypeList

use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.

the class MigrationsTest method assertTypeCount.

private static void assertTypeCount(final int count) {
    final List<KsqlEntity> entities = assertThatEventually(() -> makeKsqlRequest("LIST TYPES;"), hasSize(1));
    assertThat(entities.get(0), instanceOf(TypeList.class));
    TypeList entity = (TypeList) entities.get(0);
    assertThat(entity.getTypes().size(), is(count));
}
Also used : KsqlEntity(io.confluent.ksql.rest.entity.KsqlEntity) TypeList(io.confluent.ksql.rest.entity.TypeList)

Example 3 with TypeList

use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.

the class ListTypesExecutor method execute.

public static StatementExecutorResponse execute(final ConfiguredStatement<ListTypes> configuredStatement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
    final ImmutableMap.Builder<String, SchemaInfo> types = ImmutableMap.builder();
    final Iterator<CustomType> customTypes = executionContext.getMetaStore().types();
    while (customTypes.hasNext()) {
        final CustomType customType = customTypes.next();
        types.put(customType.getName(), EntityUtil.schemaInfo(customType.getType()));
    }
    return StatementExecutorResponse.handled(Optional.of(new TypeList(configuredStatement.getStatementText(), types.build())));
}
Also used : CustomType(io.confluent.ksql.metastore.TypeRegistry.CustomType) ImmutableMap(com.google.common.collect.ImmutableMap) TypeList(io.confluent.ksql.rest.entity.TypeList) SchemaInfo(io.confluent.ksql.rest.entity.SchemaInfo)

Example 4 with TypeList

use of io.confluent.ksql.rest.entity.TypeList in project ksql by confluentinc.

the class ConsoleTest method shouldPrintTypesList.

@Test
public void shouldPrintTypesList() {
    // Given:
    final KsqlEntityList entities = new KsqlEntityList(ImmutableList.of(new TypeList("statement", ImmutableMap.of("typeB", new SchemaInfo(SqlBaseType.ARRAY, null, new SchemaInfo(SqlBaseType.STRING, null, null)), "typeA", new SchemaInfo(SqlBaseType.STRUCT, ImmutableList.of(new FieldInfo("f1", new SchemaInfo(SqlBaseType.STRING, null, null), Optional.empty())), null), "typeC", new SchemaInfo(SqlBaseType.DECIMAL, null, null, ImmutableMap.of("precision", 10, "scale", 9))))));
    // When:
    console.printKsqlEntityList(entities);
    // Then:
    final String output = terminal.getOutputString();
    Approvals.verify(output, approvalOptions);
}
Also used : KsqlEntityList(io.confluent.ksql.rest.entity.KsqlEntityList) Matchers.containsString(org.hamcrest.Matchers.containsString) TypeList(io.confluent.ksql.rest.entity.TypeList) FieldInfo(io.confluent.ksql.rest.entity.FieldInfo) SchemaInfo(io.confluent.ksql.rest.entity.SchemaInfo) Test(org.junit.Test)

Aggregations

TypeList (io.confluent.ksql.rest.entity.TypeList)4 SchemaInfo (io.confluent.ksql.rest.entity.SchemaInfo)2 Test (org.junit.Test)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 BaseApiTest (io.confluent.ksql.api.BaseApiTest)1 KsqlClientException (io.confluent.ksql.api.client.exception.KsqlClientException)1 KsqlException (io.confluent.ksql.api.client.exception.KsqlException)1 KsqlApiException (io.confluent.ksql.api.server.KsqlApiException)1 KafkaResponseGetFailedException (io.confluent.ksql.exception.KafkaResponseGetFailedException)1 CustomType (io.confluent.ksql.metastore.TypeRegistry.CustomType)1 ParseFailedException (io.confluent.ksql.parser.exception.ParseFailedException)1 FieldInfo (io.confluent.ksql.rest.entity.FieldInfo)1 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)1 KsqlEntityList (io.confluent.ksql.rest.entity.KsqlEntityList)1 ExecutionException (java.util.concurrent.ExecutionException)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1