Skip to content

Commit 2032d48

Browse files
authored
Merge pull request #108 from DataSQRL/fix/auto_register
mark aggregation functions as auto-service
2 parents 6ec482a + c347982 commit 2032d48

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

types/json-type/src/main/java/com/datasqrl/flinkrunner/functions/json/jsonb_array_agg.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@
1515
*/
1616
package com.datasqrl.flinkrunner.functions.json;
1717

18+
import com.datasqrl.flinkrunner.functions.AutoRegisterSystemFunction;
1819
import com.datasqrl.flinkrunner.types.json.FlinkJsonType;
20+
import com.google.auto.service.AutoService;
1921
import java.util.ArrayList;
2022
import lombok.SneakyThrows;
2123
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
2224
import org.apache.flink.table.functions.AggregateFunction;
2325
import org.apache.flink.util.jackson.JacksonMapperFactory;
2426

2527
/** Aggregation function that aggregates JSON objects into a JSON array. */
26-
public class jsonb_array_agg extends AggregateFunction<FlinkJsonType, ArrayAgg> {
28+
@AutoService(AutoRegisterSystemFunction.class)
29+
public class jsonb_array_agg extends AggregateFunction<FlinkJsonType, ArrayAgg>
30+
implements AutoRegisterSystemFunction {
2731

2832
private static final ObjectMapper mapper = JacksonMapperFactory.createObjectMapper();
2933

types/json-type/src/main/java/com/datasqrl/flinkrunner/functions/json/jsonb_object_agg.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
*/
1616
package com.datasqrl.flinkrunner.functions.json;
1717

18+
import com.datasqrl.flinkrunner.functions.AutoRegisterSystemFunction;
1819
import com.datasqrl.flinkrunner.types.json.FlinkJsonType;
1920
import com.datasqrl.flinkrunner.types.json.FlinkJsonTypeSerializer;
21+
import com.google.auto.service.AutoService;
2022
import java.util.LinkedHashMap;
2123
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
2224
import org.apache.flink.table.annotation.DataTypeHint;
@@ -35,7 +37,9 @@
3537
value = "RAW",
3638
bridgedTo = FlinkJsonType.class,
3739
rawSerializer = FlinkJsonTypeSerializer.class))
38-
public class jsonb_object_agg extends AggregateFunction<Object, ObjectAgg> {
40+
@AutoService(AutoRegisterSystemFunction.class)
41+
public class jsonb_object_agg extends AggregateFunction<Object, ObjectAgg>
42+
implements AutoRegisterSystemFunction {
3943

4044
private static final ObjectMapper mapper = JacksonMapperFactory.createObjectMapper();
4145

types/vector-type/src/main/java/com/datasqrl/flinkrunner/functions/vector/center.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@
1818
import static com.datasqrl.flinkrunner.functions.vector.VectorFunctions.VEC_TO_DOUBLE;
1919
import static com.datasqrl.flinkrunner.functions.vector.VectorFunctions.convert;
2020

21+
import com.datasqrl.flinkrunner.functions.AutoRegisterSystemFunction;
2122
import com.datasqrl.flinkrunner.types.vector.FlinkVectorType;
23+
import com.google.auto.service.AutoService;
2224
import org.apache.flink.table.functions.AggregateFunction;
2325

2426
/**
2527
* Aggregates vectors by computing the centroid, i.e. summing up all vectors and dividing the
2628
* resulting vector by the number of vectors.
2729
*/
28-
public class center extends AggregateFunction<FlinkVectorType, CenterAccumulator> {
30+
@AutoService(AutoRegisterSystemFunction.class)
31+
public class center extends AggregateFunction<FlinkVectorType, CenterAccumulator>
32+
implements AutoRegisterSystemFunction {
2933

3034
@Override
3135
public CenterAccumulator createAccumulator() {

types/vector-type/src/main/java/com/datasqrl/flinkrunner/functions/vector/cosine_distance.java

+3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
*/
1616
package com.datasqrl.flinkrunner.functions.vector;
1717

18+
import com.datasqrl.flinkrunner.functions.AutoRegisterSystemFunction;
1819
import com.datasqrl.flinkrunner.types.vector.FlinkVectorType;
20+
import com.google.auto.service.AutoService;
1921

2022
/** Computes the cosine distance between two vectors */
23+
@AutoService(AutoRegisterSystemFunction.class)
2124
public class cosine_distance extends cosine_similarity {
2225

2326
@Override

0 commit comments

Comments
 (0)