blob: 94b291385c72d53d571889fc8ddd90f59ed5efee [file] [log] [blame]
buyingyic73348c2012-11-02 00:31:31 +00001DROP TABLE lineitem;
2DROP TABLE q1_pricing_summary_report;
3
4-- create tables and load data
5Create external table lineitem (L_ORDERKEY INT, L_PARTKEY INT, L_SUPPKEY INT, L_LINENUMBER INT, 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) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE LOCATION '/tpch/10/lineitem';
6
7-- create the target table
8CREATE TABLE q1_pricing_summary_report ( L_RETURNFLAG STRING, L_LINESTATUS STRING, SUM_QTY DOUBLE, SUM_BASE_PRICE DOUBLE, SUM_DISC_PRICE DOUBLE, SUM_CHARGE DOUBLE, AVE_QTY DOUBLE, AVE_PRICE DOUBLE, AVE_DISC DOUBLE, COUNT_ORDER INT);
9
10set mapred.min.split.size=536870912;
11
12-- the query
13-- INSERT OVERWRITE TABLE q1_pricing_summary_report
14SELECT
15 L_RETURNFLAG, L_LINESTATUS, SUM(L_QUANTITY), SUM(L_EXTENDEDPRICE), SUM(L_EXTENDEDPRICE*(1-L_DISCOUNT)), SUM(L_EXTENDEDPRICE*(1-L_DISCOUNT)*(1+L_TAX)), AVG(L_QUANTITY), AVG(L_EXTENDEDPRICE), AVG(L_DISCOUNT), COUNT(1)
16FROM
17 lineitem
18WHERE
19 L_SHIPDATE<='1998-09-02'
20GROUP BY L_RETURNFLAG, L_LINESTATUS
21ORDER BY L_RETURNFLAG, L_LINESTATUS;