use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldBuildLambdaFunctionWithMultipleLambdas.
@Test
public void shouldBuildLambdaFunctionWithMultipleLambdas() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT TRANSFORM_ARRAY(Col4, X => X + 5, (X,Y) => X + Y) 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))), new LambdaFunctionCall(ImmutableList.of("X", "Y"), new ArithmeticBinaryExpression(Operator.ADD, new LambdaVariable("X"), new LambdaVariable("Y"))))), Optional.empty())))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldSupportExplicitEmitFinalForInsertInto.
@Test
public void shouldSupportExplicitEmitFinalForInsertInto() {
// Given:
final SingleStatementContext stmt = givenQuery("INSERT INTO TEST1 SELECT * FROM TEST2 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 shouldThrowOnUnknownSelectQualifier.
@Test
public void shouldThrowOnUnknownSelectQualifier() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT unknown.COL0 FROM TEST1;");
// When:
final Exception e = assertThrows(KsqlException.class, () -> builder.buildStatement(stmt));
// Then:
assertThat(e.getMessage(), containsString("'UNKNOWN' is not a valid stream/table name or alias."));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldHandleAliasedDataSources.
@Test
public void shouldHandleAliasedDataSources() {
// Given:
final SingleStatementContext stmt = givenQuery("SELECT * FROM TEST1 t;");
// When:
final Query result = (Query) builder.buildStatement(stmt);
// Then:
assertThat(result.getFrom(), is(new AliasedRelation(TEST1, SourceName.of("T"))));
}
use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.
the class AstBuilderTest method shouldSupportExplicitEmitFinalForCsas.
@Test
public void shouldSupportExplicitEmitFinalForCsas() {
// Given:
final SingleStatementContext stmt = givenQuery("CREATE STREAM X AS SELECT * FROM TEST1 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));
}
Aggregations