use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldDefaultToEmitChangesForInsertInto.
@Test
public void shouldDefaultToEmitChangesForInsertInto() {
// Given:
final SingleStatementContext stmt = givenQuery("INSERT INTO TEST1 SELECT * FROM TEST2;");
// 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 shouldBuildLambdaFunction.
@Test
public void shouldBuildLambdaFunction() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TRANSFORM_ARRAY(Col4, X => X + 5) 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("TRANSFORM_ARRAY"), ImmutableList.of(column("COL4"), new LambdaFunctionCall(ImmutableList.of("X"), new ArithmeticBinaryExpression(Operator.ADD, new LambdaVariable("X"), new IntegerLiteral(5))))), Optional.empty())))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldSupportExplicitEmitFinalForCtas.
@Test
public void shouldSupportExplicitEmitFinalForCtas() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE TABLE X AS SELECT COUNT(1) FROM TEST1 GROUP BY ROWKEY EMIT FINAL;");
// 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.FINAL));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldSupportExplicitEmitFinalOnBareQuery.
@Test
public void shouldSupportExplicitEmitFinalOnBareQuery() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * FROM TEST1 EMIT FINAL;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat("Should be push", result.isPullQuery(), is(false));
assertThat(result.getRefinement().get().getOutputRefinement(), is(OutputRefinement.FINAL));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldSupportSingleHeaderColumn.
@Test
public void shouldSupportSingleHeaderColumn() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM INPUT (K BYTES HEADER('h1')) 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()).header("h1").build()));
}
Aggregations