danzhewuju opened a new issue, #11416:
URL: https://github.com/apache/paimon/issues/11416

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   
   ### Paimon version
   
   Paimon 2.2-SNAPSHOT
   
   ### Compute Engine
   
   Spark 3.5
   
   ### Minimal reproduce step
   
   
   1. Create a table with `id INT` as the primary key, `payload ROW<old_status 
INT, message INT>`, and a top-level `status INT`. Set `bucket=1`, 
`merge-engine=aggregation`, and `fields.payload.aggregate-function=first_value`.
   2. Write and commit `(1, (11, 1000), 100)`.
   3. Call `Catalog.alterTable` with `SchemaChange.renameColumn(new String[] 
{"payload", "old_status"}, "status")`.
   4. Reload the table, write and commit `(1, (22, 2000), 200)`, then read the 
merged row for `id = 1`.
   
   ### What doesn't meet your expectations?
   
   Expected `(1, (11, 1000), 200)`. The `payload` column should keep its first 
value, and the top-level `status` should take its latest non-null value.
   
   Actual `(1, (22, 2000), 100)`. The rename succeeds but moves 
`fields.payload.aggregate-function=first_value` to 
`fields.status.aggregate-function`, changing how both columns are merged.
   
   On a fresh table, changing the rename target to `status_test` also 
reproduces the bug. The DDL fails with `Field status_test can not be found in 
table schema.` because the rewritten option references a missing top-level 
column.
   
   
   ### Anything else?
   
   We encountered this issue in production while using Spark SQL to rename a 
nested field in a Paimon primary-key aggregation table. I reproduced it locally 
with Spark 3.5.9 . When the new field name matches an existing top-level 
column, the `ALTER TABLE` succeeds, but subsequent reads can silently return 
incorrect aggregation results.
   
   This is the same option-rewrite bug reported in #10277. The reproduction 
above shows its impact on primary-key aggregation tables.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


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