[ 
https://issues.apache.org/jira/browse/DRILL-5537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16027531#comment-16027531
 ] 

Arina Ielchiieva edited comment on DRILL-5537 at 5/29/17 11:31 AM:
-------------------------------------------------------------------

RDBMS plugin does not have impact on DrillReduceAggregatesRule, is has impact 
on query planning. When RDBMS plugin is enabled, it adds ProjectRemoveRule, 
since Project is removed, alias is lost.

Please compare query plans:
*Before changes*
_WITH_ ProjectRemoveRule
{noformat}
00-00    Screen
00-01      Project(version=[$0], $f1=[$1])
00-02        HashAgg(group=[{0}], agg#0=[$SUM0($1)])
00-03          Project(version=[$0], $f1=[1])
00-04            Scan(groupscan=[SystemTableScan [table=VERSION, 
distributed=false]])
{noformat}
_WITHOUT_ ProjectRemoveRule
{noformat}
00-00    Screen
00-01      Project(version=[$0], s=[$1])
00-02        Project(version=[$0], s=[$1])
00-03          HashAgg(group=[{0}], agg#0=[$SUM0($1)])
00-04            Project(version=[$0], $f1=[1])
00-05              Scan(groupscan=[SystemTableScan [table=VERSION, 
distributed=false]])
{noformat}

*After changes*
_WITH_ ProjectRemoveRule
{noformat}
00-00    Screen
00-01      Project(version=[$0], s=[$1])
00-02        HashAgg(group=[{0}], s=[$SUM0($1)])
00-03          Project(version=[$0], $f1=[1])
00-04            Scan(groupscan=[SystemTableScan [table=VERSION, 
distributed=false]])
{noformat}
_WITHOUT_ ProjectRemoveRule
{noformat}
00-00    Screen
00-01      Project(version=[$0], s=[$1])
00-02        Project(version=[$0], s=[$1])
00-03          HashAgg(group=[{0}], s=[$SUM0($1)])
00-04            Project(version=[$0], $f1=[1])
00-05              Scan(groupscan=[SystemTableScan [table=VERSION, 
distributed=false]])
{noformat}



was (Author: arina):
RDBMS plugin does not have impact on DrillReduceAggregatesRule, is has impact 
on query planning. When RDBMS plugin is enabled, it adds ProjectRemoveRule.
Due to bug in DrillReduceAggregatesRule we were losing column alias when we 
were creating new aggregate call and ProjectRemoveRule was removing project 
stage since considered project trivial. With the fix when column alias is 
preserved in new aggregate call, ProjectRecordBatch does not remove project 
stage since now it does not consider project trivial (it sees that we need to 
add alias).

> Display columns alias for queries with sum() when RDBMS storage plugin is 
> enabled
> ---------------------------------------------------------------------------------
>
>                 Key: DRILL-5537
>                 URL: https://issues.apache.org/jira/browse/DRILL-5537
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.10.0
>            Reporter: Arina Ielchiieva
>            Assignee: Arina Ielchiieva
>
> When [RDBMS storage 
> plugin|https://drill.apache.org/docs/rdbms-storage-plugin/]  is enabled, 
> alias is not displayed for column with sum function:
> {noformat}
> 0: jdbc:drill:zk=local> select version, sum(1) as s from sys.version group by 
> version;
> +------------------+------+
> |     version      | $f1  |
> +------------------+------+
> | 1.11.0-SNAPSHOT  | 1    |
> +------------------+------+
> 1 row selected (0.444 seconds)
> {noformat}
> Other functions like avg, count are not affected.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to