[
https://issues.apache.org/jira/browse/CALCITE-4763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17417239#comment-17417239
]
Julian Hyde edited comment on CALCITE-4763 at 9/18/21, 10:01 PM:
-----------------------------------------------------------------
* {{EXISTS_AGG(c)}} is equivalent to {{EXISTS_AGG(DISTINCT c)}}, and therefore
{{getDistinctOptionality()}} should return {{IGNORED}}.
* We probably don't need a new class. Use {{SqlBasicAggFunction.create}}.
* I'm not sure we should add this to SQL. So put it in
{{SqlInternalOperators}}, not {{SqlStdOperatorTable}}.
I'm not sure we should rewrite it away. I want to use this internally. For
example, we would convert
{code}select sum(x) from t group by 'a constant'{code}as if they had written
{code}select sum(x) from t having exists_agg(){code}namely
{code}Project($1)
Filter($2)
Aggregate(SUM($4), EXISTS_AGG())
TableScan(t)
{code}
But of course by keeping it around, we are forcing adapter to handle it (e.g.
the JDBC adapter would generate "COUNT\(c) > 0").
was (Author: julianhyde):
{{EXISTS_AGG(c)}} is equivalent to {{EXISTS_AGG(DISTINCT c)}}, and therefore
{{getDistinctOptionality()}} should return {{IGNORED}}.
> add EXISTS_AGG aggregate function
> ---------------------------------
>
> Key: CALCITE-4763
> URL: https://issues.apache.org/jira/browse/CALCITE-4763
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: duan xiong
> Priority: Major
>
> Add {{EXISTS_AGG}}, an aggregate function that returns whether count is
> greater than zero.
> Thus {{EXISTS_AGG\(\*)}} is equivalent to {{COUNT\(\*) > 0}}, and
> {{EXISTS_AGG(c)}} is equivalent to {{COUNT(c) > 0}}.
> {{EXISTS_AGG}} would mainly be of use internally. Since it produces a
> {{BOOLEAN}} value, we can use the value directly from an {{Aggregate}}
> without an intervening {{Project}}. It also captures the fact that we don't
> care how many rows were produced.
> See also {{TRUE_AGG}}, CALCITE-4334.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)