Search in sources :

Example 21 with SqlArgument

use of io.confluent.ksql.schema.ksql.SqlArgument in project ksql by confluentinc.

the class GenericsUtilTest method shouldIdentifySqlLambdaResolvedGenerics.

@Test
public void shouldIdentifySqlLambdaResolvedGenerics() {
    // Given:
    final GenericType typeA = GenericType.of("A");
    final GenericType typeB = GenericType.of("B");
    final LambdaType a = LambdaType.of(ImmutableList.of(typeA, typeB), typeB);
    final SqlArgument instance = SqlArgument.of(SqlLambdaResolved.of(ImmutableList.of(SqlTypes.DOUBLE, SqlTypes.BIGINT), SqlTypes.BIGINT));
    // When:
    final Map<GenericType, SqlType> mapping = GenericsUtil.reserveGenerics(a, instance);
    // Then:
    assertThat(mapping, hasEntry(typeA, SqlTypes.DOUBLE));
    assertThat(mapping, hasEntry(typeB, SqlTypes.BIGINT));
}
Also used : LambdaType(io.confluent.ksql.function.types.LambdaType) GenericType(io.confluent.ksql.function.types.GenericType) SqlArgument(io.confluent.ksql.schema.ksql.SqlArgument) SqlType(io.confluent.ksql.schema.ksql.types.SqlType) Test(org.junit.Test)

Aggregations

SqlArgument (io.confluent.ksql.schema.ksql.SqlArgument)21 Test (org.junit.Test)14 GenericType (io.confluent.ksql.function.types.GenericType)12 LambdaType (io.confluent.ksql.function.types.LambdaType)10 SqlType (io.confluent.ksql.schema.ksql.types.SqlType)10 HashMap (java.util.HashMap)7 MapType (io.confluent.ksql.function.types.MapType)4 KsqlException (io.confluent.ksql.util.KsqlException)4 Expression (io.confluent.ksql.execution.expression.tree.Expression)3 ParamType (io.confluent.ksql.function.types.ParamType)3 ArrayList (java.util.ArrayList)3 Optional (java.util.Optional)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 LambdaFunctionCall (io.confluent.ksql.execution.expression.tree.LambdaFunctionCall)2 UdfUtil (io.confluent.ksql.execution.function.UdfUtil)2 ParamTypes (io.confluent.ksql.function.types.ParamTypes)2 Udf (io.confluent.ksql.function.udf.Udf)2 UdfParameter (io.confluent.ksql.function.udf.UdfParameter)2 UdfSchemaProvider (io.confluent.ksql.function.udf.UdfSchemaProvider)2 SchemaConverters (io.confluent.ksql.schema.ksql.SchemaConverters)2