[ 
https://issues.apache.org/jira/browse/TAJO-1310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14322202#comment-14322202
 ] 

ASF GitHub Bot commented on TAJO-1310:
--------------------------------------

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

    https://github.com/apache/tajo/pull/381#discussion_r24726336
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/AbstractJoinExec.java
 ---
    @@ -0,0 +1,157 @@
    +/**
    + * 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.tajo.engine.planner.physical;
    +
    +import org.apache.tajo.catalog.Schema;
    +import org.apache.tajo.engine.planner.Projector;
    +import org.apache.tajo.plan.expr.EvalNode;
    +import org.apache.tajo.plan.logical.JoinNode;
    +import org.apache.tajo.storage.FrameTuple;
    +import org.apache.tajo.storage.Tuple;
    +import org.apache.tajo.storage.VTuple;
    +import org.apache.tajo.worker.TaskAttemptContext;
    +
    +import java.io.IOException;
    +
    +public abstract class AbstractJoinExec extends BinaryPhysicalExec {
    +
    +  protected JoinNode plan;
    +  protected EvalNode joinQual;
    +  protected EvalNode joinFilter;
    +
    +  private Projector projector;
    +  private Tuple outTuple;
    +  private FrameTuple frameTuple;
    +  private boolean filterSatisfied = false;
    +  private boolean projected = false;
    +
    +  public AbstractJoinExec(final TaskAttemptContext context, final JoinNode 
plan,
    +                          final PhysicalExec outer, PhysicalExec inner) {
    +    this(context, plan, plan.getInSchema(), plan.getOutSchema(), outer, 
inner);
    +  }
    +
    +  public AbstractJoinExec(final TaskAttemptContext context, final JoinNode 
plan,
    +                          final Schema inSchema, final Schema outSchema,
    +                          final PhysicalExec outer, PhysicalExec inner) {
    +    super(context, inSchema, outSchema, outer, inner);
    +    this.plan = plan;
    +    this.joinQual = plan.hasJoinQual() ? plan.getJoinQual() : null;
    +    this.joinFilter = plan.hasJoinFilter() ? plan.getJoinFilter() : null;
    +
    +    // for projection
    +    this.projector = new Projector(context, inSchema, outSchema, 
plan.getTargets());
    +
    +    // for join
    +    frameTuple = new FrameTuple();
    +    outTuple = new VTuple(outSchema.size());
    +  }
    +
    +  public JoinNode getPlan() {
    +    return plan;
    +  }
    +
    +  public boolean hasJoinQual() {
    +    return this.joinQual != null;
    +  }
    +
    +  public void setJoinQual(EvalNode joinQual) {
    +    this.joinQual = joinQual;
    +  }
    +
    +  public void setPrecompiledJoinPredicates() {
    +    if (hasJoinQual()) {
    +      joinQual = context.getPrecompiledEval(inSchema, joinQual);
    +    }
    +    if (hasJoinFilter()) {
    +      joinFilter = context.getPrecompiledEval(inSchema, joinFilter);
    +    }
    +  }
    +
    +  public EvalNode getJoinQual() {
    +    return joinQual;
    +  }
    +
    +  public boolean hasJoinFilter() {
    +    return this.joinFilter != null;
    +  }
    +
    +  public void setJoinFilter(EvalNode joinFilter) {
    +    this.joinFilter = joinFilter;
    +  }
    +
    +  public EvalNode getJoinFilter() {
    +    return joinFilter;
    +  }
    +
    +  public boolean evalFilter() {
    +    filterSatisfied = hasJoinFilter() ?
    +        joinFilter.eval(inSchema, frameTuple).isTrue() : true;
    +    return filterSatisfied;
    +  }
    +
    +  public boolean evalQual() {
    --- End diff --
    
    It also the same issue to above comment.


> Maintaining join filters in join operators
> ------------------------------------------
>
>                 Key: TAJO-1310
>                 URL: https://issues.apache.org/jira/browse/TAJO-1310
>             Project: Tajo
>          Issue Type: Improvement
>          Components: parser, physical operator, planner/optimizer
>            Reporter: Jihoon Son
>            Assignee: Jihoon Son
>            Priority: Blocker
>             Fix For: 0.10
>
>
> *Introduction*
> A join statement can contain join predicates and join filters.
> Join predicates are evaluated during performing the join operation, while 
> join filters are evaluated on the set of join results.
> Let me consider an example join query as follows:
> {noformat}
> default> select n_nationkey from nation left outer join region on n_nationkey 
> = r_regionkey where r_regionkey is null;
> {noformat}
> In this query, the join predicates and filters are as follows:
> * Join predicates: n_nationkey = r_regionkey
> * Join filters: r_regionkey is null
> *Problem*
> Currently, in query plans, join filters are handled as selection operators, 
> while join predicates are maintained as member variables of join operators.
> This approach makes the implementation simple, but difficult to find the 
> selection operators corresponding to join operators because they are 
> separately maintained.
> This problem is critical when the logical plan optimizer optimizes the join 
> order of a query statement that contains two or more joins each of that has 
> join filters. 
> *Solution*
> Join filters should be distinguished from selection filters, and maintained 
> in the corresponding join operators. For this, we should add join filtlers to 
> the join expression, the logical join node, and several physical join 
> executors. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to