Search in sources :

Example 21 with TransientQueryMetadata

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

the class EndToEndIntegrationTest method shouldSupportDroppingAndRecreatingJoinQuery.

@Test
public void shouldSupportDroppingAndRecreatingJoinQuery() throws Exception {
    final String createStreamStatement = format("create stream cart_event_product as " + "select pv.userid, pv.pageid, u.gender " + "from %s pv left join %s u on pv.userid=u.userid;", PAGE_VIEW_STREAM, USER_TABLE);
    executeStatement(createStreamStatement);
    ksqlContext.terminateQuery(new QueryId("CSAS_CART_EVENT_PRODUCT_0"));
    executeStatement("DROP STREAM CART_EVENT_PRODUCT;");
    executeStatement(createStreamStatement);
    final TransientQueryMetadata queryMetadata = executeStatement("SELECT * from cart_event_product EMIT CHANGES;");
    final List<Object> columns = waitForFirstRow(queryMetadata);
    if (sharedRuntimes) {
        assertThat(TEST_HARNESS.getKafkaCluster().getTopics(), hasItem("_confluent-ksql-default_query-CSAS_CART_EVENT_PRODUCT_1-Join-repartition"));
    } else {
        assertThat(TEST_HARNESS.getKafkaCluster().getTopics(), hasItem("_confluent-ksql-default_query_CSAS_CART_EVENT_PRODUCT_1-Join-repartition"));
    }
    assertThat(CONSUMED_COUNT.get(), greaterThan(0));
    assertThat(PRODUCED_COUNT.get(), greaterThan(0));
    assertThat(columns.get(0).toString(), startsWith("USER_"));
    assertThat(columns.get(1).toString(), startsWith("PAGE_"));
    assertThat(columns.get(2).toString(), either(is("FEMALE")).or(is("MALE")));
}
Also used : QueryId(io.confluent.ksql.query.QueryId) TransientQueryMetadata(io.confluent.ksql.util.TransientQueryMetadata) IntegrationTest(org.apache.kafka.test.IntegrationTest) Test(org.junit.Test)

Example 22 with TransientQueryMetadata

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

the class QueryExecutor method handlePushQuery.

private QueryMetadataHolder handlePushQuery(final ServiceContext serviceContext, final PreparedStatement<Query> statement, final Map<String, Object> streamsProperties, final boolean excludeTombstones) {
    final ConfiguredStatement<Query> configured = ConfiguredStatement.of(statement, SessionConfig.of(ksqlConfig, streamsProperties));
    if (QueryCapacityUtil.exceedsPushQueryCapacity(ksqlEngine, ksqlRestConfig)) {
        QueryCapacityUtil.throwTooManyActivePushQueriesException(ksqlEngine, ksqlRestConfig, statement.getStatementText());
    }
    final TransientQueryMetadata query = ksqlEngine.executeTransientQuery(serviceContext, configured, excludeTombstones);
    localCommands.ifPresent(lc -> lc.write(query));
    log.info("Streaming query '{}'", statement.getStatementText());
    return QueryMetadataHolder.of(query);
}
Also used : Query(io.confluent.ksql.parser.tree.Query) 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