Codegass opened a new issue, #12926:
URL: https://github.com/apache/druid/issues/12926

   <!--When I am running the test for 
[testReadParquetDecimali32](https://github.com/apache/druid/blob/fbd1a07e7e912a35e02ce166e0d5ad76fa64013d/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/DecimalParquetInputTest.java#L72-L87),
 I noticed that the test case is testing the `getAllRows()` function with the 
specific `transformHadoopDruidIndexerConfig`, but it is using the `if` 
condition to check the pre-condition of the test case.
   -->
   I would like to propose a minor improvement that could apply to all the test 
cases in DecimalParquetInputTest.  I will use 
[testReadParquetDecimali32](https://github.com/apache/druid/blob/fbd1a07e7e912a35e02ce166e0d5ad76fa64013d/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/DecimalParquetInputTest.java#L72-L87)
 as an example.
   
   ```java
   // parquet-avro does not correctly convert decimal types
       if 
(parserType.equals(ParquetExtensionsModule.PARQUET_AVRO_INPUT_PARSER_TYPE)) {
         return;
       }
   ```
   
   On line 
[75-76](https://github.com/apache/druid/blob/fbd1a07e7e912a35e02ce166e0d5ad76fa64013d/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/DecimalParquetInputTest.java#L75-L76),
 it uses an `if` condition to check if a precondition is violated, i.e. 
“parquet-avro does not correctly convert decimal types” If so, the test case 
return silently without any further execution. There could be two drawbacks to 
this: 
   1. the if and return make the logic of the test case implicit
   2. It may still be worthwhile to execute the test case and see what happens.
   
   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.
   
   The if block could be replaced by After refactoring:
   
   ```java
   
assumeFalse(parserType.equals(ParquetExtensionsModule.PARQUET_AVRO_INPUT_PARSER_TYPE));
   ```
   
   This makes the logic more explicit. Although this is a minor change, it can 
be applied to all three test cases in this `DecimalParquetInputTest`.
   


-- 
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]

Reply via email to