Skip to content

Add unit tests for FSTIndexHandler legacy-FST detection and index lifecycle#18960

Open
Akanksha-kedia wants to merge 4 commits into
apache:masterfrom
Akanksha-kedia:feat/fst-index-handler-test
Open

Add unit tests for FSTIndexHandler legacy-FST detection and index lifecycle#18960
Akanksha-kedia wants to merge 4 commits into
apache:masterfrom
Akanksha-kedia:feat/fst-index-handler-test

Conversation

@Akanksha-kedia

@Akanksha-kedia Akanksha-kedia commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

error connecting to userproxy.visa.com
check your internet connection or https://githubstatus.com

FSTIndexHandler had no unit test coverage. Adds FSTIndexHandlerTest with
6 tests covering:
- Legacy native FST index detected via magic bytes triggers rebuild
- updateIndices removes legacy native FST index
- Column dropped from config triggers index removal
- updateIndices removes index for column dropped from config
- New column in config triggers index creation
- Index already up-to-date (Lucene FST, in config) requires no update

The legacy-native check is tested by mocking PinotDataBuffer.getInt(0)
to return the native magic constant, mirroring FstIndexUtils.isLegacyNativeFst.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.25%. Comparing base (bcf3f66) to head (969ef32).
⚠️ Report is 56 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18960      +/-   ##
============================================
+ Coverage     64.86%   65.25%   +0.39%     
- Complexity     1347     1405      +58     
============================================
  Files          3392     3418      +26     
  Lines        211663   214642    +2979     
  Branches      33306    33919     +613     
============================================
+ Hits         137290   140069    +2779     
+ Misses        63296    63272      -24     
- Partials      11077    11301     +224     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (?)
java-21 65.25% <ø> (+0.39%) ⬆️
temurin 65.25% <ø> (+0.39%) ⬆️
unittests 65.25% <ø> (+0.39%) ⬆️
unittests1 56.86% <ø> (-0.13%) ⬇️
unittests2 37.77% <ø> (+0.54%) ⬆️

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.

@Akanksha-kedia

Copy link
Copy Markdown
Contributor Author

@Jackie-Jiang Jackie-Jiang added the testing Related to tests or test infrastructure label Jul 10, 2026
@Jackie-Jiang

Copy link
Copy Markdown
Contributor

The newly added test is failing. Please take a look

… on ColumnMetadata mock

checkUnsupportedOperationsForFSTIndex() validates that the column is STRING, dictionary-encoded,
and single-value before creating the index.  The mock returned null for getDataType(), causing
null != STRING to throw UnsupportedOperationException instead of returning true.
…ler preconditions

Stub getTotalDocs()→1 and getAllColumns()→TreeSet in all SegmentMetadataImpl
mocks so the BaseIndexHandler constructor precondition check does not throw.
@Akanksha-kedia

Copy link
Copy Markdown
Contributor Author

@xiangfu0 please take a look when you get a chance

@Akanksha-kedia

Copy link
Copy Markdown
Contributor Author

@xiangfu0 @shounakmk219 would appreciate a review when you get a chance. This PR adds unit tests for Add unit tests for FSTIndexHandler legacy-FST detection and index lifecycle.

@gortiz

gortiz commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Thanks for adding coverage here! A few notes:

PR description — the description currently just contains an error string ("error connecting to userproxy.visa.com…"), which looks like a stray paste rather than an actual description. Could you update it to describe what this adds and why (e.g. legacy-FST detection + config-driven add/remove lifecycle for FSTIndexHandler)?

Style nit — the // --------------------------------------------------------------------------- section banners aren't a pattern we typically use in Pinot to group tests within a class (see VectorIndexHandlerTest/InvertedIndexHandlerTest for the existing convention). Would suggest dropping them and letting descriptive test method names carry that grouping instead.

Test coverage — this covers needUpdateIndices/removal well, but a couple of gaps relative to the PR title ("index lifecycle"):

  • checkUnsupportedOperationsForFSTIndex (non-STRING type, non-dictionary-encoded, multi-value columns → UnsupportedOperationException) isn't exercised at all. The "new column added" test already builds a ColumnMetadata mock that could be parameterized to hit these branches.
  • The actual index-creation path (createFSTIndexForColumn — marker file, IndexCreationContext, FSTIndexCreator, dictionary iteration, v3 write) is never invoked/verified. Right now updateIndices is only tested for the removal branches; it'd be good to add a case confirming a new FST index actually gets created for a newly-added column, not just that needUpdateIndices detects the need for one.

Happy to help think through mocking the creation path if that's tricky.

@Akanksha-kedia

Copy link
Copy Markdown
Contributor Author

@xiangfu0 @gortiz — would appreciate a review when you get a chance 🙏

…on path coverage

- Convert class Javadoc to JEP 467 Markdown (///) style
- Drop // ---- section-banner comments
- Replace bare Map.of() with explicit Map.of(COLUMN, NO_FST) using
  FstIndexConfig.DISABLED so removed-column intent is unambiguous
- Add three checkUnsupportedOperationsForFSTIndex tests: non-STRING
  data type, no dictionary, and multi-value column each throw
  UnsupportedOperationException from needUpdateIndices
- Add testUpdateIndicesCreatesNewFstIndexForNewColumn: builds a real
  v1 segment, verifies needUpdateIndices returns true, calls
  updateIndices, and asserts the .lucene.v912.fst file is written
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to tests or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants