use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.
the class QueryRegistryImplTest method shouldGetQuery.
@Test
public void shouldGetQuery() {
// Given:
final TransientQueryMetadata q1 = givenCreateTransient(registry, "transient1");
final PersistentQueryMetadata q2 = givenCreate(registry, "q1", "source", Optional.of("sink1"), CREATE_AS);
final PersistentQueryMetadata q3 = givenCreate(registry, "q2", "source", Optional.empty(), CREATE_SOURCE);
// When:
final QueryMetadata queryMetadata1 = registry.getQuery(q1.getQueryId()).get();
final QueryMetadata queryMetadata2 = registry.getQuery(q2.getQueryId()).get();
final QueryMetadata queryMetadata3 = registry.getQuery(q3.getQueryId()).get();
// Then:
assertThat(queryMetadata1, is(q1));
assertThat(queryMetadata2, is(q2));
assertThat(queryMetadata3, is(q3));
}
use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.
the class EndToEndIntegrationTest method shouldSupportConfigurableUdfs.
@Test
public void shouldSupportConfigurableUdfs() throws Exception {
// When:
final TransientQueryMetadata queryMetadata = executeStatement("SELECT E2EConfigurableUdf(registertime) AS x from %s EMIT CHANGES;", USER_TABLE);
// Then:
final List<GenericRow> rows = verifyAvailableRows(queryMetadata, 5);
assertThat(ConfigurableUdf.PASSED_CONFIG, is(ImmutableMap.of(KSQL_FUNCTIONS_PROPERTY_PREFIX + "e2econfigurableudf.some.setting", "foo-bar", KSQL_FUNCTIONS_PROPERTY_PREFIX + "_global_.expected-param", "expected-value")));
rows.forEach(row -> assertThat(row.get(0), is(-1L)));
}
use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.
the class EndToEndIntegrationTest method verifyAvailableRows.
private static List<GenericRow> verifyAvailableRows(final TransientQueryMetadata queryMetadata, final int expectedRows) {
final BlockingRowQueue rowQueue = queryMetadata.getRowQueue();
assertThatEventually(expectedRows + " rows were not available after 30 seconds", () -> rowQueue.size() >= expectedRows, is(true), 30, TimeUnit.SECONDS);
final List<KeyValueMetadata<List<?>, GenericRow>> rows = new ArrayList<>();
rowQueue.drainTo(rows);
return rows.stream().map(kvm -> kvm.getKeyValue().value()).collect(Collectors.toList());
}
use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.
the class QueryRegistryImpl method createTransientQuery.
// CHECKSTYLE_RULES.OFF: ParameterNumberCheck
@Override
public TransientQueryMetadata createTransientQuery(final SessionConfig config, final ServiceContext serviceContext, final ProcessingLogContext processingLogContext, final MetaStore metaStore, final String statementText, final QueryId queryId, final Set<SourceName> sources, final ExecutionStep<?> physicalPlan, final String planSummary, final LogicalSchema schema, final OptionalInt limit, final Optional<WindowInfo> windowInfo, final boolean excludeTombstones) {
// CHECKSTYLE_RULES.ON: ParameterNumberCheck
final QueryBuilder queryBuilder = queryBuilderFactory.create(config, processingLogContext, serviceContext, metaStore, streams, !sandbox);
final TransientQueryMetadata query = queryBuilder.buildTransientQuery(statementText, queryId, sources, physicalPlan, planSummary, schema, limit, windowInfo, excludeTombstones, new ListenerImpl(), new StreamsBuilder(), Optional.empty(), metricCollectors);
query.initialize();
registerTransientQuery(serviceContext, metaStore, query);
return query;
}
use of io.confluent.ksql.util.TransientQueryMetadata in project ksql by confluentinc.
the class QueryDescriptionFactoryTest method shouldHandleRowKeyInValueSchemaForTransientQuery.
@Test
public void shouldHandleRowKeyInValueSchemaForTransientQuery() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("field1"), SqlTypes.INTEGER).valueColumn(ColumnName.of("ROWKEY"), SqlTypes.STRING).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("ROWKEY", new SchemaInfo(SqlBaseType.STRING, null, null), Optional.empty()), new FieldInfo("field2", new SchemaInfo(SqlBaseType.STRING, null, null), Optional.empty())));
}
Aggregations