HanumathRao commented on a change in pull request #1417: DRILL-6645: Transform 
TopN in Lateral Unnest pipeline to Sort and Limit.
URL: https://github.com/apache/drill/pull/1417#discussion_r207629168
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/TopNPrel.java
 ##########
 @@ -115,6 +118,16 @@ public Prel addImplicitRowIDCol(List<RelNode> children) {
                                     
.replace(this.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE))
                                     .replace(collationTrait)
                                     .replace(DRILL_PHYSICAL);
-    return (Prel) this.copy(traits, children);
+    return transformTopNToSortAndLimit(children, traits, collationTrait);
+  }
+
+  private Prel transformTopNToSortAndLimit(List<RelNode> children, RelTraitSet 
traits, RelCollation collationTrait) {
+    SortPrel sortprel = new SortPrel(this.getCluster(), traits, 
children.get(0), collationTrait);
+    RexNode offset = 
this.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0),
+            
this.getCluster().getTypeFactory().createSqlType(SqlTypeName.INTEGER));
+    RexNode limit = 
this.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(this.limit),
+            
this.getCluster().getTypeFactory().createSqlType(SqlTypeName.INTEGER));
+    LimitPrel limitPrel = new LimitPrel(this.getCluster(), traits, sortprel, 
offset, limit, false);
 
 Review comment:
   Yes Limit created should be partition limit but it is not created here 
because that API is not yet available in the master. Once it is available it 
will be rebased upon it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to