use of io.confluent.ksql.util.KsqlStatementException in project ksql by confluentinc.
the class KsqlEngineTest method shouldThrowFromExecuteIfSourceTopicDoesNotExist.
@Test
public void shouldThrowFromExecuteIfSourceTopicDoesNotExist() {
// Given:
final PreparedStatement<?> statement = prepare(parse("CREATE STREAM S1 (COL1 BIGINT) " + "WITH (KAFKA_TOPIC = 'i_do_not_exist', VALUE_FORMAT = 'JSON', KEY_FORMAT = 'KAFKA');").get(0));
// When:
final KsqlStatementException e = assertThrows(KsqlStatementException.class, () -> ksqlEngine.execute(serviceContext, ConfiguredStatement.of(statement, SessionConfig.of(ksqlConfig, ImmutableMap.of()))));
// Then:
assertThat(e, rawMessage(is("Kafka topic does not exist: i_do_not_exist")));
}
use of io.confluent.ksql.util.KsqlStatementException in project ksql by confluentinc.
the class KsqlEngineTest method shouldThrowFromSandBoxOnPrepareIfSourceTopicDoesNotExist.
@Test
public void shouldThrowFromSandBoxOnPrepareIfSourceTopicDoesNotExist() {
// Given:
final PreparedStatement<?> statement = prepare(parse("CREATE STREAM S1 (COL1 BIGINT) " + "WITH (KAFKA_TOPIC = 'i_do_not_exist', VALUE_FORMAT = 'JSON', KEY_FORMAT = 'KAFKA');").get(0));
// When:
final KsqlStatementException e = assertThrows(KsqlStatementException.class, () -> sandbox.execute(sandboxServiceContext, ConfiguredStatement.of(statement, SessionConfig.of(ksqlConfig, ImmutableMap.of()))));
// Then:
assertThat(e, rawMessage(is("Kafka topic does not exist: i_do_not_exist")));
assertThat(e, statementText(is("CREATE STREAM S1 (COL1 BIGINT)" + " WITH (KAFKA_TOPIC = 'i_do_not_exist', VALUE_FORMAT = 'JSON', KEY_FORMAT = 'KAFKA');")));
}
use of io.confluent.ksql.util.KsqlStatementException in project ksql by confluentinc.
the class KsqlEngineTest method shouldThrowWhenExecutingDuplicateStream.
@Test
public void shouldThrowWhenExecutingDuplicateStream() {
// Given:
final List<ParsedStatement> parsed = ksqlEngine.parse("CREATE STREAM FOO WITH (KAFKA_TOPIC='BAR') AS SELECT * FROM ORDERS; " + "CREATE STREAM FOO WITH (KAFKA_TOPIC='BAR') AS SELECT * FROM ORDERS;");
givenStatementAlreadyExecuted(parsed.get(0));
final PreparedStatement<?> prepared = ksqlEngine.prepare(parsed.get(1));
// When:
final KsqlStatementException e = assertThrows(KsqlStatementException.class, () -> ksqlEngine.execute(serviceContext, ConfiguredStatement.of(prepared, SessionConfig.of(ksqlConfig, new HashMap<>()))));
// Then:
assertThat(e, rawMessage(is("Cannot add stream 'FOO': A stream with the same name already exists")));
assertThat(e, statementText(is("CREATE STREAM FOO WITH (KAFKA_TOPIC='BAR') AS SELECT * FROM ORDERS;")));
}
use of io.confluent.ksql.util.KsqlStatementException in project ksql by confluentinc.
the class KsqlEngineTest method shouldThrowOnTerminateAsNotExecutable.
@Test
public void shouldThrowOnTerminateAsNotExecutable() {
// Given:
final PersistentQueryMetadata query = (PersistentQueryMetadata) KsqlEngineTestUtil.execute(serviceContext, ksqlEngine, "create table bar as select * from test2;", ksqlConfig, Collections.emptyMap()).get(0);
// When:
final KsqlStatementException e = assertThrows(KsqlStatementException.class, () -> KsqlEngineTestUtil.execute(serviceContext, ksqlEngine, "TERMINATE " + query.getQueryId() + ";", ksqlConfig, Collections.emptyMap()));
// Then:
assertThat(e, rawMessage(containsString("Statement not executable")));
assertThat(e, statementText(is("TERMINATE CTAS_BAR_0;")));
}
use of io.confluent.ksql.util.KsqlStatementException in project ksql by confluentinc.
the class KsqlEngineTest method shouldThrowWhenExecutingInsertIntoTable.
@Test
public void shouldThrowWhenExecutingInsertIntoTable() {
KsqlEngineTestUtil.execute(serviceContext, ksqlEngine, "create table bar as select * from test2;", ksqlConfig, Collections.emptyMap());
final ParsedStatement parsed = ksqlEngine.parse("insert into bar select * from test2;").get(0);
// When:
final KsqlStatementException e = assertThrows(KsqlStatementException.class, () -> prepare(parsed));
// Then:
assertThat(e, rawMessage(containsString("INSERT INTO can only be used to insert into a stream. BAR is a table.")));
assertThat(e, statementText(is("insert into bar select * from test2;")));
}
Aggregations