gustavodemorais commented on code in PR #27886:
URL: https://github.com/apache/flink/pull/27886#discussion_r3117009183


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/StaticArgument.java:
##########
@@ -196,6 +240,68 @@ public boolean is(StaticArgumentTrait trait) {
         return traits.contains(trait);
     }
 
+    /**
+     * Context-aware trait check. Evaluates conditional trait rules against 
the given context to
+     * determine the effective traits.
+     */
+    public boolean is(StaticArgumentTrait trait, TraitContext ctx) {
+        return resolveTraits(ctx).contains(trait);
+    }
+
+    /**
+     * Returns a new {@link StaticArgument} with an additional conditional 
trait rule. The trait is
+     * added to the effective trait set when the condition evaluates to {@code 
true} at planning
+     * time.
+     *
+     * <p>Example:
+     *
+     * <pre>{@code
+     * StaticArgument.table("input", Row.class, false, EnumSet.of(TABLE, 
SUPPORT_UPDATES))
+     *         .addTraitWhen(hasPartitionBy(), SET_SEMANTIC_TABLE)
+     *         .addTraitWhen(not(hasPartitionBy()), ROW_SEMANTIC_TABLE);
+     * }</pre>
+     */
+    public StaticArgument addTraitWhen(
+            final TraitCondition condition, final StaticArgumentTrait trait) {
+        final List<ConditionalTrait> newList = new 
ArrayList<>(this.conditionalTraits);

Review Comment:
   In general, not strictly necessary in this case but I follow the immutable 
builder pattern by default. It's a fluent builder that returns a new instance 
at each step, just like how StaticArgument.table() returns a new instance. It's 
the same pattern as EnumSet.of() or List.of() - each call produces a distinct 
value



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