Search in sources :

Example 51 with SingleStatementContext

use of io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext in project ksql by confluentinc.

the class AstBuilderTest method shouldBuildNestedLambdaFunction.

@Test
public void shouldBuildNestedLambdaFunction() {
    // Given:
    final SingleStatementContext stmt = givenQuery("SELECT TRANSFORM_ARRAY(Col4, (X,Y) => TRANSFORM_ARRAY(Col4, 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", "Y"), new FunctionCall(FunctionName.of("TRANSFORM_ARRAY"), ImmutableList.of(column("COL4"), new LambdaFunctionCall(ImmutableList.of("X"), new IntegerLiteral(5))))))), Optional.empty())))));
}
Also used : Query(io.confluent.ksql.parser.tree.Query) SingleStatementContext(io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext) LambdaFunctionCall(io.confluent.ksql.execution.expression.tree.LambdaFunctionCall) Select(io.confluent.ksql.parser.tree.Select) SingleColumn(io.confluent.ksql.parser.tree.SingleColumn) LambdaFunctionCall(io.confluent.ksql.execution.expression.tree.LambdaFunctionCall) FunctionCall(io.confluent.ksql.execution.expression.tree.FunctionCall) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Test(org.junit.Test)

Aggregations

SingleStatementContext (io.confluent.ksql.parser.SqlBaseParser.SingleStatementContext)51 Test (org.junit.Test)50 Query (io.confluent.ksql.parser.tree.Query)37 Select (io.confluent.ksql.parser.tree.Select)17 QueryContainer (io.confluent.ksql.parser.tree.QueryContainer)9 SingleColumn (io.confluent.ksql.parser.tree.SingleColumn)9 AliasedRelation (io.confluent.ksql.parser.tree.AliasedRelation)8 AllColumns (io.confluent.ksql.parser.tree.AllColumns)8 KsqlException (io.confluent.ksql.util.KsqlException)7 ParseFailedException (io.confluent.ksql.parser.exception.ParseFailedException)5 FunctionCall (io.confluent.ksql.execution.expression.tree.FunctionCall)4 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)4 LambdaFunctionCall (io.confluent.ksql.execution.expression.tree.LambdaFunctionCall)4 CreateStream (io.confluent.ksql.parser.tree.CreateStream)4 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)2 LambdaVariable (io.confluent.ksql.execution.expression.tree.LambdaVariable)2 ColumnConstraints (io.confluent.ksql.parser.tree.ColumnConstraints)2 CreateTable (io.confluent.ksql.parser.tree.CreateTable)2 TableElement (io.confluent.ksql.parser.tree.TableElement)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2