morrySnow commented on code in PR #67541:
URL: https://github.com/apache/doris/pull/67541#discussion_r3947705878


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/ProjectJoinReorderHelper.java:
##########
@@ -0,0 +1,192 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.exploration.join;
+
+import org.apache.doris.nereids.rules.exploration.CBOUtils;
+import org.apache.doris.nereids.trees.expressions.ExprId;
+import org.apache.doris.nereids.trees.expressions.NamedExpression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/** Normalize a Project over Join only when a Project-aware join reorder rule 
produces an alternative. */
+final class ProjectJoinReorderHelper {
+    private ProjectJoinReorderHelper() {
+    }
+
+    /**
+     * Keep a slot-only Project unchanged, or push single-side complex 
expressions below its Join.
+     *
+     * <p>The returned Project is slot-only and has the same output as the 
input Project. Empty means that
+     * the Project cannot be moved without changing semantics.</p>
+     */
+    static Optional<LogicalProject<LogicalJoin<Plan, Plan>>> 
normalize(LogicalProject<?> project) {
+        if (project.isAllSlots()) {
+            return Optional.of(castProject(project));
+        }
+
+        LogicalJoin<Plan, Plan> join = childJoin(project);
+        JoinType joinType = join.getJoinType();
+        if (joinType.isLeftSemiOrAntiJoin()) {
+            if (join.isMarkJoin() || projectBothJoinSides(project)) {

Review Comment:
   this is a copy from PushDownProjectThroughSemiJoin, should not be changed in 
this PR



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to