use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class DistributingExecutorTest method shouldThrowFailureIfCannotInferSchema.
@Test
public void shouldThrowFailureIfCannotInferSchema() {
// Given:
final PreparedStatement<Statement> preparedStatement = PreparedStatement.of("", new ListProperties(Optional.empty()));
final ConfiguredStatement<Statement> configured = ConfiguredStatement.of(preparedStatement, SessionConfig.of(KSQL_CONFIG, ImmutableMap.of()));
when(schemaInjector.inject(any())).thenThrow(new KsqlException("Could not infer!"));
// When:
final Exception e = assertThrows(KsqlException.class, () -> distributor.execute(configured, executionContext, securityContext));
// Then:
assertThat(e.getMessage(), containsString("Could not infer!"));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ExplainExecutorTest method shouldExplainStatement.
@Test
public void shouldExplainStatement() {
// Given:
engine.givenSource(DataSourceType.KSTREAM, "Y");
final String statementText = "SELECT * FROM Y EMIT CHANGES;";
final ConfiguredStatement<Explain> explain = (ConfiguredStatement<Explain>) engine.configure("EXPLAIN " + statementText);
// When:
final QueryDescriptionEntity query = (QueryDescriptionEntity) customExecutors.explain().execute(explain, sessionProperties, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(query.getQueryDescription().getStatementText(), equalTo(statementText));
assertThat(query.getQueryDescription().getSources(), containsInAnyOrder("Y"));
assertThat(query.getQueryDescription().getKsqlHostQueryStatus(), equalTo(Collections.emptyMap()));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ExplainExecutorTest method shouldExplainQueryId.
@Test
public void shouldExplainQueryId() {
// Given:
final ConfiguredStatement<Explain> explain = (ConfiguredStatement<Explain>) engine.configure("EXPLAIN id;");
final PersistentQueryMetadata metadata = givenPersistentQuery("id");
final KsqlEngine engine = mock(KsqlEngine.class);
when(engine.getPersistentQuery(metadata.getQueryId())).thenReturn(Optional.of(metadata));
// When:
final QueryDescriptionEntity query = (QueryDescriptionEntity) customExecutors.explain().execute(explain, sessionProperties, engine, this.engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(query.getQueryDescription(), equalTo(QueryDescriptionFactory.forQueryMetadata(metadata, Collections.singletonMap(new KsqlHostInfoEntity(LOCAL_HOST), STATE))));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ExplainExecutorTest method shouldExplainStatementWithStructFieldDereference.
@Test
public void shouldExplainStatementWithStructFieldDereference() {
// Given:
engine.givenSource(DataSourceType.KSTREAM, "Y");
final String statementText = "SELECT address->street FROM Y EMIT CHANGES;";
final ConfiguredStatement<Explain> explain = (ConfiguredStatement<Explain>) engine.configure("EXPLAIN " + statementText);
// When:
final QueryDescriptionEntity query = (QueryDescriptionEntity) customExecutors.explain().execute(explain, sessionProperties, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(query.getQueryDescription().getStatementText(), equalTo(statementText));
assertThat(query.getQueryDescription().getSources(), containsInAnyOrder("Y"));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ExplainExecutorTest method shouldExplainPersistentStatement.
@Test
public void shouldExplainPersistentStatement() {
// Given:
engine.givenSource(DataSourceType.KSTREAM, "Y");
final String statementText = "CREATE STREAM X AS SELECT * FROM Y;";
final ConfiguredStatement<Explain> explain = (ConfiguredStatement<Explain>) engine.configure("EXPLAIN " + statementText);
// When:
final QueryDescriptionEntity query = (QueryDescriptionEntity) customExecutors.explain().execute(explain, sessionProperties, engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(query.getQueryDescription().getStatementText(), equalTo(statementText));
assertThat(query.getQueryDescription().getSources(), containsInAnyOrder("Y"));
assertThat("No side effects should happen", engine.getEngine().getPersistentQueries(), is(empty()));
assertThat(query.getQueryDescription().getKsqlHostQueryStatus(), equalTo(Collections.emptyMap()));
}
Aggregations