use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldSupportExplicitEmitChangesForCsas.
@Test
public void shouldSupportExplicitEmitChangesForCsas() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM X AS SELECT * FROM TEST1 EMIT CHANGES;");
// 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 shouldCreateSourceTable.
@Test
public void shouldCreateSourceTable() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE SOURCE TABLE X WITH (kafka_topic='X');");
// When:
final CreateTable result = (CreateTable) builder.buildStatement(stmt);
// Then:
assertThat(result.isSource(), is(true));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldCreateNormalTable.
@Test
public void shouldCreateNormalTable() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE TABLE X WITH (kafka_topic='X');");
// When:
final CreateTable result = (CreateTable) builder.buildStatement(stmt);
// Then:
assertThat(result.isSource(), is(false));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleMultipleAliasedJoinDataSources.
@Test
public void shouldHandleMultipleAliasedJoinDataSources() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * FROM TEST1 t1 " + "JOIN TEST2 t2 ON t1.col1 = t2.col1 " + "JOIN TEST3 t3 ON t1.col1 = t3.col1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getFrom(), is(instanceOf(Join.class)));
assertThat((Join) result.getFrom(), hasLeft(new AliasedRelation(TEST1, SourceName.of("T1"))));
assertThat((Join) result.getFrom(), hasRights(new AliasedRelation(TEST2, SourceName.of("T2")), new AliasedRelation(TEST3, SourceName.of("T3"))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleQualifiedSelect.
@Test
public void shouldHandleQualifiedSelect() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TEST1.COL0 FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new SingleColumn(column(TEST1_NAME, "COL0"), Optional.empty())))));
}
Aggregations