chenjian2664 commented on code in PR #11245:
URL: https://github.com/apache/paimon/pull/11245#discussion_r4650171099
##########
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:
Thanks, fixed. `vector-field` is now stored as the column names it resolves
to when the table is created or altered, so `'v1, v2'` is saved as `'v1,v2'`.
Values that already match columns exactly, such as existing tables with a ` v2`
column, are kept as written. A column added later therefore can't change which
columns the option refers to.
`VectorStoreTableTest#testVectorFieldWithSpacesAfterAddingSimilarColumn`
creates a table with separator whitespace and then adds a similarly named
column.
--
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]