You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2026/08/26 17:09:05 UTC
[PR] [#12657] fix(common): Validate statistic entries in PartitionStatisticsUpdateDTO [gravitino]
LuciferYang opened a new pull request, #12658:
URL: https://github.com/apache/gravitino/pull/12658
### What changes were proposed in this pull request?
`PartitionStatisticsUpdateDTO.validate()` now walks the `statistics` map and applies the same two per-entry checks, with the same messages, as `StatisticsUpdateRequest.validate()`: the statistic name must not be blank, and the statistic value must not be null.
### Why are the changes needed?
The two statistics update endpoints disagreed on the same request body. `PUT .../statistics/partitions` with `{"custom-k": null}` returned 200 and the null reached the dispatcher, while `PUT .../statistics` with the equivalent body returned 400.
The deserializer cannot catch this: Jackson's `MapDeserializer` does not invoke a `contentUsing` deserializer for a `VALUE_NULL` content token, so the null guard in `JsonUtils.getStatisticValue` never sees a top-level null and `validate()` is the only place that can reject one.
The blank-name check matters on a second path too. The server rejects a non-`custom-` prefixed name in `StatisticOperations`, but `PartitionStatisticsUpdateDTO.of()` is what `clients/client-java` calls when building a request, and there the check runs before anything is sent.
Fix: #12657
### Does this PR introduce _any_ user-facing change?
Yes. `PUT /metalakes/{metalake}/objects/{type}/{fullName}/statistics/partitions` now returns 400 for a null statistic value or a blank statistic name, matching the object-level endpoint. It previously accepted both. Java callers going through `PartitionStatisticsUpdateDTO.of()` get an `IllegalArgumentException` for the same inputs.
### How was this patch tested?
`TestStatisticOperations.testUpdatePartitionStatisticsWithNullStatisticValue` drives the endpoint with a raw JSON body and asserts 400, `ILLEGAL_ARGUMENTS_CODE`, and an error message naming the offending statistic. Against the pre-fix code it fails with `expected: <400> but was: <200>`. The body is sent as a raw string rather than a serialized DTO on purpose: `of()` now rejects it, and serializing a map would risk the client mapper dropping the null entry, which would let the test pass on a different validation error.
New `TestPartitionStatisticsUpdateDTO` covers the DTO, which had no tests: a null value is rejected with the statistic named, a blank name is rejected, a valid map is accepted, and the real request body deserializes into a map holding a null value before `validate()` rejects it. That last assertion pins the Jackson behaviour the fix depends on; its first half passes with or without the fix. All three rejection cases were confirmed to fail against the pre-fix code.
```
./gradlew :common:test :server:test :core:test :clients:client-java:test :common:javadoc :common:spotlessCheck :server:spotlessCheck -PskipITs
```
passes.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12657] fix(common): Validate statistic entries in PartitionStatisticsUpdateDTO [gravitino]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #12658:
URL: https://github.com/apache/gravitino/pull/12658#issuecomment-5435503367
Thank you @jerryshao and @roryqi
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12657] fix(common): Validate statistic entries in PartitionStatisticsUpdateDTO [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi merged PR #12658:
URL: https://github.com/apache/gravitino/pull/12658
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12657] fix(common): Validate statistic entries in PartitionStatisticsUpdateDTO [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on PR #12658:
URL: https://github.com/apache/gravitino/pull/12658#issuecomment-5433419869
> @roryqi can you please help to review?
I will.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12657] fix(common): Validate statistic entries in PartitionStatisticsUpdateDTO [gravitino]
Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on PR #12658:
URL: https://github.com/apache/gravitino/pull/12658#issuecomment-5433741759
Thank you @jerryshao and @roryqi
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12657] fix(common): Validate statistic entries in PartitionStatisticsUpdateDTO [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12658:
URL: https://github.com/apache/gravitino/pull/12658#issuecomment-5429590118
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|68.29% **`+0.01%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|91.3%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|19.74%|:red_circle:|
|api|52.87%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|authorization-ranger|4.38%|:red_circle:|
|aws|53.54%|:green_circle:|
|azure|32.1%|:red_circle:|
|catalog-common|9.9%|:red_circle:|
|catalog-fileset|80.17%|:green_circle:|
|catalog-glue|69.24%|:green_circle:|
|catalog-hive|82.96%|:green_circle:|
|catalog-jdbc-common|45.69%|:green_circle:|
|catalog-jdbc-doris|82.44%|:green_circle:|
|catalog-jdbc-mysql|79.33%|:green_circle:|
|catalog-jdbc-postgresql|83.39%|:green_circle:|
|catalog-jdbc-starrocks|79.16%|:green_circle:|
|catalog-kafka|76.99%|:green_circle:|
|catalog-lakehouse-generic|60.55%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.86%|:green_circle:|
|catalog-lakehouse-paimon|84.26%|:green_circle:|
|catalog-model|77.99%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.16%|:green_circle:|
|common|52.69% **`+0.13%`**|:green_circle:|
|core|83.63%|:green_circle:|
|filesystem-hadoop3|76.45%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|50.29%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|32.2%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|17.84%|:red_circle:|
|hive-metastore-common|53.4%|:green_circle:|
|iceberg-aliyun-bundle|0.0%|:red_circle:|
|iceberg-common|64.75%|:green_circle:|
|iceberg-rest-server|75.31%|:green_circle:|
|idp-basic|85.98%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|62.92%|:green_circle:|
|lance-common|32.72%|:red_circle:|
|lance-rest-server|64.78%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.17%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|88.04%|:green_circle:|
|server-common|79.6%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|48.92%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|47.41%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|common|[PartitionStatisticsUpdateDTO.java](https://github.com/LuciferYang/gravitino/blob/e4aa0245f7da8ccf1eeb4f70037bf701e0e8deb5/common/src/main/java/org/apache/gravitino/dto/stats/PartitionStatisticsUpdateDTO.java)|91.3%|:green_circle:|
</details>
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12657] fix(common): Validate statistic entries in PartitionStatisticsUpdateDTO [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao commented on PR #12658:
URL: https://github.com/apache/gravitino/pull/12658#issuecomment-5433388145
@roryqi can you please help to review?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org