LuciferYang opened a new issue, #11401: URL: https://github.com/apache/paimon/issues/11401
**Search before asking** - [x] I searched in the [issues](https://github.com/apache/paimon/issues) and found nothing similar. **Paimon version** master @ 6a9e258775 **Compute Engine** Spark 4.1.4, 4.2.1 and 4.3.0. Spark 3.x not checked. **Minimal reproduce step** ```sql SET spark.paimon.write.merge-schema=true; CREATE TABLE t (id INT, v VARCHAR(4)); INSERT INTO t VALUES (1, 'a'), (2, 'b'); CREATE TABLE s (id INT, v VARCHAR(4), c INT); INSERT INTO s VALUES (1, 'x', 7), (3, 'z', 9); MERGE INTO t USING s ON t.id = s.id WHEN MATCHED THEN UPDATE SET * WHEN NOT MATCHED THEN INSERT *; ``` The MERGE fails with `[INTERNAL_ERROR] Logical plan should not have output of char/varchar type when spark.sql.preserveCharVarcharTypeInfo is false`, naming the target relation with the evolved columns `id, v, c`, and the table is unchanged. It fails the same way with V1 and V2 write, and on a primary-key table. With `v STRING` the same MERGE adds column `c` and merges the rows. **What doesn't meet your expectations?** The MERGE should add column `c` and merge the rows, as it does when `v` is a STRING column. **Anything else?** `MergeSchemaEvolutionHelper.buildEvolvedOutput` rebuilds the target relation's output from `SparkTypeUtils.fromPaimonRowType`, which maps `VARCHAR(4)` to Spark's `VarcharType(4)`. Spark's `CheckAnalysis` rejects a leaf node whose output has a char/varchar type unless `spark.sql.preserveCharVarcharTypeInfo` is set. `DataSourceV2Relation.create` replaces char/varchar with string when it builds a relation from a table; the evolved output does not. Found while fixing #11399. **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]
