ksqlDB Extensions
ksqlDB extensions are pieces of logic for transforming or aggregating events that ksqlDB can't currently express.
Check the Kafka ksqlDB section.
For creating the jar
extension, you can use the following command (development purposes):
gradle kafka-ksqldb-extensions:shadowJar
Custom UDF
package kafka.sandbox.ksqldb;
import io.confluent.ksql.function.udf.Udf;
import io.confluent.ksql.function.udf.UdfDescription;
import io.confluent.ksql.function.udf.UdfParameter;
@UdfDescription(
name = "taxes",
author = "kafka sandbox",
version = "1.0.0",
description = "A custom taxes formula for orders."
)
public class TaxesUdf {
public static final double TAXES = .12;
@Udf(description = "Calculate taxes.")
public double taxes(@UdfParameter double amount) {
return amount * TAXES;
}
}