You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2025/04/30 07:17:00 UTC
[jira] [Resolved] (CALCITE-6989) Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals
[ https://issues.apache.org/jira/browse/CALCITE-6989?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stamatis Zampetakis resolved CALCITE-6989.
------------------------------------------
Fix Version/s: 1.40.0
Resolution: Fixed
Fixed in [1919f8e90305fca997588009bed0ce87ced06011|https://github.com/apache/calcite/commit/1919f8e90305fca997588009bed0ce87ced06011].
> Enhance RexBuilder#makeIn to create SEARCH for ARRAY literals
> -------------------------------------------------------------
>
> Key: CALCITE-6989
> URL: https://issues.apache.org/jira/browse/CALCITE-6989
> Project: Calcite
> Issue Type: Improvement
> Reporter: Stamatis Zampetakis
> Assignee: Stamatis Zampetakis
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.40.0
>
>
> Currently [RexBuilder#makeIn|https://github.com/apache/calcite/blob/e9db5bdb7c78cdbbed5bb7917b62a53b6450aa40/core/src/main/java/org/apache/calcite/rex/RexBuilder.java#L1787] method creates an OR expression when the input ranges are ARRAY literals. Ideally, we should handle ARRAY literals in the same way that we handle ROW literals and create a SEARCH expression that is a more powerful abstraction.
> +Example+
> {noformat}
> RexBuilder#makeIn($0, ARRAY [100, 200], ARRAY [300, 400])
> {noformat}
> +Before+
> {noformat}
> OR(=($0, ARRAY(100, 200)), =($0, ARRAY(300, 400)))
> {noformat}
> +After+
> {noformat}
> SEARCH($0, Sarg[[100:INTEGER, 200:INTEGER]:INTEGER NOT NULL ARRAY, [300:INTEGER, 400:INTEGER]:INTEGER NOT NULL ARRAY]:INTEGER NOT NULL ARRAY)
> {noformat}
> Subsequently we can take advantage of the SEARCH operator for more powerful simplifications (RexSimplify) and/or generating IN clauses when we go from RelNode back to SQL (RelToSqlConverter).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)