Skip to content

Allow timestamp-index derived columns in star-tree dimensionsSplitOrder validation - #18774

Merged
Jackie-Jiang merged 3 commits into
apache:masterfrom
himanish-star:fix-startree-index-timestamp-derived-column-validation
Aug 13, 2026
Merged

Allow timestamp-index derived columns in star-tree dimensionsSplitOrder validation#18774
Jackie-Jiang merged 3 commits into
apache:masterfrom
himanish-star:fix-startree-index-timestamp-derived-column-validation

Conversation

@himanish-star

Copy link
Copy Markdown
Contributor

Problem

A table config that references timestamp-index derived columns (\$<column>\$<GRANULARITY>, e.g. \$OrderDate\$DAY) in starTreeIndexConfigs[].dimensionsSplitOrder is rejected by TableConfigUtils validation with:

Failed to find dimension column: $OrderDate$DAY specified in star-tree index config in schema

These derived columns are declared via fieldConfigList[].timestampConfig.granularities and are materialized as dictionary-encoded, single-value TIMESTAMP columns at segment generation time (TimestampIndexUtils#applyTimestampIndex). They are therefore absent from the schema during config validation, even though the configuration is valid and works at runtime. Today the only workaround is to push the config through the REST API with validation skipped.

Fix

validateStarTreeIndexConfigs now receives the set of declared timestamp-index columns (TimestampIndexUtils#extractColumnsWithGranularity) and accepts them in dimensionsSplitOrder without a schema lookup — matching how they are handled at segment generation time. Columns whose granularity is not declared in timestampConfig are still rejected.

Testing

Added TableConfigUtilsTest#testValidateStarTreeIndexWithTimestampIndexDerivedColumns:

  • A star-tree config using \$OrderDate\$DAY/WEEK/MONTH with matching timestampConfig granularities now validates.
  • A star-tree dimension referencing an undeclared granularity (\$OrderDate\$HOUR) still fails validation.

checkstyle:check and license:check pass on pinot-segment-local.

@codecov-commenter

codecov-commenter commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.96%. Comparing base (ffa97d9) to head (c8cd5cd).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18774      +/-   ##
============================================
+ Coverage     66.94%   66.96%   +0.02%     
  Complexity     1423     1423              
============================================
  Files          3453     3453              
  Lines        218858   218876      +18     
  Branches      34787    34792       +5     
============================================
+ Hits         146512   146572      +60     
+ Misses        60621    60595      -26     
+ Partials      11725    11709      -16     
Flag Coverage Δ
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-25 66.96% <100.00%> (+0.02%) ⬆️
lane-a 100.00% <ø> (ø)
lane-b 0.00% <ø> (ø)
temurin 66.96% <100.00%> (+0.02%) ⬆️
unittests 66.96% <100.00%> (+0.02%) ⬆️
unittests1 57.71% <22.22%> (+0.01%) ⬆️
unittests2 39.03% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Vamsi-klu

Copy link
Copy Markdown
Contributor

Walked through the three guards in validateStarTreeIndexConfigs: the first-loop indexConfigsMap.get(dimension) dictionary check, the Iterables.concat MAP check, and the dimensionColumns single-value check now all short circuit when the column is in timestampIndexColumns, so $OrderDate$DAY no longer trips the Failed to find dimension column precondition. I like that the allowed set comes from extractColumnsWithGranularity rather than an isValidColumnWithGranularity shape match, since that's exactly what keeps $OrderDate$HOUR in the negative test rejected instead of blanket accepted (HOUR is a valid granularity token but was never declared on OrderDate). It also lines up with what applyTimestampIndex materializes into the schema at segment build time, so config validation and runtime agree. One note: the derived branch skips the dictionary precondition too, which reads fine since these get generated as dictionary encoded. This looks right to me.

@Jackie-Jiang Jackie-Jiang added enhancement Improvement to existing functionality star-tree index Related to StarTree index index Related to indexing (general) labels Jul 24, 2026

@Jackie-Jiang Jackie-Jiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change looks good. Consider adding an end-to-end queries test with star-tree index enabled on a timestamp index column, and ensure the query can use star-tree index properly.

@himanish-star

Copy link
Copy Markdown
Contributor Author

The change looks good. Consider adding an end-to-end queries test with star-tree index enabled on a timestamp index column, and ensure the query can use star-tree index properly.

sure

@Jackie-Jiang
Jackie-Jiang requested a lite review from Copilot August 6, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Jackie-Jiang

Copy link
Copy Markdown
Contributor

@himanish-star Follow up on this. Do you get a chance to work on the test? It should be similar to RawWithDictionaryStarTreeV2Test

@himanish-star

Copy link
Copy Markdown
Contributor Author

@Jackie-Jiang working on it now, will update shortly

himanish-star and others added 2 commits August 14, 2026 00:25
…er validation

Timestamp-index derived columns ($col$GRANULARITY) declared via fieldConfig
timestampConfig granularities are materialized as dictionary-encoded
single-value TIMESTAMP columns at segment generation time, so they are absent
from the schema during table config validation. TableConfigUtils
#validateStarTreeIndexConfigs rejected them with 'Failed to find dimension
column ... in schema', forcing users to bypass validation via the raw REST API.

Accept declared timestamp-index columns in dimensionsSplitOrder without a
schema lookup, mirroring how they are handled at segment generation time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds TimestampIndexStarTreeV2Test, which runs the full BaseStarTreeV2Test
query matrix against a star-tree whose dimensionsSplitOrder contains a
TIMESTAMP-index derived column ($tsCol$MILLISECOND). The derived column is
declared only through fieldConfig timestampConfig granularities and is
materialized by TimestampIndexUtils#applyTimestampIndex at segment generation
time, so this covers the runtime half of the validation fix: the tree really
is built over the derived column, and every filter and group-by against it
yields the same aggregate through the star-tree as through a plain scan.

MILLISECOND granularity is used because dateTrunc('MILLISECOND', tsCol) is the
identity, so the derived column carries the same [0, DIMENSION_CARDINALITY)
value domain as the regular dimensions and the inherited predicate literals
apply to it unchanged. A dictionary-length assertion pins that the transform
actually ran, so the query cases cannot pass vacuously against an all-defaults
column.

BaseStarTreeV2Test gains hooks for schema fields, record values and the
dimensions split order, exposes the aggregation string and star-tree, and
widens testQuery to protected. Existing subclasses are unaffected.

Also fixes TableConfigUtilsTest to use the DataType import directly, which
master switched to after this branch was first written.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@himanish-star
himanish-star force-pushed the fix-startree-index-timestamp-derived-column-validation branch from eae9d21 to 155e09c Compare August 13, 2026 19:33
… column

testQueriesOnTimestampIndexColumn proves the star-tree returns correct results
when it is traversed, but it builds StarTreeFilterPlanNode directly and never
exercises StarTreeUtils#isFitForStarTree, the gate AggregationPlanNode and
GroupByPlanNode use to pick a tree. A derived column could therefore be
correct-when-used yet never selected.

Assert the gate accepts a query with the derived column in both the filter and
the group-by, and rejects the same query when the predicate column is the raw
TIMESTAMP column, which is in the schema but not a star-tree dimension. The
negative case keeps the positive one from passing vacuously.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@himanish-star

Copy link
Copy Markdown
Contributor Author

added @Jackie-Jiang

@Jackie-Jiang
Jackie-Jiang merged commit 69e57f6 into apache:master Aug 13, 2026
12 checks passed
xiangfu0 added a commit to pinot-contrib/pinot-docs that referenced this pull request Aug 13, 2026
Documents support added by apache/pinot#18774 for using timestamp-index
derived columns in `starTreeIndexConfigs[].dimensionsSplitOrder`.

The update explains the derived-column naming convention, requires the
matching timestamp granularity to be declared, and clarifies that Pinot
materializes these columns during segment generation.

Validation: `git diff --check`.

Co-authored-by: Xiang Fu <xiangfu@Xiang-mac-mtv-2.local>
@xiangfu0

Copy link
Copy Markdown
Contributor

Documentation follow-up: pinot-contrib/pinot-docs#982 (merged).

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

Labels

enhancement Improvement to existing functionality index Related to indexing (general) star-tree index Related to StarTree index

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants