[
https://issues.apache.org/jira/browse/CALCITE-5117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17528483#comment-17528483
]
xiong duan commented on CALCITE-5117:
-------------------------------------
The [PR-2781|https://github.com/apache/calcite/pull/2781] has ready for review.
Welcome.
> Optimize the EXISTS sub-query by Metadata RowCount
> --------------------------------------------------
>
> Key: CALCITE-5117
> URL: https://issues.apache.org/jira/browse/CALCITE-5117
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.30.0
> Reporter: xiong duan
> Assignee: xiong duan
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.31.0
>
>
> As same as the UNIQUE sub-query, before we convert the sub-query to RelNode.
> we use the Metadata to optimize it.
> EXISTS sub-query, If the sub-query is guaranteed to produce at least one row,
> just return TRUE. If the sub-query is guaranteed to produce no row, just
> return FALSE.
> For example:
> {code:java}
> select *
> from dept as d
> where EXISTS (select count(*) from emp e where d.deptno = e.deptno){code}
> We can optimize it to:
> {code:java}
> EnumerableTableScan(table=[[scott, DEPT]]){code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)