Skip to content

test(metadata): cover getColumnsToIndex when the table schema is absent - #19859

Open
rangareddy wants to merge 1 commit into
apache:masterfrom
rangareddy:HUDI-9194-columns-to-index-schema-absent
Open

test(metadata): cover getColumnsToIndex when the table schema is absent#19859
rangareddy wants to merge 1 commit into
apache:masterfrom
rangareddy:HUDI-9194-columns-to-index-schema-absent

Conversation

@rangareddy

Copy link
Copy Markdown
Collaborator

Describe the issue this Pull Request addresses

Closes #17410 (https://issues.apache.org/jira/browse/HUDI-9194).

The ticket asks whether HoodieTableMetadataUtil#getColumnsToIndexWithoutRequiredMetaFields needs a test case. Reading TestHoodieTableMetadataUtil#testGetColumnsToIndex, most of it is already covered through the public getColumnsToIndex wrapper: the explicit column list, meta columns appearing inside that list, unsupported column types, nested fields, the max-columns cap, and meta fields disabled.

One branch is not reachable from any existing case. Every case there supplies a table schema, so the path taken when the schema is absent is never exercised:

if (tableSchemaLazyOpt.get().isPresent()) {
  ...
} else {
  // initialize col stats index config with empty list of cols
  return Collections.emptyMap();
}

and, on the explicit-list side of the same method, the guard that fires when there is no schema to resolve names against:

ValidationUtils.checkArgument(tableSchemaLazyOpt.get().isPresent(),
    "Table schema not found for the table while computing col stats");

Summary and Changelog

  • TestHoodieTableMetadataUtil: new testGetColumnsToIndexWhenTableSchemaIsAbsent, covering the schema-absent branch in the three ways it behaves:
    • No explicit column list: the inner call returns nothing, so the caller is left with just the always-indexed meta columns. Col stats initialises rather than failing.
    • An explicit column list: IllegalArgumentException naming the missing schema. The configured names cannot be resolved to field schemas without one, and quietly indexing nothing would look like the config had been honoured.
    • The same list while the table is initialising: the configured names are recorded without their schemas, so col stats can be enabled before the first commit has produced a schema.

No code was copied.

Impact

Test-only. No production code is touched, and no existing test is modified.

Worth noting for a reader: writing this corrected two assumptions of mine that the run disproved. The schema-absent, no-list case does not return an empty map to the caller, because the wrapper still adds META_COLS_TO_ALWAYS_INDEX; and the initialising case returns five entries, not two, for the same reason. The test asserts what the code does.

Risk Level

none

Verified on Spark 3.5 / Scala 2.12:

  • mvn test -pl hudi-hadoop-common -Dtest=TestHoodieTableMetadataUtil -> Tests run: 19, Failures: 0, Errors: 0
  • mvn test-compile checkstyle:check -pl hudi-hadoop-common -> clean

Documentation Update

none

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

Closes apache#17410.

HUDI-9194 asked whether getColumnsToIndexWithoutRequiredMetaFields needs a test
case. Its branches are almost all covered already through the public
getColumnsToIndex wrapper: the explicit column list, meta columns inside that
list, unsupported types, nested fields, the max-columns cap, and meta fields
disabled. One branch was not reachable from any existing case, because every
one of them supplies a schema: the path taken when the table schema is absent.

Added a case for it, pinning three outcomes that differ in ways worth fixing in
place:

- No explicit column list: the inner call returns nothing, so the caller is
  left with just the always-indexed meta columns. Col stats initialises rather
  than failing.
- An explicit column list: it throws IllegalArgumentException naming the
  missing schema, since the configured names cannot be resolved to field
  schemas without one, and indexing nothing would look like the config had
  been honoured.
- The same list while the table is initialising: the names are recorded without
  schemas, so col stats can be enabled before the first commit has produced a
  schema.

Test-only; no production code touched.

@hudi-agent hudi-agent 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.

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for the contribution! This is a test-only PR adding coverage for the schema-absent branch of HoodieTableMetadataUtil#getColumnsToIndexWithoutRequiredMetaFields — the no-column-list path (empty map, meta cols only), the explicit-list path (IllegalArgumentException), and the table-initializing path (names recorded without schemas). I traced each assertion against the production code and the expectations match the actual branch behavior; metaClient is re-initialized per test so the table config mutations in other tests don't leak in. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. Mostly clean; one nit on trimming the overly verbose javadoc comment.

cc @yihua

Lazy.eagerly(Option.of(schema)), true, V1).keySet()));
}

/**

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.

🤖 nit: this javadoc is quite dense/wordy for a test comment — might be worth trimming to a couple of short sentences stating what's being verified, rather than walking through the full reasoning.

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

@github-actions github-actions Bot added the size:S PR with lines of changes in (10, 100] label Sep 7, 2026
@codecov-commenter

codecov-commenter commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.34%. Comparing base (9903b6d) to head (295aa05).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19859      +/-   ##
============================================
- Coverage     78.35%   78.34%   -0.01%     
+ Complexity    33953    33945       -8     
============================================
  Files          2543     2543              
  Lines        141980   141980              
  Branches      17220    17220              
============================================
- Hits         111245   111234      -11     
- Misses        23039    23047       +8     
- Partials       7696     7699       +3     
Components Coverage Δ
hudi-common 83.75% <ø> (+<0.01%) ⬆️
hudi-client 83.22% <ø> (+0.01%) ⬆️
hudi-flink 85.52% <ø> (-0.07%) ⬇️
hudi-spark-datasource 73.26% <ø> (ø)
hudi-utilities 74.51% <ø> (-0.02%) ⬇️
hudi-cli 15.13% <ø> (ø)
hudi-hadoop 70.79% <ø> (-0.02%) ⬇️
hudi-sync 75.92% <ø> (-0.03%) ⬇️
hudi-io 80.02% <ø> (ø)
hudi-timeline-service 83.44% <ø> (ø)
hudi-cloud 65.81% <ø> (ø)
hudi-kafka-connect 53.20% <ø> (ø)
Flag Coverage Δ
common-and-other-modules 51.51% <ø> (+<0.01%) ⬆️
flink-integration-tests 48.83% <ø> (-0.04%) ⬇️
hadoop-mr-java-client 44.10% <ø> (+0.03%) ⬆️
integration-tests 13.50% <ø> (-0.01%) ⬇️
spark-client-hadoop-common 50.58% <ø> (-0.01%) ⬇️
spark-java-tests 52.26% <ø> (-0.02%) ⬇️
spark-scala-tests 47.00% <ø> (+0.01%) ⬆️
utilities 36.56% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hudi-bot

hudi-bot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

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

Labels

size:S PR with lines of changes in (10, 100]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revisit whether to add a test case for HoodieTableMetadataUtil#getColumnsToIndexWithoutRequiredMetaFields

4 participants