JingsongLi commented on code in PR #11245:
URL: https://github.com/apache/paimon/pull/11245#discussion_r4643506178


##########
paimon-api/src/main/java/org/apache/paimon/CoreOptions.java:
##########
@@ -5151,6 +5163,35 @@ public static Set<String> vectorField(Map<String, 
String> options) {
         return 
Arrays.stream(vectorFields.trim().split(",")).collect(Collectors.toSet());
     }
 
+    /** Resolves {@link #VECTOR_FIELD} against the given field names. */
+    public Set<String> vectorField(List<String> fieldNames) {
+        return resolveVectorFields(options.get(VECTOR_FIELD), fieldNames);
+    }
+
+    /** Resolves {@link #VECTOR_FIELD} against the given field names. */
+    public static Set<String> vectorField(Map<String, String> options, 
List<String> fieldNames) {
+        return resolveVectorFields(options.get(VECTOR_FIELD.key()), 
fieldNames);
+    }
+
+    /**
+     * Uses a name exactly as written when a field has that name, which keeps 
existing tables with
+     * spaces in field names working, and its trimmed form otherwise.
+     */
+    private static Set<String> resolveVectorFields(
+            @Nullable String vectorFields, List<String> fieldNames) {
+        Set<String> fields = new HashSet<>();
+        if (vectorFields == null) {
+            return fields;
+        }
+        for (String field : vectorFields.trim().split(",")) {
+            String name = fieldNames.contains(field) ? field : field.trim();

Review Comment:
   **[P2] Persist the resolved column names so a later ADD COLUMN cannot 
reinterpret them**
   
   On Spark 3.5 I created and wrote a Data Evolution table with two vector 
columns `v1` and `v2` using `'vector-field'='v1, v2'`. Adding a separate quoted 
string column named ` v2` then fails with `Field name[ v2] is configured as 
vector-field so the type must be vector`. The same ALTER succeeds with 
`'vector-field'='v1,v2'`. The fallback is resolved against the candidate schema 
on each validation, so the same persisted option starts pointing to a different 
column. Store the canonical names when accepting the option on CREATE or SET, 
preserving exact matches against the schema at that point. Please cover 
creating with separator whitespace and adding a similarly named column later.



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