use of io.confluent.ksql.execution.expression.tree.FunctionCall in project ksql by confluentinc.
the class GenericExpressionResolverTest method shouldResolveArbitraryExpressions.
@Test
public void shouldResolveArbitraryExpressions() {
// Given:
final SqlType type = SqlTypes.struct().field("FOO", SqlTypes.STRING).build();
final Expression exp = new CreateStructExpression(ImmutableList.of(new Field("FOO", new FunctionCall(FunctionName.of("CONCAT"), ImmutableList.of(new StringLiteral("bar"), new StringLiteral("baz"))))));
// When:
final Object o = new GenericExpressionResolver(type, FIELD_NAME, registry, config, "insert value", false).resolve(exp);
// Then:
assertThat(o, is(new Struct(SchemaBuilder.struct().field("FOO", Schema.OPTIONAL_STRING_SCHEMA).optional().build()).put("FOO", "barbaz")));
}
use of io.confluent.ksql.execution.expression.tree.FunctionCall in project ksql by confluentinc.
the class AstSanitizerTest method shouldAllowNestedLambdaFunctionsWithoutDuplicate.
@Test
public void shouldAllowNestedLambdaFunctionsWithoutDuplicate() {
// Given:
final Statement stmt = givenQuery("SELECT TRANSFORM_ARRAY(Col4, (X,Y,Z) => TRANSFORM_MAP(Col4, Q => 4, H => 5), (X,Y,Z) => 0) FROM TEST1;");
// When:
final Query result = (Query) AstSanitizer.sanitize(stmt, META_STORE, true);
// Then:
assertThat(result.getSelect(), is(new Select(ImmutableList.of(new SingleColumn(new FunctionCall(FunctionName.of("TRANSFORM_ARRAY"), ImmutableList.of(column(TEST1_NAME, "COL4"), new LambdaFunctionCall(ImmutableList.of("X", "Y", "Z"), new FunctionCall(FunctionName.of("TRANSFORM_MAP"), ImmutableList.of(column(TEST1_NAME, "COL4"), new LambdaFunctionCall(ImmutableList.of("Q"), new IntegerLiteral(4)), new LambdaFunctionCall(ImmutableList.of("H"), new IntegerLiteral(5))))), new LambdaFunctionCall(ImmutableList.of("X", "Y", "Z"), new IntegerLiteral(0)))), Optional.of(ColumnName.of("KSQL_COL_0")))))));
}
Aggregations