gustavodemorais commented on code in PR #28199:
URL: https://github.com/apache/flink/pull/28199#discussion_r3274136760
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TraitCondition.java:
##########
@@ -68,4 +70,30 @@ static TraitCondition not(final TraitCondition condition) {
return new BuiltInCondition(
BuiltInCondition.Kind.NOT, List.of(condition), ctx ->
!condition.test(ctx));
}
+
+ /**
+ * True when the named {@code MAP<STRING, STRING>} scalar argument has a
key that, after
+ * splitting on comma and trimming each part, equals {@code key}. Returns
true when the argument
+ * is omitted, on the assumption that an absent argument means the
function falls back to a
+ * default that includes all keys.
+ */
+ @SuppressWarnings("rawtypes")
+ static TraitCondition mapArgIncludesKey(final String argName, final String
key) {
+ return new BuiltInCondition(
+ BuiltInCondition.Kind.MAP_ARG_INCLUDES_KEY,
+ List.of(argName, key),
+ ctx ->
+ ctx.getScalarArgument(argName, Map.class)
+ .map(map -> mapKeysContain(map, key))
+ .orElse(true));
+ }
Review Comment:
I liked the idea! I had to spend some time into this since this is a new API
we just added that will be used by other PTF users. But we were already
expecting to add more generic methods to it as we go.
For this case, I had to add add or, argIsPresent and argMatches because
mapArgIncludesKey had multiple checks which we want to make generic. All pieces
all now reusable and like how it looks like now. I kept the mapArgIncludesKey
using the argMatches under the hood for readability
--
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]