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 #889: DRILL-5691: enhance scalar sub queries checking for...
Date Fri, 25 Aug 2017 07:38:28 GMT
Github user amansinha100 commented on a diff in the pull request:

    https://github.com/apache/drill/pull/889#discussion_r135196236
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/join/JoinUtils.java
---
    @@ -204,24 +205,28 @@ public static void addLeastRestrictiveCasts(LogicalExpression[]
leftExpressions,
     
       /**
        * Utility method to check if a subquery (represented by its root RelNode) is provably
scalar. Currently
    -   * only aggregates with no group-by are considered scalar. In the future, this method
should be generalized
    -   * to include more cases and reconciled with Calcite's notion of scalar.
    +   * only aggregates with no group-by and sub input rel with one row are considered scalar.
In the future,
    +   * this method should be generalized to include more cases and reconciled with Calcite's
notion of scalar.
        * @param root The root RelNode to be examined
        * @return True if the root rel or its descendant is scalar, False otherwise
        */
       public static boolean isScalarSubquery(RelNode root) {
         DrillAggregateRel agg = null;
    -    RelNode currentrel = root;
    -    while (agg == null && currentrel != null) {
    -      if (currentrel instanceof DrillAggregateRel) {
    -        agg = (DrillAggregateRel)currentrel;
    -      } else if (currentrel instanceof RelSubset) {
    -        currentrel = ((RelSubset)currentrel).getBest() ;
    -      } else if (currentrel.getInputs().size() == 1) {
    +    RelNode currentRel = root;
    +    boolean hasMoreInputs = false;
    +    while (agg == null && currentRel != null) {
    +      if (currentRel instanceof DrillAggregateRel) {
    +        agg = (DrillAggregateRel) currentRel;
    +      } else if (currentRel instanceof RelSubset) {
    +        currentRel = ((RelSubset) currentRel).getBest();
    +      } else if (currentRel.getInputs().size() == 1) {
             // If the rel is not an aggregate or RelSubset, but is a single-input rel (could
be Project,
             // Filter, Sort etc.), check its input
    -        currentrel = currentrel.getInput(0);
    +        currentRel = currentRel.getInput(0);
           } else {
    +        if (currentRel.getInputs().size() > 1) {
    --- End diff --
    
    It seems you are interested only in the 0 input case such as TableScan since later on
line 239 you check for !hasMoreInputs.  In that case, I don't think you need to set this flag.
 Why not just check currentRel.getInputs().size() == 0  on line 239 ?


---
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