[
https://issues.apache.org/jira/browse/CALCITE-6793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17916190#comment-17916190
]
Stamatis Zampetakis commented on CALCITE-6793:
----------------------------------------------
One way to fix the problem would be to enhance the
{{RexSimplify#simplifyUsingPredicates}} method and add some logic that handle
pulled predicates with SEARCH/SARGs.
An alternative way would be to ensure that {{RelOptPredicateList}} isĀ in some
canonical form that does not contain SEARCH/SARGs (they are expanded
before/during construction of the {{RelOptPredicateList}} object.
A third way to handle this would be to expand the SEARCH inside the
{{simplifyUsingPredicates}} method but this will probably some extras to
decompose conjunctions etc.
Expanding and collapsing SARGs during the optimization process may lead to a
bigger search space and additional overhead so at the moment I am mostly
leaning towards the first option; accepting the presence of SEARCH inside the
{{RelOptPredicateList}} and handling natively the operator inside the
simplifier.
> Cannot simplify comparisons using pulled SARG predicates
> --------------------------------------------------------
>
> Key: CALCITE-6793
> URL: https://issues.apache.org/jira/browse/CALCITE-6793
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.38.0
> Reporter: Stamatis Zampetakis
> Assignee: Stamatis Zampetakis
> Priority: Major
>
> RexSimplify has some logic to [simplify comparison
> operations|https://github.com/apache/calcite/blob/3fce658c05aa88b44af8cbcfd0809a420896d62b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L1858]
> by exploiting pulled up predicates (predicates that we know that hold in the
> inputs).
> Let's assume that we have the comparison {{age > 25}} and we can also pull
> the {{age > 10 AND age < 20}} predicate from the input(s). Using the pulled
> up predicates we can simplify {{ age > 25 }} to {{false}}.
> The simplification above used to work in the past and stopped working
> sometime after introducing the SEARCH operator and SARGs (CALCITE-4173).
> Using SARGs, the {{age > 10 AND age < 20}} predicate is now represented as
> {{SEARCH(age, Sarg[(10..20)])}} but SEARCH/SARGs cannot be handled by the
> existing logic so they cannot be used to simplify comparisons.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)