kgyrtkirk commented on a change in pull request #860: HIVE-22408 The fix for
CALCITE-2991 creates wrong results on edge case
URL: https://github.com/apache/hive/pull/860#discussion_r357151192
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitRemoveRule.java
##########
@@ -41,8 +42,17 @@ public boolean matches(RelOptRuleCall call) {
final HiveSortLimit sortLimit = call.rel(0);
Double maxRowCount =
call.getMetadataQuery().getMaxRowCount(sortLimit.getInput());
- if (maxRowCount != null &&(maxRowCount <= 1)) {
- return true;
+ if (maxRowCount != null) {
+ if (sortLimit.getFetchExpr() != null) {
+ // we have LIMIT
+ int limit = RexLiteral.intValue(sortLimit.getFetchExpr());
+ if (maxRowCount <= limit) {
Review comment:
I agree; I've taken a closer look and for the cases I was considering the
`maxRowCount` ends up being infinity (the default for all tables is infinity) -
and no filter expr changes that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]