[
https://issues.apache.org/jira/browse/CALCITE-6989?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stamatis Zampetakis updated CALCITE-6989:
-----------------------------------------
Description:
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).
> 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
> Priority: Major
>
> 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)