Codegass opened a new pull request, #16436:
URL: https://github.com/apache/druid/pull/16436
Fixes #12926.
### Description
This PR improves the test cases in `DecimalParquetInputTest` by replacing
the if-return blocks that check for unsupported parser types with
`assumeFalse`-- Assume API from Junit.
#### Replaced if-return blocks with assumeFalse
The existing test cases used if-return blocks like this to skip tests for
unsupported parser types:
```java
// parquet-avro does not correctly convert decimal types
if
(parserType.equals(ParquetExtensionsModule.PARQUET_AVRO_INPUT_PARSER_TYPE)) {
return;
}
```
This made the test logic implicit. It's preferable to make unsupported
preconditions explicit using JUnit's `assume` methods. The assume function,
introduced after JUnit 4, is designed to check for test pre-condition. As
[mentioned in the
document](https://junit.org/junit4/javadoc/4.12/org/junit/Assume.html):
> Assume functions is a set of methods useful for stating assumptions about
the conditions in which a test is meaningful. A failed assumption does not mean
the code is broken, but that the test provides no useful information.
I replaced the if-return blocks with equivalent `assumeFalse` assertions:
```java
// parquet-avro does not correctly convert decimal types
assumeFalse(parserType.equals(ParquetExtensionsModule.PARQUET_AVRO_INPUT_PARSER_TYPE));
```
A failed assumption will cause the test to be skipped, while still allowing
the test to run for supported parser types. This makes the preconditions
clearer without changing the test behavior.
**This refactoring resolves the silent quit issue by using the Assume API to
provide explicit output when tests are skipped.**
I applied this change to all three test cases in `DecimalParquetInputTest`:
- `testReadParquetDecimalFixedLen`
- `testReadParquetDecimali32`
- `testReadParquetDecimali64`
This is a straightforward refactoring that improves test readability without
altering functionality. No other code changes were made.
<hr>
This PR has:
- [x] been self-reviewed.
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [x] added comments explaining the "why" and the intent of the code
wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths,
ensuring the threshold for [code
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]