Yingyi Bu created ASTERIXDB-2051:
------------------------------------

             Summary: Variable not found in a complex group-by query
                 Key: ASTERIXDB-2051
                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-2051
             Project: Apache AsterixDB
          Issue Type: Bug
          Components: COMP - Compiler
            Reporter: Yingyi Bu
            Assignee: Yingyi Bu


{noformat}

DROP  DATAVERSE tpch IF EXISTS;
CREATE  dataverse tpch;

USE tpch;


CREATE TYPE LineItemType AS CLOSED {
  l_orderkey : integer,
  l_partkey : integer,
  l_suppkey : integer,
  l_linenumber : integer,
  l_quantity : double,
  l_extendedprice : double,
  l_discount : double,
  l_tax : double,
  l_returnflag : string,
  l_linestatus : string,
  l_shipdate : string,
  l_commitdate : string,
  l_receiptdate : string,
  l_shipinstruct : string,
  l_shipmode : string,
  l_comment : string
}

CREATE DATASET LineItem(LineItemType) PRIMARY KEY l_orderkey,l_linenumber;


SELECT l_returnflag AS l_returnflag,
       l_linestatus AS l_linestatus,
       coll_count(cheap) AS count_cheaps,
       coll_count(expensive) AS count_expensives
FROM LineItem AS l
/* +hash */
GROUP BY l.l_returnflag AS l_returnflag,l.l_linestatus AS l_linestatus
GROUP AS g
LET cheap = (
      SELECT ELEMENT g.l
      FROM g
      WHERE g.l.l_discount > 0.05
),
expensive = (
      SELECT ELEMENT m
      FROM (FROM g SELECT VALUE l) AS m
      WHERE m.l_discount <= 0.05
)
ORDER BY l_returnflag,l_linestatus
;


{noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to