Stamatis Zampetakis created CALCITE-7240:
--------------------------------------------
Summary: Handle SEARCH in DateRangeRules
Key: CALCITE-7240
URL: https://issues.apache.org/jira/browse/CALCITE-7240
Project: Calcite
Issue Type: Improvement
Components: core
Affects Versions: 1.40.0
Reporter: Stamatis Zampetakis
Assignee: Stamatis Zampetakis
The
[DateRangeRules|https://github.com/apache/calcite/blob/b6b3a068f5a524a18db7523a9a6db0a325fb390d/core/src/main/java/org/apache/calcite/rel/rules/DateRangeRules.java]
convert various expressions with EXTRACT, CEIL, and FLOOR functions over
DATE/TIMESTAMP columns to equivalent ones that don't use the function. The
rules can handle various comparison operators with conjunctions and
disjunctions but they cannot handle SEARCH.
The SEARCH operator is created in many places so the rules should be enhanced
to work with it. SQL examples where SEARCH is introduced via the use of BETWEEN:
{code:sql}
CEIL(ts to YEAR) BETWEEN TIMESTAMP '2010-02-10 11:12:05' AND TIMESTAMP
'2015-10-12 10:12:05'
FLOOR(ts to YEAR) BETWEEN TIMESTAMP '2010-02-10 11:12:05' AND TIMESTAMP
'2015-10-12 10:12:05'
EXTRACT(d TO YEAR) BETWEEN 2010 and 2015
{code}
The respective SEARCH expressions shown below cannot be handled currently by
the rules:
{noformat}
SEARCH(CEIL($9, FLAG(YEAR)), Sarg[[2010-02-10 11:12:05..2015-10-12 10:12:05]])
SEARCH(FLOOR($9, FLAG(YEAR)), Sarg[[2010-02-10 11:12:05..2015-10-12 10:12:05]])
SEARCH(EXTRACT(FLAG(YEAR), $9), Sarg[[2010..2015]]){noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)