use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListTopicsExecutorTest method shouldListKafkaTopicsIncludingInternalTopics.
@Test
public void shouldListKafkaTopicsIncludingInternalTopics() {
// Given:
engine.givenKafkaTopic("topic1");
engine.givenKafkaTopic("topic2");
engine.givenKafkaTopic("_confluent_any_topic");
// When:
final KafkaTopicsList topicsList = (KafkaTopicsList) CUSTOM_EXECUTORS.listTopics().execute((ConfiguredStatement<ListTopics>) engine.configure("LIST ALL TOPICS;"), mock(SessionProperties.class), engine.getEngine(), serviceContext).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(topicsList.getTopics(), containsInAnyOrder(new KafkaTopicInfo("topic1", ImmutableList.of(1)), new KafkaTopicInfo("topic2", ImmutableList.of(1)), new KafkaTopicInfo("_confluent_any_topic", ImmutableList.of(1))));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class TerminateQueryExecutorTest method shouldFailToTerminateTransientQuery.
@Test
public void shouldFailToTerminateTransientQuery() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CUSTOM_EXECUTORS.terminateQuery().execute((ConfiguredStatement<TerminateQuery>) engine.configure("TERMINATE TRANSIENT_QUERY;"), mock(SessionProperties.class), engine.getEngine(), this.engine.getServiceContext()));
// Then:
assertThat(e.getMessage(), containsString("Failed to terminate query with query ID: 'TRANSIENT_QUERY'"));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class RemoteHostExecutorTest method setup.
@SuppressWarnings("unchecked")
@Before
public void setup() throws MalformedURLException {
when(sessionProperties.getInternalRequest()).thenReturn(false);
when(sessionProperties.getLocalUrl()).thenReturn(new URL("https://address"));
augmenter = RemoteHostExecutor.create((ConfiguredStatement<DescribeStreams>) engine.configure("describe streams;"), sessionProperties, executionContext, ksqlClient);
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class FeatureFlagCheckerTest method shouldNotThrowOnCreateStreamWithHeadersIfFeatureFlagIsEnabled.
@Test
public void shouldNotThrowOnCreateStreamWithHeadersIfFeatureFlagIsEnabled() {
// Given
final KsqlConfig config = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_HEADERS_COLUMNS_ENABLED, true));
final CreateStream createStream = new CreateStream(SourceName.of("stream1"), TableElements.of(new TableElement(ColumnName.of("col1"), new Type(SqlTypes.INTEGER), new ColumnConstraints.Builder().headers().build())), false, false, CreateSourceProperties.from(ImmutableMap.of(CommonCreateConfigs.KAFKA_TOPIC_NAME_PROPERTY, new StringLiteral("topic1"))), false);
final ConfiguredStatement configuredStatement = configured(config, createStream);
// When/Then
FeatureFlagChecker.throwOnDisabledFeatures(configuredStatement);
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListSourceExecutor method sourceDescriptionList.
private static Optional<KsqlEntity> sourceDescriptionList(final ConfiguredStatement<? extends StatementWithExtendedClause> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext, final List<? extends DataSource> sources, final boolean extended) {
final RemoteHostExecutor remoteHostExecutor = RemoteHostExecutor.create(statement, sessionProperties, executionContext, serviceContext.getKsqlClient());
final Multimap<String, SourceDescription> remoteSourceDescriptions = extended ? RemoteSourceDescriptionExecutor.fetchSourceDescriptions(remoteHostExecutor) : ImmutableMultimap.of();
final List<SourceDescriptionWithWarnings> descriptions = sources.stream().map(s -> describeSource(statement.getSessionConfig().getConfig(false), executionContext, serviceContext, s.getName(), extended, statement, sessionProperties, remoteSourceDescriptions.get(s.getName().toString()))).collect(Collectors.toList());
return Optional.of(new SourceDescriptionList(statement.getStatementText(), descriptions.stream().map(d -> d.description).collect(Collectors.toList()), descriptions.stream().flatMap(d -> d.warnings.stream()).collect(Collectors.toList())));
}
Aggregations