ZZZxDong commented on code in PR #10983:
URL: https://github.com/apache/paimon/pull/10983#discussion_r4489704960


##########
paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java:
##########
@@ -1378,19 +1380,61 @@ private static void 
validateMergeFunctionFactory(TableSchema schema) {
             default:
         }
 
-        for (int i = 0; i < schema.logicalRowType().getFieldNames().size(); 
i++) {
-            String fieldName = schema.logicalRowType().getFieldNames().get(i);
-            String aggFuncName = options.fieldAggFunc(fieldName);
-            aggFuncName = aggFuncName == null ? options.fieldsDefaultFunc() : 
aggFuncName;
-            if (aggFuncName != null) {
-                FactoryUtil.discoverFactory(
-                        FieldAggregator.class.getClassLoader(),
-                        FieldAggregatorFactory.class,
-                        aggFuncName);
+        RowType rowType = schema.logicalRowType();
+        List<String> primaryKeys = schema.primaryKeys();
+        List<String> sequenceFields = options.sequenceField();
+        List<String> orderingFields = new ArrayList<>();
+        List<String> protectedFields = new ArrayList<>();
+        for (Map.Entry<String, String> entry : options.toMap().entrySet()) {
+            if (isSequenceGroupOption(entry.getKey())) {
+                
orderingFields.addAll(sequenceGroupOrderingFields(entry.getKey()));
+                
protectedFields.addAll(sequenceGroupProtectedFields(entry.getValue()));
+            }
+        }
+
+        for (int i = 0; i < rowType.getFieldNames().size(); i++) {
+            String fieldName = rowType.getFieldNames().get(i);
+            String aggFuncName =
+                    resolveAggFuncName(
+                            options,
+                            fieldName,
+                            primaryKeys,
+                            sequenceFields,
+                            orderingFields,
+                            protectedFields);
+            if (aggFuncName == null) {
+                continue;
             }
+            // Instantiate once so that type-incompatible configurations (e.g. 
'collect' on a
+            // non-array column) are rejected at DDL time instead of at 
read/write time.
+            FieldAggregatorFactory.create(

Review Comment:
   Applied both points in bd984a23: the eager type check now runs only from 
`FileSystemSchemaManager.commit()` so stored schemas keep the previous 
projection-scoped read behavior, and 
`TimeTravelSchemaEvolutionTest#testTimeTravelProjectionWithEvolvedAggregateFunction`
 covers the `VARCHAR(16)` → `STRING` + `listagg` scenario you described 
(verified it fails without the change).
   



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