zhenglin tao created HAWQ-485:
---------------------------------

             Summary: Wrong results in rollup with plan_append_aggs_with_rewrite
                 Key: HAWQ-485
                 URL: https://issues.apache.org/jira/browse/HAWQ-485
             Project: Apache HAWQ
          Issue Type: Bug
          Components: Core
            Reporter: zhenglin tao
            Assignee: Lei Chang


create table vendor
(
vn int not null,
vname text not null,
vloc text
) WITH (appendonly=true, orientation = parquet) distributed by (vn);

create table sale
(
cn int not null,
vn int not null,
pn int not null,
dt date not null,
qty int not null,
prc float not null
) WITH (appendonly=true, orientation = parquet) distributed by (cn,vn,pn);

insert into vendor values
( 10, 'Witches, Inc', 'Lonely Heath'),
( 20, 'Lady Macbeth', 'Inverness'),
( 30, 'Duncan', 'Forres'),
( 40, 'Macbeth', 'Inverness'),
( 50, 'Macduff', 'Fife');

insert into sale values
( 2, 40, 100, '1401-1-1', 1100, 2400),
( 1, 10, 200, '1401-3-1', 1, 0),
( 3, 40, 200, '1401-4-1', 1, 0),
( 1, 20, 100, '1401-5-1', 1, 0),
( 1, 30, 300, '1401-5-2', 1, 0),
( 1, 50, 400, '1401-6-1', 1, 0),
( 2, 50, 400, '1401-6-1', 1, 0),
( 1, 30, 500, '1401-6-1', 12, 5),
( 3, 30, 500, '1401-6-1', 12, 5),
( 3, 30, 600, '1401-6-1', 12, 5),
( 4, 40, 700, '1401-6-1', 1, 1),
( 4, 40, 800, '1401-6-1', 1, 1);

SELECT CASE WHEN sale.qty < 10 THEN 1 ELSE 2 END as newalias2,CASE WHEN 
sale.qty < 10 THEN 1 ELSE 2 END as newalias4, COUNT(DISTINCT sale.qty)
FROM sale,vendor
WHERE sale.vn=vendor.vn
GROUP BY ROLLUP((newalias2,newalias2),(newalias4,newalias4)),sale.qty,sale.vn;



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to