From a3ea6a46ae74c18af1fac8e4de2a0caba7496a0a Mon Sep 17 00:00:00 2001 From: Zara Lim Date: Tue, 31 Aug 2021 23:03:20 -0700 Subject: [PATCH] fix: add new types to udaf functions (#8081) * fix: add new types to udaf functions * checkstyle * typos * indent --- .../function/udaf/array/CollectListUdaf.java | 25 ++ .../function/udaf/array/CollectSetUdaf.java | 24 ++ .../udaf/offset/EarliestByOffset.java | 118 +++++++++ .../udaf/offset/KudafByOffsetUtils.java | 24 ++ .../function/udaf/offset/LatestByOffset.java | 132 +++++++++- .../udaf/array/CollectListUdafTest.java | 48 ++++ .../udaf/array/CollectSetUdafTest.java | 48 ++++ .../udaf/offset/EarliestByOffsetTest.java | 128 ++++++++++ .../udaf/offset/LatestByOffsetTest.java | 130 ++++++++++ .../7.1.0_1630368512001/plan.json | 205 +++++++++++++++ .../7.1.0_1630368512001/spec.json | 155 ++++++++++++ .../7.1.0_1630368512001/topology | 25 ++ .../7.1.0_1630368515862/plan.json | 215 ++++++++++++++++ .../7.1.0_1630368515862/spec.json | 186 ++++++++++++++ .../7.1.0_1630368515862/topology | 43 ++++ .../7.1.0_1630368511768/plan.json | 205 +++++++++++++++ .../7.1.0_1630368511768/spec.json | 173 +++++++++++++ .../7.1.0_1630368511768/topology | 25 ++ .../7.1.0_1630368511850/plan.json | 205 +++++++++++++++ .../7.1.0_1630368511850/spec.json | 178 +++++++++++++ .../7.1.0_1630368511850/topology | 25 ++ .../7.1.0_1630368515513/plan.json | 215 ++++++++++++++++ .../7.1.0_1630368515513/spec.json | 210 ++++++++++++++++ .../7.1.0_1630368515513/topology | 43 ++++ .../7.1.0_1630368515678/plan.json | 215 ++++++++++++++++ .../7.1.0_1630368515678/spec.json | 217 ++++++++++++++++ .../7.1.0_1630368515678/topology | 43 ++++ .../7.1.0_1630368511554/plan.json | 205 +++++++++++++++ .../7.1.0_1630368511554/spec.json | 173 +++++++++++++ .../7.1.0_1630368511554/topology | 25 ++ .../7.1.0_1630368511626/plan.json | 205 +++++++++++++++ .../7.1.0_1630368511626/spec.json | 178 +++++++++++++ .../7.1.0_1630368511626/topology | 25 ++ .../7.1.0_1630368515150/plan.json | 215 ++++++++++++++++ .../7.1.0_1630368515150/spec.json | 210 ++++++++++++++++ .../7.1.0_1630368515150/topology | 43 ++++ .../7.1.0_1630368515326/plan.json | 215 ++++++++++++++++ .../7.1.0_1630368515326/spec.json | 217 ++++++++++++++++ .../7.1.0_1630368515326/topology | 43 ++++ .../7.1.0_1630368511264/plan.json | 205 +++++++++++++++ .../7.1.0_1630368511264/spec.json | 173 +++++++++++++ .../7.1.0_1630368511264/topology | 25 ++ .../7.1.0_1630368511384/plan.json | 205 +++++++++++++++ .../7.1.0_1630368511384/spec.json | 178 +++++++++++++ .../7.1.0_1630368511384/topology | 25 ++ .../7.1.0_1630368514803/plan.json | 215 ++++++++++++++++ .../7.1.0_1630368514803/spec.json | 210 ++++++++++++++++ .../7.1.0_1630368514803/topology | 43 ++++ .../7.1.0_1630368514960/plan.json | 215 ++++++++++++++++ .../7.1.0_1630368514960/spec.json | 217 ++++++++++++++++ .../7.1.0_1630368514960/topology | 43 ++++ .../7.1.0_1630368518406/plan.json | 205 +++++++++++++++ .../7.1.0_1630368518406/spec.json | 170 +++++++++++++ .../7.1.0_1630368518406/topology | 25 ++ .../7.1.0_1630368518205/plan.json | 205 +++++++++++++++ .../7.1.0_1630368518205/spec.json | 173 +++++++++++++ .../7.1.0_1630368518205/topology | 25 ++ .../7.1.0_1630368518316/plan.json | 205 +++++++++++++++ .../7.1.0_1630368518316/spec.json | 178 +++++++++++++ .../7.1.0_1630368518316/topology | 25 ++ .../7.1.0_1630368518012/plan.json | 205 +++++++++++++++ .../7.1.0_1630368518012/spec.json | 173 +++++++++++++ .../7.1.0_1630368518012/topology | 25 ++ .../7.1.0_1630368518117/plan.json | 205 +++++++++++++++ .../7.1.0_1630368518117/spec.json | 178 +++++++++++++ .../7.1.0_1630368518117/topology | 25 ++ .../7.1.0_1630368517819/plan.json | 205 +++++++++++++++ .../7.1.0_1630368517819/spec.json | 173 +++++++++++++ .../7.1.0_1630368517819/topology | 25 ++ .../7.1.0_1630368517923/plan.json | 205 +++++++++++++++ .../7.1.0_1630368517923/spec.json | 178 +++++++++++++ .../7.1.0_1630368517923/topology | 25 ++ .../7.1.0_1630368526794/plan.json | 205 +++++++++++++++ .../7.1.0_1630368526794/spec.json | 237 ++++++++++++++++++ .../7.1.0_1630368526794/topology | 25 ++ .../7.1.0_1630368619417/plan.json | 205 +++++++++++++++ .../7.1.0_1630368619417/spec.json | 237 ++++++++++++++++++ .../7.1.0_1630368619417/topology | 25 ++ .../query-validation-tests/collect-list.json | 147 +++++++++++ .../query-validation-tests/collect-set.json | 72 ++++++ .../earliest-offset-udaf.json | 20 +- .../latest-offset-udaf.json | 20 +- 82 files changed, 10766 insertions(+), 28 deletions(-) create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_bytes_map_-_JSON/7.1.0_1630368512001/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_bytes_map_-_JSON/7.1.0_1630368512001/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_bytes_map_-_JSON/7.1.0_1630368512001/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_bytes_map_table_-_JSON/7.1.0_1630368515862/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_bytes_map_table_-_JSON/7.1.0_1630368515862/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_bytes_map_table_-_JSON/7.1.0_1630368515862/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_-_JSON/7.1.0_1630368511768/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_-_JSON/7.1.0_1630368511768/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_-_JSON/7.1.0_1630368511768/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_-_PROTOBUF/7.1.0_1630368511850/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_-_PROTOBUF/7.1.0_1630368511850/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_-_PROTOBUF/7.1.0_1630368511850/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_table_-_JSON/7.1.0_1630368515513/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_table_-_JSON/7.1.0_1630368515513/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_table_-_JSON/7.1.0_1630368515513/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_table_-_PROTOBUF/7.1.0_1630368515678/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_table_-_PROTOBUF/7.1.0_1630368515678/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_date_map_table_-_PROTOBUF/7.1.0_1630368515678/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_-_JSON/7.1.0_1630368511554/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_-_JSON/7.1.0_1630368511554/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_-_JSON/7.1.0_1630368511554/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_-_PROTOBUF/7.1.0_1630368511626/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_-_PROTOBUF/7.1.0_1630368511626/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_-_PROTOBUF/7.1.0_1630368511626/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_table_-_JSON/7.1.0_1630368515150/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_table_-_JSON/7.1.0_1630368515150/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_table_-_JSON/7.1.0_1630368515150/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_table_-_PROTOBUF/7.1.0_1630368515326/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_table_-_PROTOBUF/7.1.0_1630368515326/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_time_map_table_-_PROTOBUF/7.1.0_1630368515326/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_-_JSON/7.1.0_1630368511264/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_-_JSON/7.1.0_1630368511264/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_-_JSON/7.1.0_1630368511264/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_-_PROTOBUF/7.1.0_1630368511384/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_-_PROTOBUF/7.1.0_1630368511384/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_-_PROTOBUF/7.1.0_1630368511384/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_table_-_JSON/7.1.0_1630368514803/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_table_-_JSON/7.1.0_1630368514803/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_table_-_JSON/7.1.0_1630368514803/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_table_-_PROTOBUF/7.1.0_1630368514960/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_table_-_PROTOBUF/7.1.0_1630368514960/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-list_-_collect_list_timestamp_map_table_-_PROTOBUF/7.1.0_1630368514960/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_bytes_map_-_JSON/7.1.0_1630368518406/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_bytes_map_-_JSON/7.1.0_1630368518406/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_bytes_map_-_JSON/7.1.0_1630368518406/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_date_map_-_JSON/7.1.0_1630368518205/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_date_map_-_JSON/7.1.0_1630368518205/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_date_map_-_JSON/7.1.0_1630368518205/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_date_map_-_PROTOBUF/7.1.0_1630368518316/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_date_map_-_PROTOBUF/7.1.0_1630368518316/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_date_map_-_PROTOBUF/7.1.0_1630368518316/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_time_map_-_JSON/7.1.0_1630368518012/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_time_map_-_JSON/7.1.0_1630368518012/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_time_map_-_JSON/7.1.0_1630368518012/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_time_map_-_PROTOBUF/7.1.0_1630368518117/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_time_map_-_PROTOBUF/7.1.0_1630368518117/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_time_map_-_PROTOBUF/7.1.0_1630368518117/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_timestamp_map_-_JSON/7.1.0_1630368517819/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_timestamp_map_-_JSON/7.1.0_1630368517819/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_timestamp_map_-_JSON/7.1.0_1630368517819/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_timestamp_map_-_PROTOBUF/7.1.0_1630368517923/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_timestamp_map_-_PROTOBUF/7.1.0_1630368517923/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/collect-set_-_collect_list_timestamp_map_-_PROTOBUF/7.1.0_1630368517923/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/earliest-offset-udaf_-_earliest_by_offset/7.1.0_1630368526794/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/earliest-offset-udaf_-_earliest_by_offset/7.1.0_1630368526794/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/earliest-offset-udaf_-_earliest_by_offset/7.1.0_1630368526794/topology create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/latest-offset-udaf_-_latest_by_offset/7.1.0_1630368619417/plan.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/latest-offset-udaf_-_latest_by_offset/7.1.0_1630368619417/spec.json create mode 100644 ksqldb-functional-tests/src/test/resources/historical_plans/latest-offset-udaf_-_latest_by_offset/7.1.0_1630368619417/topology diff --git a/ksqldb-engine/src/main/java/io/confluent/ksql/function/udaf/array/CollectListUdaf.java b/ksqldb-engine/src/main/java/io/confluent/ksql/function/udaf/array/CollectListUdaf.java index 33496ff62277..ec29e22c094a 100644 --- a/ksqldb-engine/src/main/java/io/confluent/ksql/function/udaf/array/CollectListUdaf.java +++ b/ksqldb-engine/src/main/java/io/confluent/ksql/function/udaf/array/CollectListUdaf.java @@ -20,6 +20,10 @@ import io.confluent.ksql.function.udaf.UdafDescription; import io.confluent.ksql.function.udaf.UdafFactory; import io.confluent.ksql.util.KsqlConstants; +import java.nio.ByteBuffer; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; import java.util.List; import java.util.Map; import org.apache.kafka.common.Configurable; @@ -67,6 +71,27 @@ public static TableUdaf, List> createCollectList return new Collect<>(); } + @UdafFactory(description = "collect values of a Timestamp field into a single Array") + public static TableUdaf, List> + createCollectListTimestamp() { + return new Collect<>(); + } + + @UdafFactory(description = "collect values of a Time field into a single Array") + public static TableUdaf, List