vlsi commented on a change in pull request #2363:
URL: https://github.com/apache/calcite/pull/2363#discussion_r591341149
##########
File path: core/src/main/java/org/apache/calcite/rel/core/Sort.java
##########
@@ -124,11 +126,20 @@ public abstract Sort copy(RelTraitSet traitSet, RelNode
newInput,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
+ double rowCount = mq.getRowCount(this);
+ if (collation.getFieldCollations().isEmpty()) {
+ return planner.getCostFactory().makeCost(rowCount, 0, 0);
+ }
+ int offsetValue = offset == null || offset instanceof RexDynamicParam ? 0
+ : RexLiteral.intValue(offset);
Review comment:
`RexLiteral.intValue` would do narrowing conversion, so it would result
negative values for values that exceed `Integer.MAX_VALUE`
##########
File path: core/src/main/java/org/apache/calcite/rel/core/Sort.java
##########
@@ -124,11 +126,20 @@ public abstract Sort copy(RelTraitSet traitSet, RelNode
newInput,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
+ double rowCount = mq.getRowCount(this);
+ if (collation.getFieldCollations().isEmpty()) {
+ return planner.getCostFactory().makeCost(rowCount, 0, 0);
+ }
+ int offsetValue = offset == null || offset instanceof RexDynamicParam ? 0
+ : RexLiteral.intValue(offset);
Review comment:
`RexLiteral.intValue` would do narrowing conversion, so it would result
in negative values for values that exceed `Integer.MAX_VALUE`
##########
File path: core/src/main/java/org/apache/calcite/rel/core/Sort.java
##########
@@ -124,11 +126,20 @@ public abstract Sort copy(RelTraitSet traitSet, RelNode
newInput,
@Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery mq) {
+ double rowCount = mq.getRowCount(this);
+ if (collation.getFieldCollations().isEmpty()) {
+ return planner.getCostFactory().makeCost(rowCount, 0, 0);
+ }
+ int offsetValue = offset == null || offset instanceof RexDynamicParam ? 0
+ : RexLiteral.intValue(offset);
Review comment:
`RexLiteral.intValue` would do narrowing conversion, so it would yield
negative values for values that exceed `Integer.MAX_VALUE`
----------------------------------------------------------------
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]