Skip to content

Declare a top-K aggregation on a group and list what declares one (Steps 1 and 2 of #386) - #493

Open
zipdoki wants to merge 2 commits into
mainfrom
feat/topk-metadata
Open

Declare a top-K aggregation on a group and list what declares one (Steps 1 and 2 of #386)#493
zipdoki wants to merge 2 commits into
mainfrom
feat/topk-metadata

Conversation

@zipdoki

@zipdoki zipdoki commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduce top-K aggregation metadata on Group and expose a read endpoint listing tables that declare one.

A Group can now carry an Aggregations block. Today only topk is defined; the schema is designed so future aggregation kinds (e.g. HLL) can land as sibling fields without restructuring the payload.

GET /graph/v3/aggregations returns a flat list of (type, database, table) tuples for every table that declares an aggregation, filterable by ?type=. The aggregate/mutate flow that consumes this metadata is out of scope for this PR and will land separately.

Metadata example

A group inside a label creation payload:

{
  "groups": [
    {
      "group": "purchased_count",
      "type": "COUNT",
      "fields": [{"name": "_target"}],
      "directionType": "OUT",
      "aggregations": {
        "topk": [
          {
            "topk": "top_purchased",
            "entity": "_source",
            "ranges": "_target:eq:{_target}",
            "dimension": "_target",
            "refreshAfterMillis": 31536000000,
            "rank": "commerce.purchases__topk"
          }
        ]
      }
    }
  ]
}

Endpoint example

GET /graph/v3/aggregations

{
  "items": [
    { "type": "TOPK", "database": "commerce", "table": "purchases" }
  ]
}

GET /graph/v3/aggregations?type=TOPK filters to a single aggregation type.

Test plan

  • ./gradlew :core:test --tests 'com.kakao.actionbase.core.metadata.common.AggregationsTest'
  • ./gradlew :engine:test --tests 'com.kakao.actionbase.engine.service.AggregationServiceSpec'
  • ./gradlew :engine:test --tests 'com.kakao.actionbase.v2.engine.entity.LabelEntityFunctionsSpec'
  • ./gradlew :server:test --tests 'com.kakao.actionbase.server.api.graph.v3.metadata.MetadataAggControllerE2ETest'

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Opus 4.7)

@zipdoki zipdoki self-assigned this Aug 19, 2026
@zipdoki
zipdoki requested a review from em3s as a code owner August 19, 2026 04:13
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant