FearfulTomcat27 opened a new pull request, #17368:
URL: https://github.com/apache/iotdb/pull/17368

   This pull request enhances the robustness and correctness of the 
`approx_percentile` aggregation function, particularly when using weighted 
percentiles. It introduces stricter type checks and runtime validation for the 
weight parameter, improves error handling, and adds corresponding integration 
tests to ensure the expected behavior.
   
   **Validation and Error Handling Improvements:**
   
   * Added runtime checks in `ApproxPercentileWithWeightAccumulator` to ensure 
that weights are not null and are greater than or equal to 1; throws a 
`SemanticException` if these conditions are not met. 
[[1]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R37-R42)
 
[[2]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R52-R57)
 
[[3]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R74-R79)
 
[[4]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R89-R94)
 
[[5]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R111-R116)
 
[[6]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R126-R131)
 
[[7]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R148-R153)
 
[[8]](diffhunk://#diff-3f65fbccaf8f50bba605b98719c0b7fe6452737de53ad6659beeaba25137d3e7R163-R168)
   * Improved type validation for the `approx_percentile` function in 
`TableMetadataImpl` to ensure the percentage parameter is always decimal and 
the weight parameter (if present) is either `INT32` or unknown; throws clear 
semantic exceptions for unsupported types.
   
   **Testing Enhancements:**
   
   * Added integration tests in `IoTDBTableAggregationIT.java` to verify 
correct handling of null weights and invalid weight values in 
`approx_percentile`, including checks for proper error messages when weights 
are negative or of unsupported types. 
[[1]](diffhunk://#diff-578acadfb2cdda00dea117c21562d236f37803b79f9c54c60446ace272edb942R4355-R4360)
 
[[2]](diffhunk://#diff-578acadfb2cdda00dea117c21562d236f37803b79f9c54c60446ace272edb942R4441-R4448)
   
   **Dependency and Import Updates:**
   
   * Added import for `SemanticException` in 
`ApproxPercentileWithWeightAccumulator.java` to support new exception handling 
logic.


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

Reply via email to