Stamatis Zampetakis created CALCITE-7789:
--------------------------------------------
Summary: Conditionally skip simplifications for certain expressions
Key: CALCITE-7789
URL: https://issues.apache.org/jira/browse/CALCITE-7789
Project: Calcite
Issue Type: Improvement
Components: core
Reporter: Stamatis Zampetakis
Assignee: Stamatis Zampetakis
In the past there were various discussions about incorrect simplifications in
the presence of 'NaN' (CALCITE-4467). The respective ticket was closed and it
was decided that it will be complicated to add special semantics to 'NaN'.
However, to overcome the problem of "wrong" results DB engines such as Hive,
Impala, etc., started applying workarounds for turning off simplifications
under certain conditions.
For example, Impala created a custom extension of
[RexSimplify|https://github.com/apache/impala/blob/ac16a39210df9999f8dd1941e3fa513594f9aab2/java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaRexSimplify.java#L38]
that inspects binary operators and does not simplify an expression if it
contains approximate types.
Although the RexSimplify class does not prevent overriding its not really made
for extension and doing so creates problems in other places where a simplifier
is needed.
A better solution is to add built-in functionality in the standard RexSimplify
class to be able to skip simplifications for certain expressions.
The easiest and more general way to achieve that would be to allow callers to
create a RexSimplify with a pluggable RexVisitor that decides if an expression
must be simplified or not.
Another more focused solution around 'Nan' would be to disallow simplifications
on certain datatypes. For example, skip simplification on approximate numeric
types.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)