darpan-e6 commented on code in PR #5251:
URL: https://github.com/apache/calcite/pull/5251#discussion_r3965376227


##########
core/src/main/java/org/apache/calcite/rel/rules/DateRangeRules.java:
##########
@@ -482,6 +552,10 @@ RexNode compareExtract(SqlKind comparison, RexNode operand,
             c = (Calendar) r.lowerEndpoint().clone();
             int i = 0;
             while (next(c, timeUnit, v, r, i++ > 0)) {
+              if (!rangeExpansionLimiter.tryAddRange()) {
+                rangeExpansionLimiter.reset(rangeCountMark);

Review Comment:
   The counter tracks ranges retained in the final rewrite. Flow: save count → 
generate ranges → limit exceeded → discard partial ranges and retain the 
original predicate → restore count. Without the reset, a failed rewrite would 
consume the budget despite adding no ranges to the plan.
   
   If the limit should instead count attempted work, we can remove the reset.



##########
core/src/main/java/org/apache/calcite/rel/rules/DateRangeRules.java:
##########
@@ -482,6 +552,10 @@ RexNode compareExtract(SqlKind comparison, RexNode operand,
             c = (Calendar) r.lowerEndpoint().clone();
             int i = 0;
             while (next(c, timeUnit, v, r, i++ > 0)) {
+              if (!rangeExpansionLimiter.tryAddRange()) {
+                rangeExpansionLimiter.reset(rangeCountMark);

Review Comment:
   The counter tracks ranges retained in the final rewrite. Flow: save count → 
generate ranges → limit exceeded → discard partial ranges and retain the 
original predicate → restore count. Without the reset, a failed rewrite would 
consume the budget despite adding no ranges to the plan.
   
   If the limit should instead count attempted work, we can remove the reset.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to