xiedeyantu commented on code in PR #4447:
URL: https://github.com/apache/calcite/pull/4447#discussion_r2174281936


##########
core/src/main/java/org/apache/calcite/rel/rules/FullToLeftAndRightJoinRule.java:
##########
@@ -0,0 +1,230 @@
+/*
+ * 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.calcite.rel.rules;
+
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.plan.RelRule;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.Join;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexLiteral;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexVisitorImpl;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.tools.RelBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.immutables.value.Value;
+
+import java.util.List;
+
+/**
+ * Planner rule that matches a {@link Join}
+ * that join type is FULL, and convert it to
+ * a LEFT JOIN and RIGHT JOIN combination
+ * with a UNION ALL above them.
+ *
+ * <p>This rule is mainly used for SQL dialect conversion.
+ * The SQL example is as follows:
+ *
+ * <pre>{@code

Review Comment:
   We can look at this case:
   ```
   select * from emps e1 full join emps2 e2 on e1.commission is not distinct 
from e2.commission and e1.deptno = e2.deptno; 
   
   SELECT * FROM emps e1 LEFT JOIN emps2 e2 ON e1.commission is not distinct 
from e2.commission and e1.deptno = e2.deptno 
   UNION ALL 
   SELECT * FROM emps e1 RIGHT JOIN emps2 e2 ON e1.commission is not distinct 
from e2.commission and e1.deptno = e2.deptno 
   WHERE not (e1.commission is not distinct from e2.commission and e1.deptno = 
e2.deptno);
   ```
   So what I mean is that it is harder to handle if the conditions are mixed 
with expressions that need to consider whether null values ​​are equal, such as 
`is null`, `is not distinct from`, `=`, `>`, `<`, `>=`, `<=`, `!=`, etc.



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