use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleAliasQualifiedSelectStarOnRightJoinSource.
@Test
public void shouldHandleAliasQualifiedSelectStarOnRightJoinSource() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT T2.* FROM TEST1 JOIN TEST2 T2 WITHIN 1 SECOND ON TEST1.ID = T2.ID;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new AllColumns(Optional.of(SourceName.of("T2")))))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldExtractUnaliasedDataSources.
@Test
public void shouldExtractUnaliasedDataSources() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getFrom(), is(new AliasedRelation(TEST1, TEST1_NAME)));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldDefaultToEmitChangesForCsas.
@Test
public void shouldDefaultToEmitChangesForCsas() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM X AS SELECT * FROM TEST1;");
// 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));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleUnqualifiedSelect.
@Test
public void shouldHandleUnqualifiedSelect() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT COL0 FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new SingleColumn(column("COL0"), Optional.empty())))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldFailOnPersistentQueryLimitClauseStream.
@Test
public void shouldFailOnPersistentQueryLimitClauseStream() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM X AS SELECT * FROM TEST1 LIMIT 5;");
// Then:
Exception exception = assertThrows(KsqlException.class, () -> {
builder.buildStatement(stmt);
});
String expectedMessage = "CREATE STREAM AS SELECT statements don't support LIMIT clause.";
String actualMessage = exception.getMessage();
assertEquals(expectedMessage, actualMessage);
}
Aggregations