use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleAliasQualifiedSelect.
@Test
public void shouldHandleAliasQualifiedSelect() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT T.COL0 FROM TEST2 T;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new SingleColumn(column(SourceName.of("T"), "COL0"), Optional.empty())))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleQualifiedSelectStarOnLeftJoinSource.
@Test
public void shouldHandleQualifiedSelectStarOnLeftJoinSource() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TEST1.* FROM TEST1 JOIN TEST2 WITHIN 1 SECOND ON TEST1.ID = TEST2.ID;");
// 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 shouldSupportHeadersColumns.
@Test
public void shouldSupportHeadersColumns() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM INPUT (K ARRAY<STRUCT<key STRING, value BYTES>> HEADERS) WITH (kafka_topic='input',value_format='JSON');");
// When:
final CreateStream createStream = (CreateStream) builder.buildStatement(stmt);
// Then:
final TableElement column = Iterators.getOnlyElement(createStream.getElements().iterator());
assertThat(column.getConstraints(), is((new ColumnConstraints.Builder()).headers().build()));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldExtractMultipleUnaliasedJoinDataSources.
@Test
public void shouldExtractMultipleUnaliasedJoinDataSources() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * FROM TEST1 " + "JOIN TEST2 ON test1.col1 = test2.col1 " + "JOIN TEST3 ON test1.col1 = test3.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, TEST1_NAME)));
assertThat((Join) result.getFrom(), hasRights(new AliasedRelation(TEST2, TEST2_NAME), new AliasedRelation(TEST3, TEST3_NAME)));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldOmitSelectAliasIfNotPresent.
@Test
public void shouldOmitSelectAliasIfNotPresent() {
// 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())))));
}
Aggregations