Search in sources :

Example 1 with SumAggFunctionFactory

use of io.confluent.ksql.function.udaf.sum.SumAggFunctionFactory in project ksql by confluentinc.

the class FunctionRegistry method init.

private void init() {
    /**
     *************************************
     * String functions                     *
     ***************************************
     */
    KsqlFunction lcase = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA), "LCASE", LCaseKudf.class);
    addFunction(lcase);
    KsqlFunction ucase = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA), "UCASE", UCaseKudf.class);
    addFunction(ucase);
    KsqlFunction substring = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA, Schema.INT32_SCHEMA, Schema.INT32_SCHEMA), "SUBSTRING", SubstringKudf.class);
    addFunction(substring);
    KsqlFunction concat = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA), "CONCAT", ConcatKudf.class);
    addFunction(concat);
    KsqlFunction trim = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA), "TRIM", TrimKudf.class);
    addFunction(trim);
    KsqlFunction ifNull = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA), "IFNULL", IfNullKudf.class);
    addFunction(ifNull);
    KsqlFunction len = new KsqlFunction(Schema.INT32_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA), "LEN", LenKudf.class);
    addFunction(len);
    /**
     *************************************
     * Math functions                      *
     **************************************
     */
    KsqlFunction abs = new KsqlFunction(Schema.FLOAT64_SCHEMA, Arrays.asList(Schema.FLOAT64_SCHEMA), "ABS", AbsKudf.class);
    addFunction(abs);
    KsqlFunction ceil = new KsqlFunction(Schema.FLOAT64_SCHEMA, Arrays.asList(Schema.FLOAT64_SCHEMA), "CEIL", CeilKudf.class);
    addFunction(ceil);
    KsqlFunction floor = new KsqlFunction(Schema.FLOAT64_SCHEMA, Arrays.asList(Schema.FLOAT64_SCHEMA), "FLOOR", FloorKudf.class);
    addFunction(floor);
    KsqlFunction round = new KsqlFunction(Schema.INT64_SCHEMA, Arrays.asList(Schema.FLOAT64_SCHEMA), "ROUND", RoundKudf.class);
    addFunction(round);
    KsqlFunction random = new KsqlFunction(Schema.FLOAT64_SCHEMA, new ArrayList<>(), "RANDOM", RandomKudf.class);
    addFunction(random);
    /**
     *************************************
     * Date/Time functions                      *
     **************************************
     */
    KsqlFunction timestampToString = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.INT64_SCHEMA, Schema.STRING_SCHEMA), "TIMESTAMPTOSTRING", TimestampToString.class);
    addFunction(timestampToString);
    KsqlFunction stringToTimestamp = new KsqlFunction(Schema.INT64_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA), "STRINGTOTIMESTAMP", StringToTimestamp.class);
    addFunction(stringToTimestamp);
    /**
     *************************************
     * JSON functions                     *
     ***************************************
     */
    KsqlFunction getStringFromJson = new KsqlFunction(Schema.STRING_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA), "EXTRACTJSONFIELD", JsonExtractStringKudf.class);
    addFunction(getStringFromJson);
    KsqlFunction jsonArrayContainsString = new KsqlFunction(Schema.BOOLEAN_SCHEMA, Arrays.asList(Schema.STRING_SCHEMA, Schema.STRING_SCHEMA), "ARRAYCONTAINS", ArrayContainsKudf.class);
    addFunction(jsonArrayContainsString);
    addFunction(new KsqlFunction(Schema.BOOLEAN_SCHEMA, Arrays.asList(SchemaBuilder.array(Schema.STRING_SCHEMA).build(), Schema.STRING_SCHEMA), "ARRAYCONTAINS", ArrayContainsKudf.class));
    addFunction(new KsqlFunction(Schema.BOOLEAN_SCHEMA, Arrays.asList(SchemaBuilder.array(Schema.INT32_SCHEMA).build(), Schema.INT32_SCHEMA), "ARRAYCONTAINS", ArrayContainsKudf.class));
    addFunction(new KsqlFunction(Schema.BOOLEAN_SCHEMA, Arrays.asList(SchemaBuilder.array(Schema.INT64_SCHEMA).build(), Schema.INT64_SCHEMA), "ARRAYCONTAINS", ArrayContainsKudf.class));
    addFunction(new KsqlFunction(Schema.BOOLEAN_SCHEMA, Arrays.asList(SchemaBuilder.array(Schema.FLOAT64_SCHEMA).build(), Schema.FLOAT64_SCHEMA), "ARRAYCONTAINS", ArrayContainsKudf.class));
    /**
     *************************************
     * UDAFs                               *
     **************************************
     */
    addAggregateFunctionFactory(new CountAggFunctionFactory());
    addAggregateFunctionFactory(new SumAggFunctionFactory());
    addAggregateFunctionFactory(new MaxAggFunctionFactory());
    addAggregateFunctionFactory(new MinAggFunctionFactory());
    addAggregateFunctionFactory(new TopKAggregateFunctionFactory());
    addAggregateFunctionFactory(new TopkDistinctAggFunctionFactory());
}
Also used : TopKAggregateFunctionFactory(io.confluent.ksql.function.udaf.topk.TopKAggregateFunctionFactory) SumAggFunctionFactory(io.confluent.ksql.function.udaf.sum.SumAggFunctionFactory) TopkDistinctAggFunctionFactory(io.confluent.ksql.function.udaf.topkdistinct.TopkDistinctAggFunctionFactory) MaxAggFunctionFactory(io.confluent.ksql.function.udaf.max.MaxAggFunctionFactory) MinAggFunctionFactory(io.confluent.ksql.function.udaf.min.MinAggFunctionFactory) ArrayContainsKudf(io.confluent.ksql.function.udf.json.ArrayContainsKudf) CountAggFunctionFactory(io.confluent.ksql.function.udaf.count.CountAggFunctionFactory)

Aggregations

CountAggFunctionFactory (io.confluent.ksql.function.udaf.count.CountAggFunctionFactory)1 MaxAggFunctionFactory (io.confluent.ksql.function.udaf.max.MaxAggFunctionFactory)1 MinAggFunctionFactory (io.confluent.ksql.function.udaf.min.MinAggFunctionFactory)1 SumAggFunctionFactory (io.confluent.ksql.function.udaf.sum.SumAggFunctionFactory)1 TopKAggregateFunctionFactory (io.confluent.ksql.function.udaf.topk.TopKAggregateFunctionFactory)1 TopkDistinctAggFunctionFactory (io.confluent.ksql.function.udaf.topkdistinct.TopkDistinctAggFunctionFactory)1 ArrayContainsKudf (io.confluent.ksql.function.udf.json.ArrayContainsKudf)1