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

   **Search before asking**
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   **Paimon version**
   
   master @ ae135d59c9
   
   **Compute Engine**
   
   Spark 4.2.1 and 4.3.0. Spark 4.1 is not affected.
   
   **Minimal reproduce step**
   
   On an append table with a VARCHAR column (V2 write is the default):
   
   ```sql
   CREATE TABLE v (id INT, b VARCHAR(8));
   INSERT INTO v VALUES (1, 'aa'), (2, 'bb');
   UPDATE v SET id = 5 WHERE id = 2;
   -- java.lang.RuntimeException: Max iterations (100) reached for batch 
Resolution, please set 'spark.sql.analyzer.maxIterations' to a larger value.
   ```
   
   The same error comes from an UPDATE of the VARCHAR column, from `MERGE INTO 
v USING s ON v.id = s.id WHEN MATCHED THEN UPDATE SET b = s.b`, and from a 
MERGE with only `WHEN NOT MATCHED THEN INSERT *`. DELETE and INSERT work. On a 
primary-key table, and with `spark.paimon.write.use-v2-write=false`, all of 
these work.
   
   **What doesn't meet your expectations?**
   
   UPDATE and MERGE INTO should work as on Spark 4.1. An UPDATE that writes a 
value too long for the column should fail with the char/varchar length error.
   
   **Anything else?**
   
   From reading the code, the likely loop is `Spark42RowLevelCommandRewrite`. 
It aligns the assignments with `PaimonAssignmentUtils` and passes a copy to 
Spark's `RewriteUpdateTable` or `RewriteMergeIntoTable`, which fire only when 
`AssignmentUtils.aligned` holds. That check compares each value's type with the 
raw VARCHAR type in the target column's metadata, which Spark's own 
`ResolveRowLevelCommandAssignments` strips first and this rule keeps. If the 
rewrite does not fire, the rule, which does not check `aligned`, matches again 
on the next iteration. On Spark 4.1, `Spark41UpdateTableRewrite` and 
`Spark41MergeIntoRewrite` build the plan themselves.
   
   `MergeIntoTableTestBase` "merge into with varchar" and `UpdateTableTestBase` 
"overlong VARCHAR value throws" cover this, but the spark42 and spark43 CI 
lanes do not run them.
   
   **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