zabetak commented on a change in pull request #1020: [CALCITE-2812] Add 
algebraic operators to allow expressing recursive queries (Ruben Quesada Lopez)
URL: https://github.com/apache/calcite/pull/1020#discussion_r276234096
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rel/core/RepeatUnion.java
 ##########
 @@ -0,0 +1,123 @@
+/*
+ * 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.core;
+
+import org.apache.calcite.linq4j.function.Experimental;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.BiRel;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.RelWriter;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.util.Util;
+
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+/**
+ * Relational expression that computes a Repeat Union (a.k.a. Recursive Union 
in SQL terminology).
+ *
+ * The structure of a Recursive Union is always: non-recursive term + UNION 
[ALL] + recursive term,
+ * where only the recursive term can contain a reference to the query's own 
output.
+ * (TODO only UNION ALL is supported for the moment)
+ *
+ * Such an operation is executed as follows:
+ *   - Evaluate the non-recursive term once. For UNION (but not UNION ALL), 
discard duplicate
+ *   results.
+ *   - (Re)Evaluate the recursive term over and over until it produces no more 
results. For UNION
+ *   (but not UNION ALL), discard duplicate results.
+ * Note: strictly speaking, this process is iteration not recursion, but 
RECURSIVE is the
+ * terminology chosen by the SQL standards committee.
+ *
+ * In this RepeatUnion relational expression, the left part will represent the 
non-recursive
+ * term (or "seed" relational expression), and the right part will represent 
the recursive term
+ * (or "iterative" relational expression).
+ *
+ * <p>NOTE: The current API is experimental and subject to change without 
notice.</p>
+ */
+@Experimental
+public abstract class RepeatUnion extends BiRel {
+
+  protected final boolean all = true; // TODO for the moment only RepeatUnion 
'all' is supported
+
+  // maximum number of times to repeat the iterative relational expression,
 
 Review comment:
   Use Javadoc comments instead?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to