use of io.confluent.ksql.function.udaf.topk.TopKAggregateFunctionFactory 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());
}
Aggregations