Search in sources :

Example 11 with TransientQueryMetadata

use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.

the class QueryDescriptionFactoryTest method shouldHandleRowTimeInValueSchemaForTransientQuery.

@Test
public void shouldHandleRowTimeInValueSchemaForTransientQuery() {
    // Given:
    final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("field1"), SqlTypes.INTEGER).valueColumn(ColumnName.of("ROWTIME"), SqlTypes.BIGINT).valueColumn(ColumnName.of("field2"), SqlTypes.STRING).build();
    transientQuery = new TransientQueryMetadata(SQL_TEXT, schema, SOURCE_NAMES, "execution plan", queryQueue, QUERY_ID, "app id", topology, kafkaStreamsBuilder, STREAMS_PROPS, PROP_OVERRIDES, closeTimeout, 10, ResultType.STREAM, 0L, 0L, listener);
    transientQuery.initialize();
    // When:
    transientQueryDescription = QueryDescriptionFactory.forQueryMetadata(transientQuery, Collections.emptyMap());
    // Then:
    assertThat(transientQueryDescription.getFields(), contains(new FieldInfo("field1", new SchemaInfo(SqlBaseType.INTEGER, null, null), Optional.empty()), new FieldInfo("ROWTIME", new SchemaInfo(SqlBaseType.BIGINT, null, null), Optional.empty()), new FieldInfo("field2", new SchemaInfo(SqlBaseType.STRING, null, null), Optional.empty())));
}
Also used : LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) TransientQueryMetadata(io.confluent.ksql.util.TransientQueryMetadata) Test(org.junit.Test)

Example 12 with TransientQueryMetadata

use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.

the class ListQueriesExecutorTest method givenTransientQuery.

public static TransientQueryMetadata givenTransientQuery(final String id, final KafkaStreams.State state) {
    final TransientQueryMetadata metadata = mock(TransientQueryMetadata.class);
    mockQuery(id, state, metadata);
    when(metadata.getQueryType()).thenReturn(KsqlConstants.KsqlQueryType.PUSH);
    return metadata;
}
Also used : TransientQueryMetadata(io.confluent.ksql.util.TransientQueryMetadata)

Example 13 with TransientQueryMetadata

use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.

the class QueryDescriptionFactoryTest method setUp.

@Before
public void setUp() {
    when(topology.describe()).thenReturn(topologyDescription);
    when(kafkaStreamsBuilder.build(any(), any())).thenReturn(queryStreams);
    when(queryStreams.metadataForLocalThreads()).thenReturn(Collections.emptySet());
    when(sinkTopic.getKeyFormat()).thenReturn(KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()));
    when(sinkDataSource.getKsqlTopic()).thenReturn(sinkTopic);
    when(sinkDataSource.getName()).thenReturn(SourceName.of("sink name"));
    transientQuery = new TransientQueryMetadata(SQL_TEXT, TRANSIENT_SCHEMA, SOURCE_NAMES, "execution plan", queryQueue, QUERY_ID, APPLICATION_ID, topology, kafkaStreamsBuilder, STREAMS_PROPS, PROP_OVERRIDES, closeTimeout, 10, ResultType.STREAM, 0L, 0L, listener);
    transientQuery.initialize();
    transientQueryDescription = QueryDescriptionFactory.forQueryMetadata(transientQuery, Collections.emptyMap());
    persistentQuery = new PersistentQueryMetadataImpl(KsqlConstants.PersistentQueryType.CREATE_AS, SQL_TEXT, PhysicalSchema.from(PERSISTENT_SCHEMA, SerdeFeatures.of(), SerdeFeatures.of()), SOURCE_NAMES, Optional.of(sinkDataSource), "execution plan", QUERY_ID, Optional.empty(), APPLICATION_ID, topology, kafkaStreamsBuilder, new QuerySchemas(), STREAMS_PROPS, PROP_OVERRIDES, closeTimeout, QueryErrorClassifier.DEFAULT_CLASSIFIER, physicalPlan, 10, processingLogger, 0L, 0L, listener, Optional.empty());
    persistentQuery.initialize();
    persistentQueryDescription = QueryDescriptionFactory.forQueryMetadata(persistentQuery, STATUS_MAP);
}
Also used : QuerySchemas(io.confluent.ksql.schema.query.QuerySchemas) PersistentQueryMetadataImpl(io.confluent.ksql.util.PersistentQueryMetadataImpl) TransientQueryMetadata(io.confluent.ksql.util.TransientQueryMetadata) Before(org.junit.Before)

Example 14 with TransientQueryMetadata

use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.

the class KsqlResourceTest method validateTransientQueryDescription.

private void validateTransientQueryDescription(final String ksqlQueryString, final Map<String, Object> overriddenProperties, final KsqlEntity entity) {
    final TransientQueryMetadata queryMetadata = KsqlEngineTestUtil.executeQuery(serviceContext, ksqlEngine, ksqlQueryString, ksqlConfig, overriddenProperties);
    validateQueryDescription(queryMetadata, overriddenProperties, entity);
}
Also used : TransientQueryMetadata(io.confluent.ksql.util.TransientQueryMetadata)

Example 15 with TransientQueryMetadata

use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.

the class TerminateQueryExecutorTest method givenTransientQuery.

public static TransientQueryMetadata givenTransientQuery(final String id, final KafkaStreams.State state) {
    final TransientQueryMetadata metadata = mock(TransientQueryMetadata.class);
    mockQuery(id, state, metadata);
    return metadata;
}
Also used : TransientQueryMetadata(io.confluent.ksql.util.TransientQueryMetadata)

Aggregations

TransientQueryMetadata (io.confluent.ksql.util.TransientQueryMetadata)22 Test (org.junit.Test)10 QueryId (io.confluent.ksql.query.QueryId)5 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)5 QueryMetadata (io.confluent.ksql.util.QueryMetadata)5 GenericRow (io.confluent.ksql.GenericRow)4 KsqlConfig (io.confluent.ksql.util.KsqlConfig)4 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)4 IntegrationTest (org.apache.kafka.test.IntegrationTest)4 Before (org.junit.Before)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 Query (io.confluent.ksql.parser.tree.Query)3 BlockingRowQueue (io.confluent.ksql.query.BlockingRowQueue)3 KeyValue (io.confluent.ksql.util.KeyValue)3 KeyValueMetadata (io.confluent.ksql.util.KeyValueMetadata)3 Collection (java.util.Collection)3 List (java.util.List)3 Map (java.util.Map)3 Objects (java.util.Objects)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2