[
https://issues.apache.org/jira/browse/PHOENIX-5217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16803827#comment-16803827
]
Chen Feng commented on PHOENIX-5217:
------------------------------------
Some debug info:
Sql A:
<-- a PageFilter is added in BaseResultIterators.initializeScan(), which leads
to the bug.
<-- plan.getGroupBy().getOrderPreservingColumnCount() returns 1.
<-- plan.getGroupBy() returns a new constructed GroupBy.
<-- in GroupByCompiler.compile(), al aliasedNodes are DistinctCountParseNode,
which leas to a new GroupBy object.
Sql B:
<-- no PageFilter is added in BaseResultIterators.initializeScan().
<-- plan.getGroupBy().getOrderPreservingColumnCount() returns 0.
<-- plan.getGroupBy() returns GroupByCompiler.GroupBy.UNGROUPED_GROUP_BY
<-- in GroupByCompiler.compile(), some aliasedNode is NOT
DistinctCountParseNode, therefore UNGROUPED_GROUP_BY is returned ,
I've no idea on why a new GroupBy object is needed for sql A, which leads to
the incorrect answer.
[~jamestaylor] would you be up for fixing this issue?
> Incorrect result for COUNT DISTINCT ... limit ...
> -------------------------------------------------
>
> Key: PHOENIX-5217
> URL: https://issues.apache.org/jira/browse/PHOENIX-5217
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.14.1
> Environment: 4.14.1: incorrect
> 4.6: correct.
>
> Reporter: Chen Feng
> Priority: Critical
>
> For table t1(pk1, col1, CONSTRAINT(pk1))
> upsert into "t1" values (1, 1);
> upsert into "t1" values (2, 2);
> sql A: select count("pk1") from "t1" limit 1, return 2 [correct]
> sql B: select count(disctinct("pk1")) from "t1" limit 1, return 1 [incorrect]
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)