Admaing opened a new pull request, #30250: URL: https://github.com/apache/flink/pull/30250
## What is the purpose of the change `CEIL` and `FLOOR` over a `DECIMAL(p, s)` column return `DECIMAL(p, 0)`, but `DecimalDataUtils.ceil` and `DecimalDataUtils.floor` built the result using the precision of the scaled `BigDecimal` instead. When the rounded value has fewer digits than the declared precision (for example, `1.5` in `DECIMAL(2, 1)` produces `1`), `AbstractBinaryWriter.writeDecimal` fails its `value.precision() == precision` assertion when assertions are enabled. This change preserves the input decimal precision, which matches the inferred `DECIMAL(p, 0)` result type, and adds a regression test for both functions. ## Brief change log - Use `decimal.precision()` instead of `bd.precision()` for the results of `DecimalDataUtils.ceil` and `DecimalDataUtils.floor`. - Add `CEIL` and `FLOOR` cases over `DECIMAL(2, 1)` to `MathFunctionsITCase`, checking the runtime result type `DECIMAL(2, 0)` through both the Table API and SQL. ## Verifying this change This change added tests and can be verified as follows: - `MathFunctionsITCase`: 83 tests passed. Without the fix, the new cases produce six `AssertionError`s from `AbstractBinaryWriter.writeDecimal`. - `DecimalDataTest`: 660 tests passed. - `./mvnw -pl flink-table/flink-table-runtime,flink-table/flink-table-planner spotless:apply` passed. - `./mvnw -pl flink-table/flink-table-runtime,flink-table/flink-table-planner checkstyle:check -T1C` passed with zero violations. ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): no - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no - The serializers: no - The runtime per-record code paths (performance sensitive): no - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no - The S3 file system connector: no ## Documentation - Does this pull request introduce a new feature? no - If yes, how is the feature documented? not applicable --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Codex CLI 0.169.0-alpha.11.1 -- 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]
