lowka commented on code in PR #6374:
URL: https://github.com/apache/ignite-3/pull/6374#discussion_r2269363561


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/Cloner.java:
##########
@@ -47,4 +54,58 @@ public static IgniteRel clone(IgniteRel root, RelOptCluster 
cluster) {
     private IgniteRel visit(IgniteRel rel) {
         return rel.clone(cluster, Commons.transform(rel.getInputs(), rel0 -> 
visit((IgniteRel) rel0)));
     }
+
+
+    /**
+     * Clones and assigns source ids to all source relations.
+     *
+     * @param root Plan.
+     * @param cluster Cluster.
+     * @return The number of source relations in the given plan and the plan 
itself.
+     */
+    public static IntObjectPair<IgniteRel> cloneAndAssignSourceId(IgniteRel 
root, RelOptCluster cluster) {
+        CloneAndAssignIds assigner = new CloneAndAssignIds(cluster);
+        IgniteRel result = assigner.visit(root);
+        int numSources = assigner.sourceIndex;
+
+        return new IntObjectImmutablePair<>(numSources, result);
+    }
+
+    private static class CloneAndAssignIds extends IgniteRelShuttle {
+
+        private final RelOptCluster cluster;
+
+        private int sourceIndex;
+
+        private CloneAndAssignIds(RelOptCluster cluster) {
+            this.cluster = cluster;
+        }
+
+        @Override
+        public IgniteRel visit(IgniteRel rel) {
+            if (rel instanceof SourceAwareIgniteRel && !(rel instanceof 
IgniteTrimExchange)) {

Review Comment:
   Fixed. 



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to