leekeiabstraction commented on code in PR #2042:
URL: https://github.com/apache/fluss/pull/2042#discussion_r2568431858


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/sink/FlussSinkBuilder.java:
##########
@@ -193,4 +219,48 @@ private void validateConfiguration() {
         checkNotNull(tableName, "Table name is required but not provided.");
         checkArgument(!tableName.isEmpty(), "Table name cannot be empty.");
     }
+
+    // -------------- Test-visible helper methods --------------
+    /**
+     * Computes target column indexes for partial updates. If {@code 
specifiedColumns} is null or
+     * empty, returns null indicating full update. Validates that all primary 
key columns are
+     * included in the specified columns.
+     *
+     * @param allFieldNames the list of all field names in table row type order
+     * @param primaryKeyNames the list of primary key column names
+     * @param specifiedColumns the optional list of columns specified for 
partial update
+     * @return the indexes into {@code allFieldNames} corresponding to {@code 
specifiedColumns}, or
+     *     null for full update
+     * @throws IllegalArgumentException if a specified column does not exist 
or primary key coverage
+     *     is incomplete
+     */
+    static int[] computeTargetColumnIndexes(
+            List<String> allFieldNames,
+            List<String> primaryKeyNames,
+            List<String> specifiedColumns) {
+        if (specifiedColumns == null || specifiedColumns.isEmpty()) {
+            return null; // full update
+        }
+
+        // Map specified column names to indexes
+        int[] indexes = new int[specifiedColumns.size()];
+        for (int i = 0; i < specifiedColumns.size(); i++) {
+            String col = specifiedColumns.get(i);
+            int idx = allFieldNames.indexOf(col);
+            checkArgument(
+                    idx >= 0, "Column '%s' not found in table schema: %s", 
col, allFieldNames);

Review Comment:
   nit: Slightly more context can be provided in the message e.g. "Partial 
update column '%s' not found in table schema: %s'



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