use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldBuildIntervalUnit.
@Test
public void shouldBuildIntervalUnit() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TIMESTAMPADD(MINUTES, 5, Col4) FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new SingleColumn(new FunctionCall(FunctionName.of("TIMESTAMPADD"), ImmutableList.of(new IntervalUnit(TimeUnit.MINUTES), new IntegerLiteral(5), column("COL4"))), Optional.empty())))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldCreateNormalStream.
@Test
public void shouldCreateNormalStream() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM X WITH (kafka_topic='X');");
// When:
final CreateStream result = (CreateStream) 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 shouldHandleUnqualifiedSelectStarOnJoin.
@Test
public void shouldHandleUnqualifiedSelectStarOnJoin() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * 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.empty())))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldRejectIncorrectlyTypedHeadersColumns.
@Test
public void shouldRejectIncorrectlyTypedHeadersColumns() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM INPUT (K BIGINT HEADERS) WITH (kafka_topic='input',value_format='JSON');");
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> {
builder.buildStatement(stmt);
});
// Then:
assertThat(e.getMessage(), is("Invalid type for HEADERS column: expected ARRAY<STRUCT<`KEY` STRING, `VALUE` BYTES>>, got BIGINT"));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldDefaultToEmptyRefinementForBareQueries.
@Test
public void shouldDefaultToEmptyRefinementForBareQueries() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * FROM TEST1;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat("Should be pull", result.isPullQuery(), is(true));
assertThat(result.getRefinement(), is(Optional.empty()));
}
Aggregations