buyingyi | cf48fb5 | 2012-11-02 00:31:31 +0000 | [diff] [blame^] | 1 | DROP TABLE IF EXISTS nation; |
| 2 | DROP TABLE IF EXISTS u10_nestedloop_join; |
| 3 | |
| 4 | -- create tables and load data |
| 5 | create external table nation (N_NATIONKEY INT, N_NAME STRING, N_REGIONKEY INT, N_COMMENT STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE LOCATION '/tpch/nation'; |
| 6 | |
| 7 | -- create the target table |
| 8 | create table u10_nestedloop_join(supp_nation string, cust_nation string, s_nationkey int, c_nationkey int); |
| 9 | |
| 10 | -- the query |
| 11 | insert overwrite table u10_nestedloop_join |
| 12 | select |
| 13 | * |
| 14 | from |
| 15 | ( |
| 16 | select |
| 17 | n1.n_name as supp_nation, n2.n_name as cust_nation, n1.n_nationkey as s_nationkey, |
| 18 | n2.n_nationkey as c_nationkey |
| 19 | from |
| 20 | nation n1 join nation n2 where n1.n_nationkey > n2.n_nationkey |
| 21 | ) a; |