Search in sources :

Example 16 with UdfFactory

use of io.confluent.ksql.function.UdfFactory in project ksql by confluentinc.

the class InterpretedExpressionTest method shouldHandleFunctionCalls_intervalParam.

@Test
public void shouldHandleFunctionCalls_intervalParam() {
    // Given:
    final UdfFactory udfFactory = mock(UdfFactory.class);
    final KsqlScalarFunction udf = mock(KsqlScalarFunction.class);
    when(udf.newInstance(any())).thenReturn(new toMillisUdf());
    givenUdf("FOO", udfFactory, udf);
    when(udf.parameters()).thenReturn(ImmutableList.of(IntervalUnitType.INSTANCE, IntegerType.INSTANCE));
    // When:
    InterpretedExpression interpreter1 = interpreter(new FunctionCall(FunctionName.of("FOO"), ImmutableList.of(new IntervalUnit(TimeUnit.SECONDS), new IntegerLiteral(1))));
    final Object object = interpreter1.evaluate(ROW);
    // Then:
    assertThat(object, is(1000));
}
Also used : IntervalUnit(io.confluent.ksql.execution.expression.tree.IntervalUnit) KsqlScalarFunction(io.confluent.ksql.function.KsqlScalarFunction) UdfFactory(io.confluent.ksql.function.UdfFactory) 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

UdfFactory (io.confluent.ksql.function.UdfFactory)16 KsqlScalarFunction (io.confluent.ksql.function.KsqlScalarFunction)14 FunctionCall (io.confluent.ksql.execution.expression.tree.FunctionCall)13 LambdaFunctionCall (io.confluent.ksql.execution.expression.tree.LambdaFunctionCall)13 Test (org.junit.Test)13 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)10 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)8 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)7 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)7 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)7 Expression (io.confluent.ksql.execution.expression.tree.Expression)7 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)7 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)7 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)7 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)7 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)6 LambdaVariable (io.confluent.ksql.execution.expression.tree.LambdaVariable)5 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)3