Skip to content

[MINOR][SQL][TEST] Make test assertions protected functions for downstream reusability - #58878

Open
pedrumj2 wants to merge 1 commit into
apache:masterfrom
pedrumj2:test-assertion-seams
Open

pedrumj2 wants to merge 1 commit into
apache:masterfrom
pedrumj2:test-assertion-seams

Conversation

@pedrumj2

Copy link
Copy Markdown

What changes were proposed in this pull request?

Refactors test assertions into protected methods.

Why are the changes needed?

Some downstream consumers such as Apache Gluten reuse these test to ensure spark functionality is tested on changes. In apache/gluten#12976 after the velox map_from_arrays operator was enabled, the Exception asserted in some spark tests changed (while core logic remained the same). This required either:

  • Disabling the test --> losing test coverage
  • Copying the entire test --> Duplicating code

By making the assertion protected, downstream consumers can override the limited lines without having to copy the entire test body allowing better re-usability downstream.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

build/mvn -pl sql/core -am test -Dtest=none -DfailIfNoTests=false \
  -DwildcardSuites=org.apache.spark.sql.RuntimeNullChecksV2Writes,org.apache.spark.sql.DataFrameFunctionsSuite

RuntimeNullChecksV2Writes:
...
DataFrameFunctionsSuite:
...
Run completed in 50 seconds, 854 milliseconds.
Total number of tests run: 176
Suites: completed 4, aborted 0
Tests: succeeded 176, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
[INFO] BUILD SUCCESS

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Co-authored with Claude Code (Opus 5)

… overridable

### What changes were proposed in this pull request?

Refactors test assertions into protected methods.

### Why are the changes needed?

Apache Gluten reuses `RuntimeNullChecksV2Writes` and `DataFrameFunctionsSuite` against its Velox backend. As an example in apache/gluten#12976, after the map_from_arrays operator was enabled, it changed the exception thrown in these tests and required copying over the entire test only to override the exception type in the assertion.

By making the assertion protected downstream consumers can override the limited lines without having to copy the entire test body allowing better re-usability downstream.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

```
build/mvn -pl sql/core -am test -Dtest=none -DfailIfNoTests=false \
  -DwildcardSuites=org.apache.spark.sql.RuntimeNullChecksV2Writes,org.apache.spark.sql.DataFrameFunctionsSuite

RuntimeNullChecksV2Writes:
...
DataFrameFunctionsSuite:
...
Run completed in 50 seconds, 854 milliseconds.
Total number of tests run: 176
Suites: completed 4, aborted 0
Tests: succeeded 176, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
[INFO] BUILD SUCCESS
```

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Co-authored with Claude Code (Opus 5)
@pedrumj2 pedrumj2 changed the title [MINOR][SQL][TEST] Make the not-null and null-map-key test assertions… [MINOR][SQL][TEST] Make test assertions protected functions for downstream reusability Sep 17, 2026
@pedrumj2

Copy link
Copy Markdown
Author

CC @wangyum @HyukjinKwon I saw you previously helped review a similar PR: #52996

Wondering if you could help take a look here?

@HyukjinKwon I did see your comment on that PR:

I think we shouldn't really change the test code for other projects to use .. but if this is the only one, one time thing should be fine.

What would be the recommended approach for spark plugin developers to ensure they haven't broken spark functionality? Currently Gluten relies on running these tests to ensure changes don't break core Spark functionality.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant