use of io.confluent.ksql.rest.entity.KsqlRequest in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailForIncorrectDropTableStatement.
@Test
public void shouldFailForIncorrectDropTableStatement() throws Exception {
KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
final String ksqlString = "DROP STREAM test_table;";
Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, Collections.emptyMap()));
KsqlEntityList result = (KsqlEntityList) response.getEntity();
assertThat("Incorrect drop statement.", result.size(), equalTo(1));
assertThat(result.get(0), instanceOf(ErrorMessageEntity.class));
ErrorMessageEntity errorMessageEntity = (ErrorMessageEntity) result.get(0);
assertTrue(errorMessageEntity.getErrorMessage().getMessage().equalsIgnoreCase("Incompatible data source type" + " is TABLE, but statement was DROP STREAM"));
}
use of io.confluent.ksql.rest.entity.KsqlRequest in project ksql by confluentinc.
the class KsqlRestClient method makeKsqlRequest.
public RestResponse<KsqlEntityList> makeKsqlRequest(String ksql) {
KsqlRequest jsonRequest = new KsqlRequest(ksql, localProperties);
Response response = makePostRequest("ksql", jsonRequest);
KsqlEntityList result = response.readEntity(KsqlEntityList.class);
response.close();
return RestResponse.successful(result);
}
use of io.confluent.ksql.rest.entity.KsqlRequest in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailForIncorrectCTASStatementResultType.
@Test
public void shouldFailForIncorrectCTASStatementResultType() throws Exception {
KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
final String ksqlString = "CREATE TABLE s1 AS SELECT * FROM test_stream;";
Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, Collections.emptyMap()));
KsqlEntityList result = (KsqlEntityList) response.getEntity();
assertThat("Incorrect response size.", result.size(), equalTo(1));
assertThat(result.get(0), instanceOf(ErrorMessageEntity.class));
ErrorMessageEntity errorMessageEntity = (ErrorMessageEntity) result.get(0);
assertTrue(errorMessageEntity.getErrorMessage().getMessage().contains("Invalid result type. Your " + "SELECT query produces a STREAM. Please use CREATE STREAM AS SELECT statement instead."));
}
use of io.confluent.ksql.rest.entity.KsqlRequest in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailCreateTableWithInferenceWithIncorrectKey.
@Test
public void shouldFailCreateTableWithInferenceWithIncorrectKey() throws Exception {
KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
final String ksqlString = "CREATE TABLE orders WITH (KAFKA_TOPIC='orders-topic', " + "VALUE_FORMAT = 'avro', KEY = 'orderid1');";
Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, new HashMap<>()));
KsqlEntityList result = (KsqlEntityList) response.getEntity();
assertThat("Incorrect response.", result.size(), equalTo(1));
assertThat(result.get(0), instanceOf(ErrorMessageEntity.class));
}
use of io.confluent.ksql.rest.entity.KsqlRequest in project ksql by confluentinc.
the class KsqlResourceTest method shouldCreateTableWithInference.
@Test
public void shouldCreateTableWithInference() throws Exception {
KsqlResource testResource = TestKsqlResourceUtil.get(ksqlEngine, ksqlRestConfig);
final String ksqlString = "CREATE TABLE orders WITH (KAFKA_TOPIC='orders-topic', " + "VALUE_FORMAT = 'avro', KEY = 'orderid');";
Response response = testResource.handleKsqlStatements(new KsqlRequest(ksqlString, new HashMap<>()));
KsqlEntityList result = (KsqlEntityList) response.getEntity();
assertThat("Incorrect response.", result.size(), equalTo(1));
assertTrue(result.get(0) instanceof CommandStatusEntity);
CommandStatusEntity commandStatusEntity = (CommandStatusEntity) result.get(0);
assertTrue(commandStatusEntity.getCommandId().getType().name().equalsIgnoreCase("TABLE"));
}
Aggregations