raminqaf commented on code in PR #28025:
URL: https://github.com/apache/flink/pull/28025#discussion_r3201871357
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/FromChangelogTypeStrategy.java:
##########
@@ -273,23 +276,26 @@ private static Optional<List<DataType>>
validateErrorHandling(
return Optional.empty();
}
- private static String resolveOpColumnName(final CallContext callContext) {
- return callContext
- .getArgumentValue(ARG_OP, ColumnList.class)
- .filter(cl -> !cl.getNames().isEmpty())
- .map(cl -> cl.getNames().get(0))
- .orElse(DEFAULT_OP_COLUMN_NAME);
- }
-
private static List<Field> buildOutputFields(
final TableSemantics tableSemantics, final String opColumnName) {
final List<Field> inputFields =
DataType.getFields(tableSemantics.dataType());
-
- // Exclude the op column (becomes RowKind), keep all other columns
- return inputFields.stream()
- .filter(f -> !f.getName().equals(opColumnName))
+ return Arrays.stream(
+ ChangelogTypeStrategyUtils.computeOutputIndices(
+ tableSemantics, opColumnName))
+ .mapToObj(inputFields::get)
.collect(Collectors.toList());
}
+ /**
+ * Returns the index of the column matching {@code opColumnName} within
the given input fields,
+ * or empty if no field matches.
+ */
+ private static OptionalInt resolveOpColumnIndex(
+ final List<Field> inputFields, final String opColumnName) {
+ return IntStream.range(0, inputFields.size())
+ .filter(i -> inputFields.get(i).getName().equals(opColumnName))
+ .findFirst();
+ }
+
Review Comment:
Nice catch. Applied
--
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]