use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldThrowOnUnknownStarAliasOnJoin.
@Test
public void shouldThrowOnUnknownStarAliasOnJoin() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT unknown.* FROM TEST1 JOIN TEST2 WITHIN 1 SECOND ON TEST1.ID = TEST2.ID;");
// When:
final Exception e = assertThrows(KsqlException.class, () -> builder.buildStatement(stmt));
// Then:
assertThat(e.getMessage(), containsString("'UNKNOWN' is not a valid stream/table name or alias."));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldFailOnPersistentQueryLimitClauseTable.
@Test
public void shouldFailOnPersistentQueryLimitClauseTable() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE TABLE X AS SELECT * FROM TEST1 LIMIT 5;");
// Then:
Exception exception = assertThrows(KsqlException.class, () -> {
builder.buildStatement(stmt);
});
String expectedMessage = "CREATE TABLE AS SELECT statements don't support LIMIT clause.";
String actualMessage = exception.getMessage();
assertEquals(expectedMessage, actualMessage);
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldSupportExplicitEmitChangesOnBareQuery.
@Test
public void shouldSupportExplicitEmitChangesOnBareQuery() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * FROM TEST1 EMIT CHANGES;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat("Should be push", result.isPullQuery(), is(false));
assertThat(result.getRefinement().get().getOutputRefinement(), is(OutputRefinement.CHANGES));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleQualifiedSelectStar.
@Test
public void shouldHandleQualifiedSelectStar() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TEST1.* FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new AllColumns(Optional.of(TEST1_NAME))))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldDefaultToEmitChangesForCtas.
@Test
public void shouldDefaultToEmitChangesForCtas() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE TABLE X AS SELECT COUNT(1) FROM TEST1 GROUP BY ROWKEY;");
// When:
final Query result = ((QueryContainer) builder.buildStatement(stmt)).getQuery();
// Then:
assertThat("Should be push", result.isPullQuery(), is(false));
assertThat(result.getRefinement().get().getOutputRefinement(), is(OutputRefinement.CHANGES));
}
Aggregations