Github user hyunsik commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/12#discussion_r13029224
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/FilterPushDownRule.java
 ---
    @@ -232,50 +298,84 @@ public LogicalNode visitJoin(Set<EvalNode> cnf, 
LogicalPlan plan, LogicalPlan.Qu
           if (joinNode.getJoinType() == JoinType.CROSS) {
             joinNode.setJoinType(JoinType.INNER);
           }
    -      cnf.removeAll(matched);
    +      context.workingEvals.removeAll(matched);
         }
     
         return joinNode;
       }
     
    -  @Override
    -  public LogicalNode visitTableSubQuery(Set<EvalNode> cnf, LogicalPlan 
plan, LogicalPlan.QueryBlock block,
    -                                        TableSubQueryNode node, 
Stack<LogicalNode> stack) throws PlanningException {
    -    List<EvalNode> matched = Lists.newArrayList();
    -    for (EvalNode eval : cnf) {
    -      if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, eval, node)) {
    -        matched.add(eval);
    +  private Map<EvalNode, EvalNode> 
transformEvalsWidthByPassNode(Collection<EvalNode> originEvals, LogicalPlan 
plan,
    +                                                                
LogicalPlan.QueryBlock block,
    +                                                                
LogicalNode node, LogicalNode childNode) throws PlanningException {
    +    // transformed -> workingEvals
    +    Map<EvalNode, EvalNode> transformedMap = new HashMap<EvalNode, 
EvalNode>();
    +
    +    if (originEvals.isEmpty()) {
    +      return transformedMap;
    +    }
    +
    +    if (node.getType() == NodeType.UNION) {
    +      // Node가 Union이면 Eval 컬럼은 모두 Simple Name이고 
Child의 OutSchema의 Simple Name과 모두 매칭
    +      Schema childOutSchema = childNode.getOutSchema();
    +      for (EvalNode eval : originEvals) {
    +        EvalNode copy;
    +        try {
    +          copy = (EvalNode) eval.clone();
    +        } catch (CloneNotSupportedException e) {
    +          throw new PlanningException(e);
    +        }
    +
    +        Set<Column> columns = EvalTreeUtil.findUniqueColumns(copy);
    +        for (Column c : columns) {
    +          Column column = childOutSchema.getColumn(c.getSimpleName());
    +          if (column == null) {
    +            throw new PlanningException(
    +                "Invalid Filter PushDown on SubQuery: No such a 
corresponding column '"
    +                    + c.getQualifiedName() + " for FilterPushDown(" + eval 
+ "), " +
    +                    "(PID=" + node.getPID() + ", Child=" + 
childNode.getPID() + ")");
    +          }
    +          EvalTreeUtil.changeColumnRef(copy, c.getSimpleName(), 
column.getQualifiedName());
    +        }
    +
    +        transformedMap.put(copy, eval);
           }
    +      return transformedMap;
         }
     
    -    Map<String, String> columnMap = new HashMap<String, String>();
    -    for (int i = 0; i < node.getInSchema().size(); i++) {
    -      LogicalNode childNode = node.getSubQuery();
    -      if (childNode.getOutSchema().getColumn(i).hasQualifier()) {
    -      columnMap.put(node.getInSchema().getColumn(i).getQualifiedName(),
    -          childNode.getOutSchema().getColumn(i).getQualifiedName());
    -      } else {
    -        NamedExprsManager namedExprsMgr = 
plan.getBlock(node.getSubQuery()).getNamedExprsManager();
    -        String originalName = 
namedExprsMgr.getOriginalName(childNode.getOutSchema().getColumn(i)
    -            .getQualifiedName());
    -
    -        // We need to consider aliased columns of sub-query.
    -        // Because we can't get original column name for a special 
occasion.
    -        // For example, if we use an aliased name inside a sub-query and 
then we use it to where
    -        // condition outside the sub-query, we can't find its original 
name.
    -        if (originalName != null) {
    -          
columnMap.put(node.getInSchema().getColumn(i).getQualifiedName(), originalName);
    -        } else {
    -          columnMap.put(node.getInSchema().getColumn(i).getQualifiedName(),
    -            node.getInSchema().getColumn(i).getQualifiedName());
    +    if (childNode.getType() == NodeType.UNION) {
    +      // Child가 Union이면 Eval의 컬럼의 Qualifier를 제거하고 
반환
    --- End diff --
    
    Could you remove the korean comment?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to