[
https://issues.apache.org/jira/browse/CALCITE-2907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16789449#comment-16789449
]
Lai Zhou edited comment on CALCITE-2907 at 3/11/19 11:43 AM:
-------------------------------------------------------------
[~danny0405]
I found this issue was caused by my customed function SqlReturnTypeInference,
which has a bug when infer the return type for an aggregate call. I have fixed
it ,so this issue is not real bug. I'll close it.
was (Author: hhlai1990):
[~danny0405]
I found this issure was caused by my customed function SqlReturnTypeInference,
which has a bug when infer the return type for a aggregate call. I have fixed
it ,so this issure is not real bug. I'll close it.
> AggregateExpandDistinctAggregatesRule produces a wrong relational algebra
> -------------------------------------------------------------------------
>
> Key: CALCITE-2907
> URL: https://issues.apache.org/jira/browse/CALCITE-2907
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.18.0
> Reporter: Lai Zhou
> Priority: Major
>
> In my usecase:
> an Aggregate which contains distinct call was converted improperly to a
> wrong relational algebra.
>
> {code:java}
> SELECT user_id,
> order_id,
> product_id,
> count(DISTINCT secured_libs.u51decrypt(phone)) AS
> contact_count,
> stddev_pop(secured_libs.u51decrypt(phone)) AS
> seg3stddev,
> entropy(secured_libs.u51decrypt(phone)) AS
> seg3entropy
> FROM dw_risk__mygravitation_v_snap_contacts_contacts
> GROUP BY user_id,
> order_id,
> product_id
> {code}
>
>
> After digging into the code,I found at the line 444 of the
> AggregateExpandDistinctAggregatesRule.java :
>
> {code:java}
> int x = groupCount;
> final List<AggregateCall> newCalls = new ArrayList<>();
> for (AggregateCall aggCall : aggregate.getAggCallList()) {
> final int newFilterArg;
> final List<Integer> newArgList;
> final SqlAggFunction aggregation;
> if (!aggCall.isDistinct()) {
> aggregation = SqlStdOperatorTable.MIN;
> newArgList = ImmutableIntList.of(x++);
> newFilterArg = filters.get(aggregate.getGroupSet());
> } else {
> {code}
> the undistinct aggregate call `stddev_pop` and `entropy` was converted to a
> SqlStdOperatorTable.MIN,(actually all undistinct aggregate call here will be
> converted to a SqlStdOperatorTable.MIN ).
> I don't understand how it works.
> I guess someone made a faulty assumption here. [~julianhyde] ,can someone
> help me ASAP ?
> It’s very important for my business.
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)