drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansinha100 <...@git.apache.org>
Subject [GitHub] drill pull request #794: DRILL-5375: Nested loop join: return correct result...
Date Mon, 27 Mar 2017 16:18:49 GMT
Github user amansinha100 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/794#discussion_r108213635
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java
---
    @@ -70,27 +70,65 @@
       private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillOptiq.class);
     
       /**
    -   * Converts a tree of {@link RexNode} operators into a scalar expression in Drill syntax.
    +   * Converts a tree of {@link RexNode} operators into a scalar expression in Drill syntax
using one input.
    +   *
    +   * @param context parse context which contains planner settings
    +   * @param input data input
    +   * @param expr expression to be converted
    +   * @return converted expression
        */
       public static LogicalExpression toDrill(DrillParseContext context, RelNode input, RexNode
expr) {
    -    final RexToDrill visitor = new RexToDrill(context, input);
    +    return toDrill(context, Lists.newArrayList(input), expr);
    +  }
    +
    +  /**
    +   * Converts a tree of {@link RexNode} operators into a scalar expression in Drill syntax
using multiple inputs.
    +   *
    +   * @param context parse context which contains planner settings
    +   * @param inputs multiple data inputs
    +   * @param expr expression to be converted
    +   * @return converted expression
    +   */
    +  public static LogicalExpression toDrill(DrillParseContext context, List<RelNode>
inputs, RexNode expr) {
    +    final RexToDrill visitor = new RexToDrill(context, inputs);
         return expr.accept(visitor);
       }
     
       private static class RexToDrill extends RexVisitorImpl<LogicalExpression> {
    -    private final RelNode input;
    +    private final List<RelNode> inputs;
         private final DrillParseContext context;
    +    private final List<RelDataTypeField> fieldList;
     
    -    RexToDrill(DrillParseContext context, RelNode input) {
    +    RexToDrill(DrillParseContext context, List<RelNode> inputs) {
           super(true);
           this.context = context;
    -      this.input = input;
    +      this.inputs = inputs;
    +      this.fieldList = Lists.newArrayList();
    +      /*
    +         Fields are enumerated by their presence order in input. Details {@link org.apache.calcite.rex.RexInputRef}.
    +         Thus we can merge field list from several inputs by adding them into the list
in order of appearance.
    +         Each field index in the list will match field index in the RexInputRef instance
which will allow us
    +         to retrieve field from filed list by index in {@link #visitInputRef(RexInputRef)}
method. Example:
    +
    +         Query: select t1.c1, t2.c1. t2.c2 from t1 inner join t2 on t1.c1 between t2.c1
and t2.c2
    +
    +         Input 1: $0
    +         Input 2: $1, $2
    +
    +         Result: $0, $1, $2
    +       */
    +      for (RelNode input : inputs) {
    --- End diff --
    
    I guess I am still unclear about the reason for merging the multiple lists into one. 
Later, you will have to determine which input each $n reference belonged to, isn't it ?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message