okumin commented on a change in pull request #1873:
URL: https://github.com/apache/hive/pull/1873#discussion_r558338464



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
##########
@@ -1411,47 +1414,92 @@ public String toString() {
     }
   }
 
-  private List<Task<?>> toRealRootTasks(List<CTEClause> execution) {
-    List<Task<?>> cteRoots = new ArrayList<>();
-    List<Task<?>> cteLeafs = new ArrayList<>();
-    List<Task<?>> curTopRoots = null;
-    List<Task<?>> curBottomLeafs = null;
-    for (CTEClause current : execution) {
-      if (current.parents.isEmpty() && curTopRoots != null) {
-        cteRoots.addAll(curTopRoots);
-        cteLeafs.addAll(curBottomLeafs);
-        curTopRoots = curBottomLeafs = null;

Review comment:
       This looks like the root cause. In [the case I put in the 
ticket](https://issues.apache.org/jira/browse/HIVE-24606), there are the 
following dependencies.
   
   - `<root> -> a1`
   - `<root> -> x`
   - `<root> -> a2`
   - `a2 -> a1`
   
   But the old implementation tries to traverse CTEs in order of `a1` -> `x` -> 
`a2` -> `<root>`, the order which depends on AST.
   As a result, when it visits `a2`, the information of `a1` has gone and it 
fails to link `a2` with `a1`.




----------------------------------------------------------------
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:
[email protected]



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

Reply via email to