raminqaf commented on code in PR #28164:
URL: https://github.com/apache/flink/pull/28164#discussion_r3259869929
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/FromChangelogTypeStrategy.java:
##########
@@ -200,22 +247,47 @@ private static Optional<List<DataType>> validateOpMapping(
if (validationError.isPresent()) {
return validationError;
}
-
- final boolean hasUpdateBefore =
- mapping.values().stream().anyMatch(v ->
UPDATE_BEFORE.equals(v.trim()));
- final boolean hasUpdateAfter =
- mapping.values().stream().anyMatch(v ->
UPDATE_AFTER.equals(v.trim()));
- if (hasUpdateAfter && !hasUpdateBefore) {
- return callContext.fail(
- throwOnFailure,
- "The 'op_mapping' must include UPDATE_BEFORE for
retract mode. "
- + "Upsert mode (without UPDATE_BEFORE) is not
supported "
- + "in this version.");
+ final Optional<List<DataType>> upsertKeyError =
+ validateUpsertRequiresPartitionBy(callContext, mapping,
throwOnFailure);
+ if (upsertKeyError.isPresent()) {
+ return upsertKeyError;
}
}
return Optional.empty();
}
+ /**
+ * An {@code op_mapping} that produces {@code UPDATE_AFTER} without {@code
UPDATE_BEFORE}
+ * describes an upsert changelog. Upsert mode requires a key, so the input
table must use set
+ * semantics via {@code PARTITION BY}.
+ */
+ private static Optional<List<DataType>> validateUpsertRequiresPartitionBy(
+ final CallContext callContext,
+ final Map<String, String> mapping,
+ final boolean throwOnFailure) {
+ final boolean hasUpdateAfter =
+ mapping.values().stream().anyMatch(v ->
UPDATE_AFTER.equals(v.trim()));
Review Comment:
https://github.com/apache/flink/pull/28164#discussion_r3259867576
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/FromChangelogTypeStrategy.java:
##########
@@ -200,22 +247,47 @@ private static Optional<List<DataType>> validateOpMapping(
if (validationError.isPresent()) {
return validationError;
}
-
- final boolean hasUpdateBefore =
- mapping.values().stream().anyMatch(v ->
UPDATE_BEFORE.equals(v.trim()));
- final boolean hasUpdateAfter =
- mapping.values().stream().anyMatch(v ->
UPDATE_AFTER.equals(v.trim()));
- if (hasUpdateAfter && !hasUpdateBefore) {
- return callContext.fail(
- throwOnFailure,
- "The 'op_mapping' must include UPDATE_BEFORE for
retract mode. "
- + "Upsert mode (without UPDATE_BEFORE) is not
supported "
- + "in this version.");
+ final Optional<List<DataType>> upsertKeyError =
+ validateUpsertRequiresPartitionBy(callContext, mapping,
throwOnFailure);
+ if (upsertKeyError.isPresent()) {
+ return upsertKeyError;
}
}
return Optional.empty();
}
+ /**
+ * An {@code op_mapping} that produces {@code UPDATE_AFTER} without {@code
UPDATE_BEFORE}
+ * describes an upsert changelog. Upsert mode requires a key, so the input
table must use set
+ * semantics via {@code PARTITION BY}.
+ */
+ private static Optional<List<DataType>> validateUpsertRequiresPartitionBy(
Review Comment:
Addressed
--
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]