blob: 1899b5c2278b9f77c7a85602daa41d3228a47c8c [file] [log] [blame]
buyingyic73348c2012-11-02 00:31:31 +00001-- create tables and load data
2Create 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/100/lineitem';
3
4-- create the target table
5CREATE 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);
6
7set mapred.min.split.size=536870912;
8
9-- the query
10INSERT OVERWRITE TABLE q1_pricing_summary_report
11SELECT
12 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)
13FROM
14 lineitem
15WHERE
16 L_SHIPDATE<='1998-09-02'
17GROUP BY L_RETURNFLAG, L_LINESTATUS
18ORDER BY L_RETURNFLAG, L_LINESTATUS;
19
20DROP TABLE lineitem;
21DROP TABLE q1_pricing_summary_report;