[jira] [Commented] (PHOENIX-3488) Support COUNT(DISTINCT x) in Phoenix-Calcite Integration
[ https://issues.apache.org/jira/browse/PHOENIX-3488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15713748#comment-15713748 ] ASF GitHub Bot commented on PHOENIX-3488: - Github user lomoree closed the pull request at: https://github.com/apache/phoenix/pull/223 > Support COUNT(DISTINCT x) in Phoenix-Calcite Integration > > > Key: PHOENIX-3488 > URL: https://issues.apache.org/jira/browse/PHOENIX-3488 > Project: Phoenix > Issue Type: Improvement >Reporter: Eric Lomore >Assignee: Eric Lomore > Labels: calcite > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PHOENIX-3488) Support COUNT(DISTINCT x) in Phoenix-Calcite Integration
[ https://issues.apache.org/jira/browse/PHOENIX-3488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15713467#comment-15713467 ] ASF GitHub Bot commented on PHOENIX-3488: - Github user lomoree commented on a diff in the pull request: https://github.com/apache/phoenix/pull/223#discussion_r90563623 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java --- @@ -899,9 +899,6 @@ public static boolean isConvertible(Aggregate input) { if (input.getGroupSets().size() > 1) return false; -if (input.containsDistinctCall()) --- End diff -- @maryannxue added a commit to detect for any distinct calls that aren't of type COUNT. Thanks! > Support COUNT(DISTINCT x) in Phoenix-Calcite Integration > > > Key: PHOENIX-3488 > URL: https://issues.apache.org/jira/browse/PHOENIX-3488 > Project: Phoenix > Issue Type: Improvement >Reporter: Eric Lomore >Assignee: Eric Lomore > Labels: calcite > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PHOENIX-3488) Support COUNT(DISTINCT x) in Phoenix-Calcite Integration
[ https://issues.apache.org/jira/browse/PHOENIX-3488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15706605#comment-15706605 ] ASF GitHub Bot commented on PHOENIX-3488: - Github user maryannxue commented on a diff in the pull request: https://github.com/apache/phoenix/pull/223#discussion_r90119141 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/calcite/rules/PhoenixConverterRules.java --- @@ -899,9 +899,6 @@ public static boolean isConvertible(Aggregate input) { if (input.getGroupSets().size() > 1) return false; -if (input.containsDistinctCall()) --- End diff -- One minor nit, would you mind add check for other distinct functions? coz we don't support SUM DISTINCT yet. > Support COUNT(DISTINCT x) in Phoenix-Calcite Integration > > > Key: PHOENIX-3488 > URL: https://issues.apache.org/jira/browse/PHOENIX-3488 > Project: Phoenix > Issue Type: Improvement >Reporter: Eric Lomore >Assignee: Eric Lomore > Labels: calcite > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PHOENIX-3488) Support COUNT(DISTINCT x) in Phoenix-Calcite Integration
[ https://issues.apache.org/jira/browse/PHOENIX-3488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15703360#comment-15703360 ] ASF GitHub Bot commented on PHOENIX-3488: - GitHub user lomoree opened a pull request: https://github.com/apache/phoenix/pull/223 PHOENIX-3488 Support COUNT(DISTINCT x) in Phoenix-Calcite Integration You can merge this pull request into a Git repository by running: $ git pull https://github.com/bloomberg/phoenix countdistinct Alternatively you can review and apply these changes as the patch at: https://github.com/apache/phoenix/pull/223.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #223 commit f3feb0ac314b36a99faf3684b43c7e2fde0d44d8 Author: EricDate: 2016-11-16T19:48:18Z Support COUNT(DISTINCT x) > Support COUNT(DISTINCT x) in Phoenix-Calcite Integration > > > Key: PHOENIX-3488 > URL: https://issues.apache.org/jira/browse/PHOENIX-3488 > Project: Phoenix > Issue Type: Improvement >Reporter: Eric Lomore >Assignee: Eric Lomore > Labels: calcite > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PHOENIX-3488) Support COUNT(DISTINCT x) in Phoenix-Calcite Integration
[ https://issues.apache.org/jira/browse/PHOENIX-3488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15684913#comment-15684913 ] Maryann Xue commented on PHOENIX-3488: -- The problem was caused by AggregateExpandDistinctAggregatesRule, which kept being filed endlessly. Simply adding {{planner.removeRule(AggregateExpandDistinctAggregatesRule.INSTANCE);}} will get rid of this problem. I believe this is a Calcite bug and we don't need this rule once we implement all XXX(distinct x) calls. Anyway, Phoenix only supports COUNT(DISTINCT x) right now, so you might still need to keep some of the not-supported-feature check there, both in {{PhoenixConverterRules.isConvertible()}} and in {{PhoenixAbstractAggregate.serializeAggregators()}}. I suggest removing all checks from PhoenixAbstractAggregate constructor though, which is to keep things in just one place and follow the current convention of all other Phoenix rels. > Support COUNT(DISTINCT x) in Phoenix-Calcite Integration > > > Key: PHOENIX-3488 > URL: https://issues.apache.org/jira/browse/PHOENIX-3488 > Project: Phoenix > Issue Type: Improvement >Reporter: Eric Lomore >Assignee: Eric Lomore > Labels: calcite > -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (PHOENIX-3488) Support COUNT(DISTINCT x) in Phoenix-Calcite Integration
[ https://issues.apache.org/jira/browse/PHOENIX-3488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15672054#comment-15672054 ] Eric Lomore commented on PHOENIX-3488: -- [~maryannxue], I believe I have a working patch for this. Before I create a PR, I wanted to raise an issue I noticed -- when doing multiple joins where only one of the joins is a PK the use of count(distinct x) fails both before and after my patch. While this query isn't necessarily logical (the count is always 1), it is valid. My patch is here for reference (includes the case below, and is annotated appropriately): https://github.com/bloomberg/phoenix/commit/ee361f98c73af82d798580f63a06aa6a30d43111 {code} select organization_id, b_string, count(distinct entity_id) from atable group by organization_id, b_string {code} {code} java.lang.AssertionError: Internal error: Error while applying rule PhoenixOrderedAggregateRule, args [rel#64710:PhoenixServerAggregate.SERVERAGG.[](input=rel#64709:Subset#5877.SERVER.[],group={0, 2},EXPR$2=COUNT($1),isOrdered=false)] at org.apache.calcite.util.Util.newInternal(Util.java:792) at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:236) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:803) at org.apache.calcite.tools.Programs$5.run(Programs.java:300) at org.apache.calcite.tools.Programs$SequenceProgram.run(Programs.java:351) at org.apache.calcite.prepare.Prepare.optimize(Prepare.java:155) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:280) at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:195) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:737) at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:600) at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:570) at org.apache.phoenix.calcite.PhoenixPrepareImpl.prepareSql(PhoenixPrepareImpl.java:223) at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:215) at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:594) at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:615) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:148) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) at org.apache.calcite.jdbc.PhoenixCalciteFactory$PhoenixCalciteStatement.executeQuery(PhoenixCalciteFactory.java:349) at org.apache.phoenix.calcite.BaseCalciteIT$Sql.checkExplain(BaseCalciteIT.java:181) at org.apache.phoenix.calcite.BaseCalciteIT$Sql.explainIs(BaseCalciteIT.java:172) at org.apache.phoenix.calcite.CalciteIT.testCountDistinct(CalciteIT.java:880) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at