alltables.sql 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. create database if not exists ${DB};
  2. use ${DB};
  3. drop table if exists call_center;
  4. create external table call_center(
  5. cc_call_center_sk int
  6. , cc_call_center_id string
  7. , cc_rec_start_date string
  8. , cc_rec_end_date string
  9. , cc_closed_date_sk int
  10. , cc_open_date_sk int
  11. , cc_name string
  12. , cc_class string
  13. , cc_employees int
  14. , cc_sq_ft int
  15. , cc_hours string
  16. , cc_manager string
  17. , cc_mkt_id int
  18. , cc_mkt_class string
  19. , cc_mkt_desc string
  20. , cc_market_manager string
  21. , cc_division int
  22. , cc_division_name string
  23. , cc_company int
  24. , cc_company_name string
  25. , cc_street_number string
  26. , cc_street_name string
  27. , cc_street_type string
  28. , cc_suite_number string
  29. , cc_city string
  30. , cc_county string
  31. , cc_state string
  32. , cc_zip string
  33. , cc_country string
  34. , cc_gmt_offset float
  35. , cc_tax_percentage float
  36. )
  37. row format delimited fields terminated by '|'
  38. location '${LOCATION}/call_center';
  39. create database if not exists ${DB};
  40. use ${DB};
  41. drop table if exists catalog_page;
  42. create external table catalog_page(
  43. cp_catalog_page_sk int
  44. , cp_catalog_page_id string
  45. , cp_start_date_sk int
  46. , cp_end_date_sk int
  47. , cp_department string
  48. , cp_catalog_number int
  49. , cp_catalog_page_number int
  50. , cp_description string
  51. , cp_type string
  52. )
  53. row format delimited fields terminated by '|'
  54. location '${LOCATION}/catalog_page';
  55. create database if not exists ${DB};
  56. use ${DB};
  57. drop table if exists catalog_returns;
  58. create external table catalog_returns
  59. (
  60. cr_returned_date_sk int,
  61. cr_returned_time_sk int,
  62. cr_item_sk int,
  63. cr_refunded_customer_sk int,
  64. cr_refunded_cdemo_sk int,
  65. cr_refunded_hdemo_sk int,
  66. cr_refunded_addr_sk int,
  67. cr_returning_customer_sk int,
  68. cr_returning_cdemo_sk int,
  69. cr_returning_hdemo_sk int,
  70. cr_returning_addr_sk int,
  71. cr_call_center_sk int,
  72. cr_catalog_page_sk int,
  73. cr_ship_mode_sk int,
  74. cr_warehouse_sk int,
  75. cr_reason_sk int,
  76. cr_order_number int,
  77. cr_return_quantity int,
  78. cr_return_amount float,
  79. cr_return_tax float,
  80. cr_return_amt_inc_tax float,
  81. cr_fee float,
  82. cr_return_ship_cost float,
  83. cr_refunded_cash float,
  84. cr_reversed_charge float,
  85. cr_store_credit float,
  86. cr_net_loss float
  87. )
  88. row format delimited fields terminated by '|'
  89. location '${LOCATION}/catalog_returns';
  90. create database if not exists ${DB};
  91. use ${DB};
  92. drop table if exists catalog_sales;
  93. create external table catalog_sales
  94. (
  95. cs_sold_date_sk int,
  96. cs_sold_time_sk int,
  97. cs_ship_date_sk int,
  98. cs_bill_customer_sk int,
  99. cs_bill_cdemo_sk int,
  100. cs_bill_hdemo_sk int,
  101. cs_bill_addr_sk int,
  102. cs_ship_customer_sk int,
  103. cs_ship_cdemo_sk int,
  104. cs_ship_hdemo_sk int,
  105. cs_ship_addr_sk int,
  106. cs_call_center_sk int,
  107. cs_catalog_page_sk int,
  108. cs_ship_mode_sk int,
  109. cs_warehouse_sk int,
  110. cs_item_sk int,
  111. cs_promo_sk int,
  112. cs_order_number int,
  113. cs_quantity int,
  114. cs_wholesale_cost float,
  115. cs_list_price float,
  116. cs_sales_price float,
  117. cs_ext_discount_amt float,
  118. cs_ext_sales_price float,
  119. cs_ext_wholesale_cost float,
  120. cs_ext_list_price float,
  121. cs_ext_tax float,
  122. cs_coupon_amt float,
  123. cs_ext_ship_cost float,
  124. cs_net_paid float,
  125. cs_net_paid_inc_tax float,
  126. cs_net_paid_inc_ship float,
  127. cs_net_paid_inc_ship_tax float,
  128. cs_net_profit float
  129. )
  130. row format delimited fields terminated by '|'
  131. location '${LOCATION}/catalog_sales';
  132. create database if not exists ${DB};
  133. use ${DB};
  134. drop table if exists customer_address;
  135. create external table customer_address
  136. (
  137. ca_address_sk int,
  138. ca_address_id string,
  139. ca_street_number string,
  140. ca_street_name string,
  141. ca_street_type string,
  142. ca_suite_number string,
  143. ca_city string,
  144. ca_county string,
  145. ca_state string,
  146. ca_zip string,
  147. ca_country string,
  148. ca_gmt_offset float,
  149. ca_location_type string
  150. )
  151. row format delimited fields terminated by '|'
  152. location '${LOCATION}/customer_address';
  153. create database if not exists ${DB};
  154. use ${DB};
  155. drop table if exists customer_demographics;
  156. create external table customer_demographics
  157. (
  158. cd_demo_sk int,
  159. cd_gender string,
  160. cd_marital_status string,
  161. cd_education_status string,
  162. cd_purchase_estimate int,
  163. cd_credit_rating string,
  164. cd_dep_count int,
  165. cd_dep_employed_count int,
  166. cd_dep_college_count int
  167. )
  168. row format delimited fields terminated by '|'
  169. location '${LOCATION}/customer_demographics';
  170. create database if not exists ${DB};
  171. use ${DB};
  172. drop table if exists customer;
  173. create external table customer
  174. (
  175. c_customer_sk int,
  176. c_customer_id string,
  177. c_current_cdemo_sk int,
  178. c_current_hdemo_sk int,
  179. c_current_addr_sk int,
  180. c_first_shipto_date_sk int,
  181. c_first_sales_date_sk int,
  182. c_salutation string,
  183. c_first_name string,
  184. c_last_name string,
  185. c_preferred_cust_flag string,
  186. c_birth_day int,
  187. c_birth_month int,
  188. c_birth_year int,
  189. c_birth_country string,
  190. c_login string,
  191. c_email_address string,
  192. c_last_review_date string
  193. )
  194. row format delimited fields terminated by '|'
  195. location '${LOCATION}/customer';
  196. create database if not exists ${DB};
  197. use ${DB};
  198. drop table if exists date_dim;
  199. create external table date_dim
  200. (
  201. d_date_sk int,
  202. d_date_id string,
  203. d_date string,
  204. d_month_seq int,
  205. d_week_seq int,
  206. d_quarter_seq int,
  207. d_year int,
  208. d_dow int,
  209. d_moy int,
  210. d_dom int,
  211. d_qoy int,
  212. d_fy_year int,
  213. d_fy_quarter_seq int,
  214. d_fy_week_seq int,
  215. d_day_name string,
  216. d_quarter_name string,
  217. d_holiday string,
  218. d_weekend string,
  219. d_following_holiday string,
  220. d_first_dom int,
  221. d_last_dom int,
  222. d_same_day_ly int,
  223. d_same_day_lq int,
  224. d_current_day string,
  225. d_current_week string,
  226. d_current_month string,
  227. d_current_quarter string,
  228. d_current_year string
  229. )
  230. row format delimited fields terminated by '|'
  231. location '${LOCATION}/date_dim';
  232. create database if not exists ${DB};
  233. use ${DB};
  234. drop table if exists household_demographics;
  235. create external table household_demographics
  236. (
  237. hd_demo_sk int,
  238. hd_income_band_sk int,
  239. hd_buy_potential string,
  240. hd_dep_count int,
  241. hd_vehicle_count int
  242. )
  243. row format delimited fields terminated by '|'
  244. location '${LOCATION}/household_demographics';
  245. create database if not exists ${DB};
  246. use ${DB};
  247. drop table if exists income_band;
  248. create external table income_band(
  249. ib_income_band_sk int
  250. , ib_lower_bound int
  251. , ib_upper_bound int
  252. )
  253. row format delimited fields terminated by '|'
  254. location '${LOCATION}/income_band';
  255. create database if not exists ${DB};
  256. use ${DB};
  257. drop table if exists inventory;
  258. create external table inventory
  259. (
  260. inv_date_sk int,
  261. inv_item_sk int,
  262. inv_warehouse_sk int,
  263. inv_quantity_on_hand int
  264. )
  265. row format delimited fields terminated by '|'
  266. location '${LOCATION}/inventory';
  267. create database if not exists ${DB};
  268. use ${DB};
  269. drop table if exists item;
  270. create external table item
  271. (
  272. i_item_sk int,
  273. i_item_id string,
  274. i_rec_start_date string,
  275. i_rec_end_date string,
  276. i_item_desc string,
  277. i_current_price float,
  278. i_wholesale_cost float,
  279. i_brand_id int,
  280. i_brand string,
  281. i_class_id int,
  282. i_class string,
  283. i_category_id int,
  284. i_category string,
  285. i_manufact_id int,
  286. i_manufact string,
  287. i_size string,
  288. i_formulation string,
  289. i_color string,
  290. i_units string,
  291. i_container string,
  292. i_manager_id int,
  293. i_product_name string
  294. )
  295. row format delimited fields terminated by '|'
  296. location '${LOCATION}/item';
  297. create database if not exists ${DB};
  298. use ${DB};
  299. drop table if exists promotion;
  300. create external table promotion
  301. (
  302. p_promo_sk int,
  303. p_promo_id string,
  304. p_start_date_sk int,
  305. p_end_date_sk int,
  306. p_item_sk int,
  307. p_cost float,
  308. p_response_target int,
  309. p_promo_name string,
  310. p_channel_dmail string,
  311. p_channel_email string,
  312. p_channel_catalog string,
  313. p_channel_tv string,
  314. p_channel_radio string,
  315. p_channel_press string,
  316. p_channel_event string,
  317. p_channel_demo string,
  318. p_channel_details string,
  319. p_purpose string,
  320. p_discount_active string
  321. )
  322. row format delimited fields terminated by '|'
  323. location '${LOCATION}/promotion';
  324. create database if not exists ${DB};
  325. use ${DB};
  326. drop table if exists reason;
  327. create external table reason(
  328. r_reason_sk int
  329. , r_reason_id string
  330. , r_reason_desc string
  331. )
  332. row format delimited fields terminated by '|'
  333. location '${LOCATION}/reason';
  334. create database if not exists ${DB};
  335. use ${DB};
  336. drop table if exists ship_mode;
  337. create external table ship_mode(
  338. sm_ship_mode_sk int
  339. , sm_ship_mode_id string
  340. , sm_type string
  341. , sm_code string
  342. , sm_carrier string
  343. , sm_contract string
  344. )
  345. row format delimited fields terminated by '|'
  346. location '${LOCATION}/ship_model';
  347. create database if not exists ${DB};
  348. use ${DB};
  349. drop table if exists store_returns;
  350. create external table store_returns
  351. (
  352. sr_returned_date_sk int,
  353. sr_return_time_sk int,
  354. sr_item_sk int,
  355. sr_customer_sk int,
  356. sr_cdemo_sk int,
  357. sr_hdemo_sk int,
  358. sr_addr_sk int,
  359. sr_store_sk int,
  360. sr_reason_sk int,
  361. sr_ticket_number int,
  362. sr_return_quantity int,
  363. sr_return_amt float,
  364. sr_return_tax float,
  365. sr_return_amt_inc_tax float,
  366. sr_fee float,
  367. sr_return_ship_cost float,
  368. sr_refunded_cash float,
  369. sr_reversed_charge float,
  370. sr_store_credit float,
  371. sr_net_loss float
  372. )
  373. row format delimited fields terminated by '|'
  374. location '${LOCATION}/store_returns';
  375. create database if not exists ${DB};
  376. use ${DB};
  377. drop table if exists store_sales;
  378. create external table store_sales
  379. (
  380. ss_sold_date_sk int,
  381. ss_sold_time_sk int,
  382. ss_item_sk int,
  383. ss_customer_sk int,
  384. ss_cdemo_sk int,
  385. ss_hdemo_sk int,
  386. ss_addr_sk int,
  387. ss_store_sk int,
  388. ss_promo_sk int,
  389. ss_ticket_number int,
  390. ss_quantity int,
  391. ss_wholesale_cost float,
  392. ss_list_price float,
  393. ss_sales_price float,
  394. ss_ext_discount_amt float,
  395. ss_ext_sales_price float,
  396. ss_ext_wholesale_cost float,
  397. ss_ext_list_price float,
  398. ss_ext_tax float,
  399. ss_coupon_amt float,
  400. ss_net_paid float,
  401. ss_net_paid_inc_tax float,
  402. ss_net_profit float
  403. )
  404. row format delimited fields terminated by '|'
  405. location '${LOCATION}/store_sales';
  406. create database if not exists ${DB};
  407. use ${DB};
  408. drop table if exists store;
  409. create external table store
  410. (
  411. s_store_sk int,
  412. s_store_id string,
  413. s_rec_start_date string,
  414. s_rec_end_date string,
  415. s_closed_date_sk int,
  416. s_store_name string,
  417. s_number_employees int,
  418. s_floor_space int,
  419. s_hours string,
  420. s_manager string,
  421. s_market_id int,
  422. s_geography_class string,
  423. s_market_desc string,
  424. s_market_manager string,
  425. s_division_id int,
  426. s_division_name string,
  427. s_company_id int,
  428. s_company_name string,
  429. s_street_number string,
  430. s_street_name string,
  431. s_street_type string,
  432. s_suite_number string,
  433. s_city string,
  434. s_county string,
  435. s_state string,
  436. s_zip string,
  437. s_country string,
  438. s_gmt_offset float,
  439. s_tax_precentage float
  440. )
  441. row format delimited fields terminated by '|'
  442. location '${LOCATION}/store';
  443. create database if not exists ${DB};
  444. use ${DB};
  445. drop table if exists time_dim;
  446. create external table time_dim
  447. (
  448. t_time_sk int,
  449. t_time_id string,
  450. t_time int,
  451. t_hour int,
  452. t_minute int,
  453. t_second int,
  454. t_am_pm string,
  455. t_shift string,
  456. t_sub_shift string,
  457. t_meal_time string
  458. )
  459. row format delimited fields terminated by '|'
  460. location '${LOCATION}/time_dim';
  461. create database if not exists ${DB};
  462. use ${DB};
  463. drop table if exists warehouse;
  464. create external table warehouse(
  465. w_warehouse_sk int
  466. , w_warehouse_id string
  467. , w_warehouse_name string
  468. , w_warehouse_sq_ft int
  469. , w_street_number string
  470. , w_street_name string
  471. , w_street_type string
  472. , w_suite_number string
  473. , w_city string
  474. , w_county string
  475. , w_state string
  476. , w_zip string
  477. , w_country string
  478. , w_gmt_offset float
  479. )
  480. row format delimited fields terminated by '|'
  481. location '${LOCATION}/warehouse';
  482. create database if not exists ${DB};
  483. use ${DB};
  484. drop table if exists web_page;
  485. create external table web_page(
  486. wp_web_page_sk int
  487. , wp_web_page_id string
  488. , wp_rec_start_date string
  489. , wp_rec_end_date string
  490. , wp_creation_date_sk int
  491. , wp_access_date_sk int
  492. , wp_autogen_flag string
  493. , wp_customer_sk int
  494. , wp_url string
  495. , wp_type string
  496. , wp_char_count int
  497. , wp_link_count int
  498. , wp_image_count int
  499. , wp_max_ad_count int
  500. )
  501. row format delimited fields terminated by '|'
  502. location '${LOCATION}/web_page';
  503. create database if not exists ${DB};
  504. use ${DB};
  505. drop table if exists web_returns;
  506. create external table web_returns
  507. (
  508. wr_returned_date_sk int,
  509. wr_returned_time_sk int,
  510. wr_item_sk int,
  511. wr_refunded_customer_sk int,
  512. wr_refunded_cdemo_sk int,
  513. wr_refunded_hdemo_sk int,
  514. wr_refunded_addr_sk int,
  515. wr_returning_customer_sk int,
  516. wr_returning_cdemo_sk int,
  517. wr_returning_hdemo_sk int,
  518. wr_returning_addr_sk int,
  519. wr_web_page_sk int,
  520. wr_reason_sk int,
  521. wr_order_number int,
  522. wr_return_quantity int,
  523. wr_return_amt float,
  524. wr_return_tax float,
  525. wr_return_amt_inc_tax float,
  526. wr_fee float,
  527. wr_return_ship_cost float,
  528. wr_refunded_cash float,
  529. wr_reversed_charge float,
  530. wr_account_credit float,
  531. wr_net_loss float
  532. )
  533. row format delimited fields terminated by '|'
  534. location '${LOCATION}/web_returns';
  535. create database if not exists ${DB};
  536. use ${DB};
  537. drop table if exists web_sales;
  538. create external table web_sales
  539. (
  540. ws_sold_date_sk int,
  541. ws_sold_time_sk int,
  542. ws_ship_date_sk int,
  543. ws_item_sk int,
  544. ws_bill_customer_sk int,
  545. ws_bill_cdemo_sk int,
  546. ws_bill_hdemo_sk int,
  547. ws_bill_addr_sk int,
  548. ws_ship_customer_sk int,
  549. ws_ship_cdemo_sk int,
  550. ws_ship_hdemo_sk int,
  551. ws_ship_addr_sk int,
  552. ws_web_page_sk int,
  553. ws_web_site_sk int,
  554. ws_ship_mode_sk int,
  555. ws_warehouse_sk int,
  556. ws_promo_sk int,
  557. ws_order_number int,
  558. ws_quantity int,
  559. ws_wholesale_cost float,
  560. ws_list_price float,
  561. ws_sales_price float,
  562. ws_ext_discount_amt float,
  563. ws_ext_sales_price float,
  564. ws_ext_wholesale_cost float,
  565. ws_ext_list_price float,
  566. ws_ext_tax float,
  567. ws_coupon_amt float,
  568. ws_ext_ship_cost float,
  569. ws_net_paid float,
  570. ws_net_paid_inc_tax float,
  571. ws_net_paid_inc_ship float,
  572. ws_net_paid_inc_ship_tax float,
  573. ws_net_profit float
  574. )
  575. row format delimited fields terminated by '|'
  576. location '${LOCATION}/web_sales';
  577. create database if not exists ${DB};
  578. use ${DB};
  579. drop table if exists web_site;
  580. create external table web_site
  581. (
  582. web_site_sk int,
  583. web_site_id string,
  584. web_rec_start_date string,
  585. web_rec_end_date string,
  586. web_name string,
  587. web_open_date_sk int,
  588. web_close_date_sk int,
  589. web_class string,
  590. web_manager string,
  591. web_mkt_id int,
  592. web_mkt_class string,
  593. web_mkt_desc string,
  594. web_market_manager string,
  595. web_company_id int,
  596. web_company_name string,
  597. web_street_number string,
  598. web_street_name string,
  599. web_street_type string,
  600. web_suite_number string,
  601. web_city string,
  602. web_county string,
  603. web_state string,
  604. web_zip string,
  605. web_country string,
  606. web_gmt_offset float,
  607. web_tax_percentage float
  608. )
  609. row format delimited fields terminated by '|'
  610. location '${LOCATION}/web_site';