snuyanzin commented on code in PR #27250:
URL: https://github.com/apache/flink/pull/27250#discussion_r2545646914
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/physical/stream/FlinkMarkChangelogNormalizeProgram.java:
##########
@@ -149,27 +154,47 @@ public RelNode optimize(RelNode root,
StreamOptimizeContext context) {
continue;
}
- final Set<RexNode> common =
calculateCommonCondition(changelogNormalizeContexts);
+ final List<RexNode> commons =
+ calculateCommonCondition(rexBuilder,
changelogNormalizeContexts);
for (ChangelogNormalizeContext ctx : changelogNormalizeContexts) {
ctx.getChangelogNormalize().markSourceReuse();
- if (!common.isEmpty()) {
-
ctx.getChangelogNormalize().setCommonFilter(common.toArray(new RexNode[0]));
+ if (!commons.isEmpty()) {
+
ctx.getChangelogNormalize().setCommonFilter(commons.toArray(new RexNode[0]));
}
}
}
return root;
}
- private Set<RexNode> calculateCommonCondition(
- List<ChangelogNormalizeContext> changelogNormalizeContexts) {
- changelogNormalizeContexts.sort(Comparator.comparingInt(o ->
o.getConditions().size()));
- final Set<RexNode> common =
- new
HashSet<>(changelogNormalizeContexts.get(0).getConditions());
+ private List<RexNode> calculateCommonCondition(
Review Comment:
the only reason to refactor this code is memory issue in case of query with
huge list of conditions connected by `OR`
--
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]