darpan-14 opened a new pull request, #5251:
URL: https://github.com/apache/calcite/pull/5251

   ## Jira Link
   
   [CALCITE-7762](https://issues.apache.org/jira/browse/CALCITE-7762)
   
   ## Changes Proposed
   
   `DateRangeRules` has three related problems with sub-day predicates:
   
   ```sql
   SELECT FLOOR(hiredate TO DAY)
   FROM sales.emp_b
   WHERE FLOOR(hiredate TO DAY) < TIMESTAMP '2010-02-04 13:00:00';
   ```
   
   can produce an incorrect range boundary, while
   
   ```sql
   SELECT EXTRACT(HOUR FROM hiredate)
   FROM sales.emp_b
   WHERE EXTRACT(YEAR FROM hiredate) = 2010
     AND EXTRACT(HOUR FROM hiredate) = 13;
   ```
   
   can hang during the rewrite. Lower units can also cause excessive expansion;
   for example, rewriting `EXTRACT(SECOND) = 15` over one year would attempt to
   enumerate 525,600 ranges.
   
   This change:
   
   * uses `Calendar.HOUR_OF_DAY` and validates `HOUR` in the range 0 through 23;
   * adds a configurable range-expansion limit, defaulting to 100 ranges;
   * retains the original lower-unit predicate when rewriting it would exceed 
the
     limit;
   * applies the same limit when expanding `SEARCH` predicates; and
   * allows callers to select unlimited expansion explicitly with `-1`.
   
   The tests cover the corrected `FLOOR` and `CEIL` relational plans, 24-hour
   `EXTRACT(HOUR)` behavior, bounded `HOUR` and `SECOND` rewrites, exact-limit 
and
   over-limit behavior, and `SEARCH` expansion.
   
   Validation: `./gradlew build` (16,734 tests completed, 0 failed).
   


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