Github user amansinha100 commented on a diff in the pull request:
https://github.com/apache/drill/pull/1096#discussion_r171479641
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillRelOptUtil.java
---
@@ -224,4 +226,64 @@ public Void visitInputRef(RexInputRef inputRef) {
}
}
+ public static boolean isLimit0(RexNode fetch) {
+ if (fetch != null && fetch.isA(SqlKind.LITERAL)) {
+ RexLiteral l = (RexLiteral) fetch;
+ switch (l.getTypeName()) {
+ case BIGINT:
+ case INTEGER:
+ case DECIMAL:
+ if (((long) l.getValue2()) == 0) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isProjectOutputRowcountUnknown(RelNode project) {
+ assert project instanceof Project : "Rel is NOT an instance of
project!";
+ try {
+ RexVisitor<Void> visitor =
--- End diff --
Would FLATTEN ever occur within other expressions ? I believe it always
occurs as an independent expression. If that's the case, it seems to me that
having a visitor is overkill.. what do you think ? Even the original rewrite
from project to flatten just iterates over the project exprs here [1].
[1]
https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/RewriteProjectToFlatten.java#L77
---