NestDream opened a new pull request, #3629:
URL: https://github.com/apache/fluss/pull/3629

   - [ ] No generative AI tools used
   - [x] Yes (please specify the tool below)
   
   Generated-by: Claude Code (Fable 5) following [the 
guidelines](https://github.com/apache/fluss/blob/main/AGENTS.md)
   
   ### Purpose
   
   Linked issue: close #3628
   
   `Schema.PrimaryKey.hashCode()` folds in `super.hashCode()` (the `Object` 
per-instance hash) while `equals()` compares only `columnNames`, so two 
value-equal primary keys return different hash codes. This violates the 
`Object.equals`/`hashCode` contract and propagates through `Schema.hashCode()` 
and the public `TableDescriptor`, so an equal schema/table descriptor can be 
missing from a `HashSet`/`HashMap` (e.g. after a `toJsonBytes`/`fromJsonBytes` 
round-trip). Standalone reproduction against the released 0.9.1-incubating 
artifact: https://github.com/NestDream/fluss-pk-hashcode-demo
   
   ### Brief change log
   
   - `Schema.PrimaryKey.hashCode()`: `Objects.hash(super.hashCode(), 
columnNames)` → `Objects.hash(columnNames)`, matching the field `equals()` 
compares and the value-based hashing already used by `Schema` and `Column`.
   
   ### Tests
   
   - `TableSchemaTest#testPrimaryKeySchemaSurvivesJsonRoundTripAsHashKey` 
(unit): round-trips a primary-key schema via `toJsonBytes`/`fromJsonBytes` and 
asserts the reloaded schema hashes equally and is found in a `HashSet<Schema>`; 
also asserts two primary keys with equal columns but different constraint names 
are equal and hash-equal. Fails before the fix, passes after.
   - `FlussAdminITCase#testPrimaryKeySchemaReadBackIsUsableAsHashKey` 
(end-to-end): creates a primary-key table via `Admin.createTable`, reads the 
schema back via `Admin.getTableSchema`, and asserts it is usable as a hash key. 
Fails before the fix, passes after.
   - Existing `TableSchemaTest`, `TableDescriptorTest`, `SchemaJsonSerdeTest` 
continue to pass (`mvn verify -pl fluss-common`: 1684 tests, 0 failures).
   
   ### API and Format
   
   No public API or storage format change. `hashCode()` is never persisted or 
transmitted (`SchemaJsonSerde` writes explicit fields; on-the-wire schema 
identity is the separate `schemaId`).
   
   ### Documentation
   
   No documentation change; behavior-only fix.
   


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