Skip to content

feat: allow clustered segments to create projection grouped by a vc derived clustered column - #19752

Open
capistrant wants to merge 2 commits into
apache:masterfrom
capistrant:fix-clustered-projection-group-by-derived-column
Open

feat: allow clustered segments to create projection grouped by a vc derived clustered column#19752
capistrant wants to merge 2 commits into
apache:masterfrom
capistrant:fix-clustered-projection-group-by-derived-column

Conversation

@capistrant

Copy link
Copy Markdown
Contributor

Description

Eagerly derive clustered columns during indexing and if the spec has projections materialize the clustered columns for each row so if a projection being built groups on a VC derived clustering column, the grouping value is available to the indexer. Before this change, if you tried to do ingestion with a vc derived clustering column that was then used for a grouping column in a projection, the projection would register null for all rows for that grouping column because it wasn't available at build time.

Release note

N/A. part of larger Druid 39 release note on clustered segment improvements


Key changed/added classes in this PR
  • OnHeapClusteredBaseTable
  • OnHeapIncrementalIndex

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity Findings
P0 0
P1 1
P2 0
P3 0
Total 1
Severity Findings
P0 0
P1 1
P2 0
P3 0
Total 1

The derived clustering value now reaches projection grouping keys, but projection filters and aggregators still read the raw input row.

Reviewed 4 of 4 changed files.


This is an automated review by Codex GPT-5.6-Sol

// reused by the clustered addToFacts below so the clustering derivation happens exactly once.
final Object[] clusteringValues = clusteredBaseTable == null
? null
: clusteredBaseTable.prepareClusteringValues(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Expose derived values to projection filters and aggregators

The derived clustering value is only encoded into key.dims, so it fixes grouping but remains invisible to the projection's filter and aggregator selectors, which read the raw InputRow through the projection's own virtual-column factory. For example, a filtered projection that groups on derived region and filters region = us-east-1 is accepted, but the matcher sees the absent top-level field as null and drops every matching row; an aggregator reading a derived numeric clustering column likewise receives null. This can produce incomplete projection results. Please make these selectors consume the derived value too, or reject such projection specifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants