You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2024/10/03 22:58:00 UTC
[jira] [Commented] (CALCITE-6608) RexBuilder#makeIn should create EQUALS instead of SEARCH for single point values
[ https://issues.apache.org/jira/browse/CALCITE-6608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17886803#comment-17886803 ]
Julian Hyde commented on CALCITE-6608:
--------------------------------------
The principle should be that what comes out of {{makeIn}} is consistent with what comes out of the simplifier (assuming the arguments to {{makeIn}} have already been simplified).
As I remarked in CALCITE-6599 we should not use Sargs/SEARCH for simple conditions like 'x = 3' or 'x IS NULL' but we should for more complex conditions like '{{x = 4 OR x IS NULL' or 'x = 5 OR x = 7}}'. Hopefully that is the current behavior of simplifier. If there are divergent opinions, maybe simplifier should be configurable (but {{makeIn}} should be consistent with it).
Separately, we should discuss compaction of {{{}IN{}}}-lists over discrete data types. I think that {{x IN (2, 4, 5, 6, 7, 8, 9, 10, 17)}} should be converted to {{SEARCH(x, Sarg([2], [4, 10], 17))}} because {{INTEGER}} is a discrete type and all values between 4 and 10 are listed in the expression.
> RexBuilder#makeIn should create EQUALS instead of SEARCH for single point values
> --------------------------------------------------------------------------------
>
> Key: CALCITE-6608
> URL: https://issues.apache.org/jira/browse/CALCITE-6608
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Stamatis Zampetakis
> Assignee: Stamatis Zampetakis
> Priority: Minor
>
> {code:java}
> RexBuilder.makeIn(inputRef(0), ImmutableList.of(literal(100)))
> {code}
> Current behavior:
> {noformat}
> SEARCH($0, Sarg[100])
> {noformat}
> Proposed behavior:
> {noformat}
> =($0, 100)
> {noformat}
> The EQUALS operator is simpler than the SEARCH operator and it is handled better by other components. Although, the SEARCH to EQUALS transformation is already something that is done during simplification not every piece of code calls the simplifier.
> This basic simplification could also be done directly inside the makeIn method when the caller passes a single point value.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)