Skip to content

test(spark): tail-sweep coverage for low-coverage datasource classes - #19405

Open
yihua wants to merge 1 commit into
apache:masterfrom
yihua:test-spark-datasource-tail-sweep-2
Open

test(spark): tail-sweep coverage for low-coverage datasource classes#19405
yihua wants to merge 1 commit into
apache:masterfrom
yihua:test-spark-datasource-tail-sweep-2

Conversation

@yihua

@yihua yihua commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

Part 2 of the Spark-datasource small-class coverage tail-sweep (sibling to #19164). Several small classes in the Spark datasource had low unit-test coverage, with branches reached only indirectly, if at all. This adds focused, behavior-pinning unit tests for the genuinely uncovered ones.

Summary and Changelog

Adds unit coverage for three low-coverage classes. Every assertion pins exact output, so a wrong result would fail the test.

  • org.apache.spark.sql.BaseHoodieCatalystExpressionUtils (0 missed lines, but many uncovered branches): new TestCatalystExpressionOrderPreserving drives tryMatchAttributeOrderingPreservingTransformation across the whole OrderPreservingTransformation match. It asserts the exact source AttributeReference recovered for identity, arithmetic on either operand, unary math, string case, date add/sub, and order-preserving up-cast, and that non-order-preserving shapes (numeric-to-string cast, attribute-free arithmetic, a non-whitelisted Sqrt) do not match.
  • org.apache.spark.sql.avro.AvroUtils: new TestAvroUtils covers supportsDataType (atomic, struct, array, map, null supported; CalendarInterval and its wrappers unsupported) and the AvroSchemaHelper matching and validation paths previously exercised only through the Avro serializers: non-RECORD rejection, by-name vs positional field lookup, extra-Catalyst-field and extra-required-Avro-field validation (including the ignoreNullable and nullable-Avro-field skips), and the ambiguous case-insensitive by-name match. Each error case pins the raised IncompatibleSchemaException message.
  • org.apache.spark.sql.FileFormatUtilsForFileGroupReader: new TestFileFormatUtilsForFileGroupReader covers applyFiltersToPlan, pinning the Catalyst expression produced for each pushed-down data-source Filter (comparisons, null checks, In, string predicates, AlwaysTrue / AlwaysFalse, a nested and/or/not tree, and multi-filter And), and that an empty filter list returns the input plan unchanged.

Candidates verified and left out: VectorDistanceUtils is already exhaustively covered with exact-value assertions by TestHoodieVectorSearchFunction, so no new test was added. HiveSyncProcedure and HoodieNestedSchemaPruning need heavier end-to-end scaffolding (hive metastore, optimizer plan fixtures) and are deferred to a separate pass. No code was copied.

Impact

Test-only. No production code changes, no public API change, and no behavior change.

Risk Level

none

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

Add unit coverage for BaseHoodieCatalystExpressionUtils order-preserving
transformation matching, org.apache.spark.sql.avro.AvroUtils schema
matching and validation, and FileFormatUtilsForFileGroupReader filter
lowering. Each assertion pins the exact translated output.
@github-actions github-actions Bot added the size:L PR with lines of changes in (300, 1000] label Jul 29, 2026
@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.85%. Comparing base (8e18999) to head (e7b5d8d).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19405      +/-   ##
============================================
+ Coverage     72.49%   74.85%   +2.35%     
+ Complexity    32888    32341     -547     
============================================
  Files          2574     2574              
  Lines        149010   142978    -6032     
  Branches      18749    17571    -1178     
============================================
- Hits         108032   107032    -1000     
+ Misses        32513    27885    -4628     
+ Partials       8465     8061     -404     
Components Coverage Δ
hudi-common 82.24% <ø> (ø)
hudi-client 81.79% <ø> (+<0.01%) ⬆️
hudi-flink 78.63% <ø> (+0.01%) ⬆️
hudi-spark-datasource 68.52% <ø> (+9.84%) ⬆️
hudi-utilities 71.21% <ø> (-0.01%) ⬇️
hudi-cli 15.32% <ø> (ø)
hudi-hadoop 63.49% <ø> (ø)
hudi-sync 70.67% <ø> (+0.05%) ⬆️
hudi-io 79.57% <ø> (ø)
hudi-timeline-service 83.44% <ø> (ø)
hudi-cloud 64.00% <ø> (ø)
hudi-kafka-connect 53.20% <ø> (-0.77%) ⬇️
Flag Coverage Δ
common-and-other-modules 47.77% <ø> (+0.34%) ⬆️
flink-integration-tests 47.63% <ø> (-0.01%) ⬇️
hadoop-mr-java-client 43.38% <ø> (+<0.01%) ⬆️
integration-tests 13.63% <ø> (+0.10%) ⬆️
spark-client-hadoop-common 48.71% <ø> (ø)
spark-java-tests 51.41% <ø> (+2.01%) ⬆️
spark-scala-tests 46.09% <ø> (+1.44%) ⬆️
utilities 36.65% <ø> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 34 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

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

@yihua
yihua marked this pull request as ready for review July 30, 2026 19:30

@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 working on this! This PR adds behavior-pinning unit tests for three low-coverage Spark-datasource classes: the order-preserving transformation matcher in BaseHoodieCatalystExpressionUtils, AvroUtils/AvroSchemaHelper, and FileFormatUtilsForFileGroupReader.applyFiltersToPlan. I traced each assertion against the actual source implementations (including isCastPreservingOrdering, the OrderPreservingTransformation extractor cases, the translate/reduceLeft(And) filter lowering, and the Avro schema-matching/validation error messages) and every expected value lines up with real behavior. 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. One minor naming nit in TestAvroUtils; the other two files are clean.

cc @yihua

| {"name":"id","type":"int"},
| {"name":"ghost","type":["null","int"]}
|]}""".stripMargin)
val helper2 = new AvroUtils.AvroSchemaHelper(

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: helper2 loses the context that this helper covers the optional-ghost case — could you rename it to helperWithOptionalGhost to mirror avroWithOptionalGhost and make the two scenarios easier to scan at a glance?

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

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

Labels

size:L PR with lines of changes in (300, 1000]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants