ihuzenko commented on a change in pull request #1608: DRILL-6960: Auto Limit
Wrapping should not apply to non-select query
URL: https://github.com/apache/drill/pull/1608#discussion_r252687106
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
##########
@@ -183,4 +183,24 @@ private static PhysicalPlan getQueryPlan(QueryContext
context, String sql, Point
return handler.getPlan(sqlNode);
}
+
Review comment:
I'd like to replace the constant and method defined below, with:
```suggestion
private static boolean applyAutoLimit(SqlNode sqlNode, SqlKind kind,
Integer autoLimit) {
if (kind == SqlKind.SELECT) {
SqlNumericLiteral fetch =
SqlNumericLiteral.createExactNumeric(autoLimit.toString(),
sqlNode.getParserPosition());
((SqlSelect) sqlNode).setFetch(fetch);
return true;
} else if (sqlNode instanceof SqlWith) {
SqlNode withBody = ((SqlWith) sqlNode).body;
return applyAutoLimit(withBody, withBody.getKind(), autoLimit);
}
return false;
}
```
Suggested method avoids double parsing of SQL string and handles WITH
queries.
----------------------------------------------------------------
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