Github user amansinha100 commented on a diff in the pull request:
https://github.com/apache/drill/pull/1096#discussion_r171478117
--- 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 =
+ new RexVisitorImpl<Void>(true) {
+ public Void visitCall(RexCall call) {
+ if
("flatten".equals(call.getOperator().getName().toLowerCase())) {
+ throw new Util.FoundOne(call); /* throw exception to
interrupt tree walk (this is similar to
+ other utility methods in
RexUtil.java */
+ }
+ return super.visitCall(call);
+ }
+ };
+ for (RexNode rex : ((Project) project).getProjects()) {
+ rex.accept(visitor);
+ }
+ } catch (Util.FoundOne e) {
+ Util.swallow(e, null);
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isProjectOutputSchemaUnknown(RelNode project) {
--- End diff --
Javadoc
---