├── 附件四(最新表).xlsx ├── Attachment5(Presto-HBase-Connector-PerformanceTesting).xlsx ├── Attachment6(Presto-HBase-Connector-PerformanceTesting-ClientSide).xlsx ├── 附件三(单表查询测试).sql ├── LICENSE ├── 附件二(TPC-DS查询测试).sql └── 附件一(表结构信息).sql /附件四(最新表).xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analysys/public-docs/HEAD/附件四(最新表).xlsx -------------------------------------------------------------------------------- /Attachment5(Presto-HBase-Connector-PerformanceTesting).xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analysys/public-docs/HEAD/Attachment5(Presto-HBase-Connector-PerformanceTesting).xlsx -------------------------------------------------------------------------------- /Attachment6(Presto-HBase-Connector-PerformanceTesting-ClientSide).xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/analysys/public-docs/HEAD/Attachment6(Presto-HBase-Connector-PerformanceTesting-ClientSide).xlsx -------------------------------------------------------------------------------- /附件三(单表查询测试).sql: -------------------------------------------------------------------------------- 1 | 1、select avg(ss_item_sk) from store_sales; 2 | 2、select ss_sold_Date_sk,count(*) as cnt from store_sales group by ss_sold_Date_sk order by cnt desc,ss_sold_Date_sk limit 10; 3 | 3、select ss_sold_Date_sk,avg(ss_item_sk) as cnt from store_sales group by ss_sold_Date_sk order by cnt desc,ss_sold_Date_sk limit 10; 4 | 4、select ss_item_sk,count(*) from store_sales group by ss_item_sk having count(*)>1 limit 10; 5 | 5、select sum(ss_item_sk) from store_sales; 6 | 6、select ss_sold_Date_sk,ss_wholesale_cost,avg(ss_item_sk) as cnt from store_sales group by ss_sold_Date_sk,ss_wholesale_cost order by cnt desc,ss_sold_Date_sk limit 10; 7 | 7、select ss_sold_Date_sk,ss_wholesale_cost,avg(ss_item_sk) as cnt from store_sales group by ss_sold_Date_sk,ss_wholesale_cost order by cnt desc,ss_sold_Date_sk limit 10; 8 | 9 | 8、select ss_sold_Date_sk,ss_wholesale_cost,avg(ss_item_sk) as cnt,count(distinct(ss_sales_price)) as avg1 from store_sales group by ss_sold_Date_sk,ss_wholesale_cost order by cnt desc,ss_sold_Date_sk limit 10; 10 | 11 | 9、select avg(ss_item_sk) as cnt,avg(ss_sales_price),count(distinct(ss_sales_price)) ,count(ss_item_sk) from store_sales group by ss_sold_Date_sk,ss_wholesale_cost order by cnt desc,ss_sold_Date_sk limit 10; 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /附件二(TPC-DS查询测试).sql: -------------------------------------------------------------------------------- 1 | 1、 2 | select i_item_id, 3 | avg(cs_quantity) agg1, 4 | avg(cs_list_price) agg2, 5 | avg(cs_coupon_amt) agg3, 6 | avg(cs_sales_price) agg4 7 | from catalog_sales, customer_demographics, date_dim, item, promotion 8 | where cs_sold_date_sk = d_date_sk and 9 | cs_item_sk = i_item_sk and 10 | cs_bill_cdemo_sk = cd_demo_sk and 11 | cs_promo_sk = p_promo_sk and 12 | cd_gender = 'M' and 13 | cd_marital_status = 'D' and 14 | cd_education_status = 'Advanced Degree' and 15 | (p_channel_email = 'N' or p_channel_event = 'N') and 16 | d_year = 1998 17 | group by i_item_id 18 | order by i_item_id 19 | limit 10; 20 | 21 | 2、 22 | select i_brand_id brand_id, i_brand brand, 23 | sum(ss_ext_sales_price) ext_price 24 | from date_dim, store_sales, item 25 | where d_date_sk = ss_sold_date_sk 26 | and ss_item_sk = i_item_sk 27 | and i_manager_id=25 28 | and d_moy=11 29 | and d_year=2002 30 | group by i_brand, i_brand_id 31 | order by ext_price desc, i_brand_id 32 | limit 10; 33 | 34 | 3、 35 | select channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM ( 36 | SELECT 'store' as channel, 'ss_promo_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price 37 | FROM store_sales, item, date_dim 38 | WHERE ss_promo_sk IS NULL 39 | AND ss_sold_date_sk=d_date_sk 40 | AND ss_item_sk=i_item_sk 41 | UNION ALL 42 | SELECT 'web' as channel, 'ws_ship_customer_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price 43 | FROM web_sales, item, date_dim 44 | WHERE ws_ship_customer_sk IS NULL 45 | AND ws_sold_date_sk=d_date_sk 46 | AND ws_item_sk=i_item_sk 47 | UNION ALL 48 | SELECT 'catalog' as channel, 'cs_bill_hdemo_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price 49 | FROM catalog_sales, item, date_dim 50 | WHERE cs_bill_hdemo_sk IS NULL 51 | AND cs_sold_date_sk=d_date_sk 52 | AND cs_item_sk=i_item_sk) foo 53 | GROUP BY channel, col_name, d_year, d_qoy, i_category 54 | ORDER BY channel, col_name, d_year, d_qoy, i_category 55 | limit 10; 56 | 57 | 4、 58 | select avg(ss_quantity) 59 | ,avg(ss_ext_sales_price) 60 | ,avg(ss_ext_wholesale_cost) 61 | ,sum(ss_ext_wholesale_cost) 62 | from store_sales 63 | ,store 64 | ,customer_demographics 65 | ,household_demographics 66 | ,customer_address 67 | ,date_dim 68 | where s_store_sk = ss_store_sk 69 | and ss_sold_date_sk = d_date_sk and d_year = 2001 70 | and((ss_hdemo_sk=hd_demo_sk 71 | and cd_demo_sk = ss_cdemo_sk 72 | and cd_marital_status = 'U' 73 | and cd_education_status = 'Secondary' 74 | and ss_sales_price between 100.00 and 150.00 75 | and hd_dep_count = 3 76 | )or 77 | (ss_hdemo_sk=hd_demo_sk 78 | and cd_demo_sk = ss_cdemo_sk 79 | and cd_marital_status = 'S' 80 | and cd_education_status = 'Advanced Degree' 81 | and ss_sales_price between 50.00 and 100.00 82 | and hd_dep_count = 1 83 | ) or 84 | (ss_hdemo_sk=hd_demo_sk 85 | and cd_demo_sk = ss_cdemo_sk 86 | and cd_marital_status = 'M' 87 | and cd_education_status = 'College' 88 | and ss_sales_price between 150.00 and 200.00 89 | and hd_dep_count = 1 90 | )) 91 | and((ss_addr_sk = ca_address_sk 92 | and ca_country = 'United States' 93 | and ca_state in ('AK', 'TX', 'WV') 94 | and ss_net_profit between 100 and 200 95 | ) or 96 | (ss_addr_sk = ca_address_sk 97 | and ca_country = 'United States' 98 | and ca_state in ('MT', 'NC', 'IN') 99 | and ss_net_profit between 150 and 300 100 | ) or 101 | (ss_addr_sk = ca_address_sk 102 | and ca_country = 'United States' 103 | and ca_state in ('MI', 'MO', 'KY') 104 | and ss_net_profit between 50 and 250 105 | )) 106 | limit 10; 107 | 108 | 109 | 5、 110 | select c_last_name 111 | ,c_first_name 112 | ,c_salutation 113 | ,c_preferred_cust_flag 114 | ,ss_ticket_number 115 | ,cnt from 116 | (select ss_ticket_number 117 | ,ss_customer_sk 118 | ,count(*) cnt 119 | from store_sales,date_dim,store,household_demographics 120 | where store_sales.ss_sold_date_sk = date_dim.d_date_sk 121 | and store_sales.ss_store_sk = store.s_store_sk 122 | and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk 123 | and date_dim.d_dom between 1 and 2 124 | and (household_demographics.hd_buy_potential = '>10000' or 125 | household_demographics.hd_buy_potential = '5001-10000') 126 | and household_demographics.hd_vehicle_count > 0 127 | and case when household_demographics.hd_vehicle_count > 0 then 128 | household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1 129 | and date_dim.d_year in (1999,1999+1,1999+2) 130 | and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County') 131 | group by ss_ticket_number,ss_customer_sk) dj,customer 132 | where ss_customer_sk = c_customer_sk 133 | and cnt between 1 and 5 134 | order by cnt desc, c_last_name asc; 135 | 136 | 137 | 6 select 138 | c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit 139 | from 140 | (select ss_ticket_number 141 | ,ss_customer_sk 142 | ,store.s_city 143 | ,sum(ss_coupon_amt) amt 144 | ,sum(ss_net_profit) profit 145 | from store_sales,date_dim,store,household_demographics 146 | where store_sales.ss_sold_date_sk = date_dim.d_date_sk 147 | and store_sales.ss_store_sk = store.s_store_sk 148 | and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk 149 | and (household_demographics.hd_dep_count = 1 or household_demographics.hd_vehicle_count > -1) 150 | and date_dim.d_dow = 1 151 | and date_dim.d_year in (2000,2000+1,2000+2) 152 | and store.s_number_employees between 200 and 295 153 | group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer 154 | where ss_customer_sk = c_customer_sk 155 | order by c_last_name,c_first_name,substr(s_city,1,30), profit 156 | limit 10 157 | ; 158 | 159 | 7、 160 | select sum (ss_quantity) 161 | from store_sales, store, customer_demographics, customer_address, date_dim 162 | where s_store_sk = ss_store_sk 163 | and ss_sold_date_sk = d_date_sk and d_year = 2000 164 | and 165 | ( 166 | ( 167 | cd_demo_sk = ss_cdemo_sk 168 | and 169 | cd_marital_status = 'S' 170 | and 171 | cd_education_status = 'Advanced Degree' 172 | and 173 | ss_sales_price between 100.00 and 150.00 174 | ) 175 | or 176 | ( 177 | cd_demo_sk = ss_cdemo_sk 178 | and 179 | cd_marital_status = 'D' 180 | and 181 | cd_education_status = '4 yr Degree' 182 | and 183 | ss_sales_price between 50.00 and 100.00 184 | ) 185 | or 186 | ( 187 | cd_demo_sk = ss_cdemo_sk 188 | and 189 | cd_marital_status = 'U' 190 | and 191 | cd_education_status = 'Secondary' 192 | and 193 | ss_sales_price between 150.00 and 200.00 194 | ) 195 | ) 196 | and 197 | ( 198 | ( 199 | ss_addr_sk = ca_address_sk 200 | and 201 | ca_country = 'United States' 202 | and 203 | ca_state in ('MN', 'TN', 'IL') 204 | and ss_net_profit between 0 and 2000 205 | ) 206 | or 207 | (ss_addr_sk = ca_address_sk 208 | and 209 | ca_country = 'United States' 210 | and 211 | ca_state in ('TX', 'OR', 'ID') 212 | and ss_net_profit between 150 and 3000 213 | ) 214 | or 215 | (ss_addr_sk = ca_address_sk 216 | and 217 | ca_country = 'United States' 218 | and 219 | ca_state in ('MI', 'AL', 'RI') 220 | and ss_net_profit between 50 and 25000 221 | ) 222 | ) 223 | ; 224 | 225 | 8 select i_item_id, 226 | avg(cs_quantity) agg1, 227 | avg(cs_list_price) agg2, 228 | avg(cs_coupon_amt) agg3, 229 | avg(cs_sales_price) agg4 230 | from catalog_sales, customer_demographics, date_dim, item, promotion 231 | where cs_sold_date_sk = d_date_sk and 232 | cs_item_sk = i_item_sk and 233 | cs_bill_cdemo_sk = cd_demo_sk and 234 | cs_promo_sk = p_promo_sk and 235 | cd_gender = 'M' and 236 | cd_marital_status = 'D' and 237 | cd_education_status = 'Advanced Degree' and 238 | (p_channel_email = 'N' or p_channel_event = 'N') and 239 | d_year = 1998 240 | group by i_item_id 241 | order by i_item_id 242 | limit 10 243 | ; 244 | 245 | 9、 246 | select distinct(i_product_name) 247 | from item i1 248 | where i_manufact_id between 761 and 761+40 249 | and (select count(*) as item_cnt 250 | from item 251 | where (i_manufact = i1.i_manufact and 252 | ((i_category = 'Women' and 253 | (i_color = 'midnight' or i_color = 'gainsboro') and 254 | (i_units = 'Box' or i_units = 'Carton') and 255 | (i_size = 'small' or i_size = 'large') 256 | ) or 257 | (i_category = 'Women' and 258 | (i_color = 'magenta' or i_color = 'chocolate') and 259 | (i_units = 'Lb' or i_units = 'Bunch') and 260 | (i_size = 'petite' or i_size = 'medium') 261 | ) or 262 | (i_category = 'Men' and 263 | (i_color = 'chartreuse' or i_color = 'chiffon') and 264 | (i_units = 'Tbl' or i_units = 'Dozen') and 265 | (i_size = 'economy' or i_size = 'extra large') 266 | ) or 267 | (i_category = 'Men' and 268 | (i_color = 'coral' or i_color = 'pale') and 269 | (i_units = 'Ton' or i_units = 'Bundle') and 270 | (i_size = 'small' or i_size = 'large') 271 | ))) or 272 | (i_manufact = i1.i_manufact and 273 | ((i_category = 'Women' and 274 | (i_color = 'burnished' or i_color = 'plum') and 275 | (i_units = 'Oz' or i_units = 'Each') and 276 | (i_size = 'small' or i_size = 'large') 277 | ) or 278 | (i_category = 'Women' and 279 | (i_color = 'misty' or i_color = 'mint') and 280 | (i_units = 'Ounce' or i_units = 'Tsp') and 281 | (i_size = 'petite' or i_size = 'medium') 282 | ) or 283 | (i_category = 'Men' and 284 | (i_color = 'dark' or i_color = 'olive') and 285 | (i_units = 'Dram' or i_units = 'Gross') and 286 | (i_size = 'economy' or i_size = 'extra large') 287 | ) or 288 | (i_category = 'Men' and 289 | (i_color = 'cornflower' or i_color = 'hot') and 290 | (i_units = 'Gram' or i_units = 'N/A') and 291 | (i_size = 'small' or i_size = 'large') 292 | )))) > 0 293 | order by i_product_name 294 | limit 10 295 | ; 296 | 297 | 10、 298 | select * 299 | from( 300 | select i_category, i_class, i_brand, 301 | s_store_name, s_company_name, 302 | d_moy, 303 | sum(ss_sales_price) sum_sales, 304 | avg(sum(ss_sales_price)) over 305 | (partition by i_category, i_brand, s_store_name, s_company_name) 306 | avg_monthly_sales 307 | from item, store_sales, date_dim, store 308 | where ss_item_sk = i_item_sk and 309 | ss_sold_date_sk = d_date_sk and 310 | ss_store_sk = s_store_sk and 311 | d_year in (1998) and 312 | ((i_category in ('Electronics','Men','Books') and 313 | i_class in ('cameras','shirts','entertainments') 314 | ) 315 | or (i_category in ('Music','Women','Jewelry') and 316 | i_class in ('classical','dresses','estate') 317 | )) 318 | group by i_category, i_class, i_brand, 319 | s_store_name, s_company_name, d_moy) tmp1 320 | where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1 321 | order by sum_sales - avg_monthly_sales, s_store_name 322 | limit 10 323 | ; 324 | 325 | 11 select sum (ss_quantity) 326 | from store_sales, store, customer_demographics, customer_address, date_dim 327 | where s_store_sk = ss_store_sk 328 | and ss_sold_date_sk = d_date_sk and d_year = 2000 329 | and 330 | ( 331 | ( 332 | cd_demo_sk = ss_cdemo_sk 333 | and 334 | cd_marital_status = 'S' 335 | and 336 | cd_education_status = 'Advanced Degree' 337 | and 338 | ss_sales_price between 100.00 and 150.00 339 | ) 340 | or 341 | ( 342 | cd_demo_sk = ss_cdemo_sk 343 | and 344 | cd_marital_status = 'D' 345 | and 346 | cd_education_status = '4 yr Degree' 347 | and 348 | ss_sales_price between 50.00 and 100.00 349 | ) 350 | or 351 | ( 352 | cd_demo_sk = ss_cdemo_sk 353 | and 354 | cd_marital_status = 'U' 355 | and 356 | cd_education_status = 'Secondary' 357 | and 358 | ss_sales_price between 150.00 and 200.00 359 | ) 360 | ) 361 | and 362 | ( 363 | ( 364 | ss_addr_sk = ca_address_sk 365 | and 366 | ca_country = 'United States' 367 | and 368 | ca_state in ('MN', 'TN', 'IL') 369 | and ss_net_profit between 0 and 2000 370 | ) 371 | or 372 | (ss_addr_sk = ca_address_sk 373 | and 374 | ca_country = 'United States' 375 | and 376 | ca_state in ('TX', 'OR', 'ID') 377 | and ss_net_profit between 150 and 3000 378 | ) 379 | or 380 | (ss_addr_sk = ca_address_sk 381 | and 382 | ca_country = 'United States' 383 | and 384 | ca_state in ('MI', 'AL', 'RI') 385 | and ss_net_profit between 50 and 25000 386 | ) 387 | ) 388 | ; 389 | 12 390 | select 391 | s_store_name, 392 | i_item_desc, 393 | sc.revenue, 394 | i_current_price, 395 | i_wholesale_cost, 396 | i_brand 397 | from store, item, 398 | (select ss_store_sk, avg(revenue) as ave 399 | from 400 | (select ss_store_sk, ss_item_sk, 401 | sum(ss_sales_price) as revenue 402 | from store_sales, date_dim 403 | where ss_sold_date_sk = d_date_sk and d_month_seq between 1177 and 1177+11 404 | group by ss_store_sk, ss_item_sk) sa 405 | group by ss_store_sk) sb, 406 | (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue 407 | from store_sales, date_dim 408 | where ss_sold_date_sk = d_date_sk and d_month_seq between 1177 and 1177+11 409 | group by ss_store_sk, ss_item_sk) sc 410 | where sb.ss_store_sk = sc.ss_store_sk and 411 | sc.revenue <= 0.1 * sb.ave and 412 | s_store_sk = sc.ss_store_sk and 413 | i_item_sk = sc.ss_item_sk 414 | order by s_store_name, i_item_desc 415 | limit 10 416 | ; 417 | 418 | select s_store_name,i_item_desc,sc.revenue,i_current_price,i_wholesale_cost,i_brand from store, item,(select ss_store_sk, avg(revenue) as ave from(select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue from store_sales, date_dim where ss_sold_date_sk = d_date_sk and d_month_seq between 1177 and 1177+11 group by ss_store_sk, ss_item_sk) sa group by ss_store_sk) sb,(select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue from store_sales, date_dim where ss_sold_date_sk = d_date_sk and d_month_seq between 1177 and 1177+11 group by ss_store_sk, ss_item_sk) sc where sb.ss_store_sk = sc.ss_store_sk and sc.revenue <= 0.1 * sb.ave and s_store_sk = sc.ss_store_sk and i_item_sk = sc.ss_item_sk order by s_store_name, i_item_desc limit 10; 419 | 420 | 421 | 13 422 | select * 423 | from 424 | (select count(*) h8_30_to_9 425 | from store_sales, household_demographics , time_dim, store 426 | where ss_sold_time_sk = time_dim.t_time_sk 427 | and ss_hdemo_sk = household_demographics.hd_demo_sk 428 | and ss_store_sk = s_store_sk 429 | and time_dim.t_hour = 8 430 | and time_dim.t_minute >= 30 431 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 432 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 433 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 434 | and store.s_store_name = 'ese') s1, 435 | (select count(*) h9_to_9_30 436 | from store_sales, household_demographics , time_dim, store 437 | where ss_sold_time_sk = time_dim.t_time_sk 438 | and ss_hdemo_sk = household_demographics.hd_demo_sk 439 | and ss_store_sk = s_store_sk 440 | and time_dim.t_hour = 9 441 | and time_dim.t_minute < 30 442 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 443 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 444 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 445 | and store.s_store_name = 'ese') s2, 446 | (select count(*) h9_30_to_10 447 | from store_sales, household_demographics , time_dim, store 448 | where ss_sold_time_sk = time_dim.t_time_sk 449 | and ss_hdemo_sk = household_demographics.hd_demo_sk 450 | and ss_store_sk = s_store_sk 451 | and time_dim.t_hour = 9 452 | and time_dim.t_minute >= 30 453 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 454 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 455 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 456 | and store.s_store_name = 'ese') s3, 457 | (select count(*) h10_to_10_30 458 | from store_sales, household_demographics , time_dim, store 459 | where ss_sold_time_sk = time_dim.t_time_sk 460 | and ss_hdemo_sk = household_demographics.hd_demo_sk 461 | and ss_store_sk = s_store_sk 462 | and time_dim.t_hour = 10 463 | and time_dim.t_minute < 30 464 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 465 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 466 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 467 | and store.s_store_name = 'ese') s4, 468 | (select count(*) h10_30_to_11 469 | from store_sales, household_demographics , time_dim, store 470 | where ss_sold_time_sk = time_dim.t_time_sk 471 | and ss_hdemo_sk = household_demographics.hd_demo_sk 472 | and ss_store_sk = s_store_sk 473 | and time_dim.t_hour = 10 474 | and time_dim.t_minute >= 30 475 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 476 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 477 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 478 | and store.s_store_name = 'ese') s5, 479 | (select count(*) h11_to_11_30 480 | from store_sales, household_demographics , time_dim, store 481 | where ss_sold_time_sk = time_dim.t_time_sk 482 | and ss_hdemo_sk = household_demographics.hd_demo_sk 483 | and ss_store_sk = s_store_sk 484 | and time_dim.t_hour = 11 485 | and time_dim.t_minute < 30 486 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 487 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 488 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 489 | and store.s_store_name = 'ese') s6, 490 | (select count(*) h11_30_to_12 491 | from store_sales, household_demographics , time_dim, store 492 | where ss_sold_time_sk = time_dim.t_time_sk 493 | and ss_hdemo_sk = household_demographics.hd_demo_sk 494 | and ss_store_sk = s_store_sk 495 | and time_dim.t_hour = 11 496 | and time_dim.t_minute >= 30 497 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 498 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 499 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 500 | and store.s_store_name = 'ese') s7, 501 | (select count(*) h12_to_12_30 502 | from store_sales, household_demographics , time_dim, store 503 | where ss_sold_time_sk = time_dim.t_time_sk 504 | and ss_hdemo_sk = household_demographics.hd_demo_sk 505 | and ss_store_sk = s_store_sk 506 | and time_dim.t_hour = 12 507 | and time_dim.t_minute < 30 508 | and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or 509 | (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or 510 | (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) 511 | and store.s_store_name = 'ese') s8 512 | ; 513 | 514 | select * from(select count(*) h8_30_to_9 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 8 and time_dim.t_minute >= 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or(household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) and store.s_store_name = 'ese') s1,(select count(*) h9_to_9_30 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 9 and time_dim.t_minute < 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or(household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or(household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2))and store.s_store_name = 'ese') s2,(select count(*) h9_30_to_10 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 9 and time_dim.t_minute >= 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or(household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2))and store.s_store_name = 'ese') s3,(select count(*) h10_to_10_30 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 10 and time_dim.t_minute < 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or(household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or(household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2))and store.s_store_name = 'ese') s4,(select count(*) h10_30_to_11 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 10 and time_dim.t_minute >= 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or(household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or(household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2))and store.s_store_name = 'ese') s5,(select count(*) h11_to_11_30 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 11 and time_dim.t_minute < 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or(household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2))and store.s_store_name = 'ese') s6,(select count(*) h11_30_to_12 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 11 and time_dim.t_minute >= 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or(household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) and store.s_store_name = 'ese') s7,(select count(*) h12_to_12_30 from store_sales, household_demographics , time_dim, store where ss_sold_time_sk = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk and time_dim.t_hour = 12 and time_dim.t_minute < 30 and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or(household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2) or (household_demographics.hd_dep_count = 4 and household_demographics.hd_vehicle_count<=4+2)) and store.s_store_name = 'ese') s8; 515 | 516 | 14、 517 | select count(*) from store_sales,household_demographics ,time_dim, store where ss_sold_time_sk 518 | = time_dim.t_time_sk and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk 519 | and time_dim.t_hour = 8 and time_dim.t_minute >= 30 and household_demographics.hd_dep_count = 5 and 520 | store.s_store_name = 'ese' order by count(*); 521 | 522 | 523 | 15 524 | select 525 | s_store_name 526 | ,s_company_id 527 | ,s_street_number 528 | ,s_street_name 529 | ,s_street_type 530 | ,s_suite_number 531 | ,s_city 532 | ,s_county 533 | ,s_state 534 | ,s_zip 535 | ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as a 536 | ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 537 | (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as b 538 | ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 539 | (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as c 540 | ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and 541 | (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as d 542 | ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as e 543 | from 544 | store_sales 545 | ,store_returns 546 | ,store 547 | ,date_dim d1 548 | ,date_dim d2 549 | where 550 | d2.d_year = 2000 551 | and d2.d_moy = 8 552 | and ss_ticket_number = sr_ticket_number 553 | and ss_item_sk = sr_item_sk 554 | and ss_sold_date_sk = d1.d_date_sk 555 | and sr_returned_date_sk = d2.d_date_sk 556 | and ss_customer_sk = sr_customer_sk 557 | and ss_store_sk = s_store_sk 558 | group by 559 | s_store_name 560 | ,s_company_id 561 | ,s_street_number 562 | ,s_street_name 563 | ,s_street_type 564 | ,s_suite_number 565 | ,s_city 566 | ,s_county 567 | ,s_state 568 | ,s_zip 569 | order by s_store_name 570 | ,s_company_id 571 | ,s_street_number 572 | ,s_street_name 573 | ,s_street_type 574 | ,s_suite_number 575 | ,s_city 576 | ,s_county 577 | ,s_state 578 | ,s_zip 579 | limit 10 580 | ; 581 | 582 | -------------------------------------------------------------------------------- /附件一(表结构信息).sql: -------------------------------------------------------------------------------- 1 | use hive_orc; 2 | create table dbgen_version 3 | ( 4 | dv_version varchar(16), 5 | dv_create_date date , 6 | dv_create_time varchar(40) , 7 | dv_cmdline_args varchar(200) 8 | ) 9 | row format delimited 10 | fields terminated by '|' 11 | lines terminated by '\n' 12 | stored as orc 13 | ; 14 | 15 | create table customer_address 16 | ( 17 | ca_address_sk int , 18 | ca_address_id char(16) , 19 | ca_street_number char(10), 20 | ca_street_name varchar(60) , 21 | ca_street_type char(15) , 22 | ca_suite_number char(10), 23 | ca_city varchar(60), 24 | ca_county varchar(30) , 25 | ca_state char(2) , 26 | ca_zip char(10) , 27 | ca_country varchar(20) , 28 | ca_gmt_offset decimal(5,2), 29 | ca_location_type char(20) 30 | ) 31 | row format delimited 32 | fields terminated by '|' 33 | lines terminated by '\n' 34 | stored as orc 35 | ; 36 | 37 | create table customer_demographics 38 | ( 39 | cd_demo_sk int , 40 | cd_gender char(1) , 41 | cd_marital_status char(1) , 42 | cd_education_status char(20) , 43 | cd_purchase_estimate int , 44 | cd_credit_rating char(10) , 45 | cd_dep_count int , 46 | cd_dep_employed_count int , 47 | cd_dep_college_count int 48 | ) 49 | row format delimited 50 | fields terminated by '|' 51 | lines terminated by '\n' 52 | stored as orc 53 | ; 54 | 55 | create table date_dim 56 | ( 57 | d_date_sk int , 58 | d_date_id char(16) , 59 | d_date date , 60 | d_month_seq int , 61 | d_week_seq int , 62 | d_quarter_seq int , 63 | d_year int , 64 | d_dow int , 65 | d_moy int , 66 | d_dom int , 67 | d_qoy int , 68 | d_fy_year int , 69 | d_fy_quarter_seq int , 70 | d_fy_week_seq int , 71 | d_day_name char(9) , 72 | d_quarter_name char(6) , 73 | d_holiday char(1) , 74 | d_weekend char(1) , 75 | d_following_holiday char(1) , 76 | d_first_dom int , 77 | d_last_dom int , 78 | d_same_day_ly int , 79 | d_same_day_lq int , 80 | d_current_day char(1) , 81 | d_current_week char(1) , 82 | d_current_month char(1) , 83 | d_current_quarter char(1) , 84 | d_current_year char(1) 85 | ) 86 | row format delimited 87 | fields terminated by '|' 88 | lines terminated by '\n' 89 | stored as orc 90 | ; 91 | 92 | create table warehouse 93 | ( 94 | w_warehouse_sk int , 95 | w_warehouse_id char(16) , 96 | w_warehouse_name varchar(20) , 97 | w_warehouse_sq_ft int , 98 | w_street_number char(10) , 99 | w_street_name varchar(60) , 100 | w_street_type char(15) , 101 | w_suite_number char(10) , 102 | w_city varchar(60) , 103 | w_county varchar(30) , 104 | w_state char(2) , 105 | w_zip char(10) , 106 | w_country varchar(20) , 107 | w_gmt_offset decimal(5,2) 108 | ) 109 | row format delimited 110 | fields terminated by '|' 111 | lines terminated by '\n' 112 | stored as orc 113 | ; 114 | 115 | create table ship_mode 116 | ( 117 | sm_ship_mode_sk int , 118 | sm_ship_mode_id char(16) , 119 | sm_type char(30) , 120 | sm_code char(10) , 121 | sm_carrier char(20) , 122 | sm_contract char(20) 123 | ) 124 | row format delimited 125 | fields terminated by '|' 126 | lines terminated by '\n' 127 | stored as orc 128 | ; 129 | 130 | create table time_dim 131 | ( 132 | t_time_sk int , 133 | t_time_id char(16) , 134 | t_time int , 135 | t_hour int , 136 | t_minute int , 137 | t_second int , 138 | t_am_pm char(2) , 139 | t_shift char(20) , 140 | t_sub_shift char(20) , 141 | t_meal_time char(20) 142 | ) 143 | row format delimited 144 | fields terminated by '|' 145 | lines terminated by '\n' 146 | stored as orc 147 | ; 148 | 149 | create table reason 150 | ( 151 | r_reason_sk int , 152 | r_reason_id char(16) , 153 | r_reason_desc char(100) 154 | ) 155 | row format delimited 156 | fields terminated by '|' 157 | lines terminated by '\n' 158 | stored as orc 159 | ; 160 | 161 | create table income_band 162 | ( 163 | ib_income_band_sk int , 164 | ib_lower_bound int , 165 | ib_upper_bound int 166 | ) 167 | row format delimited 168 | fields terminated by '|' 169 | lines terminated by '\n' 170 | stored as orc 171 | ; 172 | 173 | create table item 174 | ( 175 | i_item_sk int , 176 | i_item_id char(16) , 177 | i_rec_start_date date , 178 | i_rec_end_date date , 179 | i_item_desc varchar(200) , 180 | i_current_price decimal(7,2) , 181 | i_wholesale_cost decimal(7,2) , 182 | i_brand_id int , 183 | i_brand char(50) , 184 | i_class_id int , 185 | i_class char(50) , 186 | i_category_id int , 187 | i_category char(50) , 188 | i_manufact_id int , 189 | i_manufact char(50) , 190 | i_size char(20) , 191 | i_formulation char(20) , 192 | i_color char(20) , 193 | i_units char(10) , 194 | i_container char(10) , 195 | i_manager_id int , 196 | i_product_name char(50) 197 | ) 198 | row format delimited 199 | fields terminated by '|' 200 | lines terminated by '\n' 201 | stored as orc 202 | ; 203 | 204 | create table store 205 | ( 206 | s_store_sk int , 207 | s_store_id char(16) , 208 | s_rec_start_date date , 209 | s_rec_end_date date , 210 | s_closed_date_sk int , 211 | s_store_name varchar(50) , 212 | s_number_employees int , 213 | s_floor_space int , 214 | s_hours char(20) , 215 | s_manager varchar(40) , 216 | s_market_id int , 217 | s_geography_class varchar(100) , 218 | s_market_desc varchar(100) , 219 | s_market_manager varchar(40) , 220 | s_division_id int , 221 | s_division_name varchar(50) , 222 | s_company_id int , 223 | s_company_name varchar(50) , 224 | s_street_number varchar(10) , 225 | s_street_name varchar(60) , 226 | s_street_type char(15) , 227 | s_suite_number char(10) , 228 | s_city varchar(60) , 229 | s_county varchar(30) , 230 | s_state char(2) , 231 | s_zip char(10) , 232 | s_country varchar(20) , 233 | s_gmt_offset decimal(5,2) , 234 | s_tax_precentage decimal(5,2) 235 | ) 236 | row format delimited 237 | fields terminated by '|' 238 | lines terminated by '\n' 239 | stored as orc 240 | ; 241 | 242 | create table call_center 243 | ( 244 | cc_call_center_sk int , 245 | cc_call_center_id char(16) , 246 | cc_rec_start_date date , 247 | cc_rec_end_date date , 248 | cc_closed_date_sk int , 249 | cc_open_date_sk int , 250 | cc_name varchar(50) , 251 | cc_class varchar(50) , 252 | cc_employees int , 253 | cc_sq_ft int , 254 | cc_hours char(20) , 255 | cc_manager varchar(40) , 256 | cc_mkt_id int , 257 | cc_mkt_class char(50) , 258 | cc_mkt_desc varchar(100) , 259 | cc_market_manager varchar(40) , 260 | cc_division int , 261 | cc_division_name varchar(50) , 262 | cc_company int , 263 | cc_company_name char(50) , 264 | cc_street_number char(10) , 265 | cc_street_name varchar(60) , 266 | cc_street_type char(15) , 267 | cc_suite_number char(10) , 268 | cc_city varchar(60) , 269 | cc_county varchar(30) , 270 | cc_state char(2) , 271 | cc_zip char(10) , 272 | cc_country varchar(20) , 273 | cc_gmt_offset decimal(5,2) , 274 | cc_tax_percentage decimal(5,2) 275 | ) 276 | row format delimited 277 | fields terminated by '|' 278 | lines terminated by '\n' 279 | stored as orc 280 | ; 281 | 282 | create table customer 283 | ( 284 | c_customer_sk int , 285 | c_customer_id char(16) , 286 | c_current_cdemo_sk int , 287 | c_current_hdemo_sk int , 288 | c_current_addr_sk int , 289 | c_first_shipto_date_sk int , 290 | c_first_sales_date_sk int , 291 | c_salutation char(10) , 292 | c_first_name char(20) , 293 | c_last_name char(30) , 294 | c_preferred_cust_flag char(1) , 295 | c_birth_day int , 296 | c_birth_month int , 297 | c_birth_year int , 298 | c_birth_country varchar(20) , 299 | c_login char(13) , 300 | c_email_address char(50) , 301 | c_last_review_date char(10) 302 | ) 303 | row format delimited 304 | fields terminated by '|' 305 | lines terminated by '\n' 306 | stored as orc 307 | ; 308 | 309 | create table web_site 310 | ( 311 | web_site_sk int , 312 | web_site_id char(16) , 313 | web_rec_start_date date , 314 | web_rec_end_date date , 315 | web_name varchar(50) , 316 | web_open_date_sk int , 317 | web_close_date_sk int , 318 | web_class varchar(50) , 319 | web_manager varchar(40) , 320 | web_mkt_id int , 321 | web_mkt_class varchar(50) , 322 | web_mkt_desc varchar(100) , 323 | web_market_manager varchar(40) , 324 | web_company_id int , 325 | web_company_name char(50) , 326 | web_street_number char(10) , 327 | web_street_name varchar(60) , 328 | web_street_type char(15) , 329 | web_suite_number char(10) , 330 | web_city varchar(60) , 331 | web_county varchar(30) , 332 | web_state char(2) , 333 | web_zip char(10) , 334 | web_country varchar(20) , 335 | web_gmt_offset decimal(5,2) , 336 | web_tax_percentage decimal(5,2) 337 | ) 338 | row format delimited 339 | fields terminated by '|' 340 | lines terminated by '\n' 341 | stored as orc 342 | ; 343 | 344 | create table store_returns 345 | ( 346 | sr_returned_date_sk int , 347 | sr_return_time_sk int , 348 | sr_item_sk int , 349 | sr_customer_sk int , 350 | sr_cdemo_sk int , 351 | sr_hdemo_sk int , 352 | sr_addr_sk int , 353 | sr_store_sk int , 354 | sr_reason_sk int , 355 | sr_ticket_number int , 356 | sr_return_quantity int , 357 | sr_return_amt decimal(7,2) , 358 | sr_return_tax decimal(7,2) , 359 | sr_return_amt_inc_tax decimal(7,2) , 360 | sr_fee decimal(7,2) , 361 | sr_return_ship_cost decimal(7,2) , 362 | sr_refunded_cash decimal(7,2) , 363 | sr_reversed_charge decimal(7,2) , 364 | sr_store_credit decimal(7,2) , 365 | sr_net_loss decimal(7,2) 366 | 367 | ) 368 | row format delimited 369 | fields terminated by '|' 370 | lines terminated by '\n' 371 | stored as orc 372 | ; 373 | 374 | create table household_demographics 375 | ( 376 | hd_demo_sk int , 377 | hd_income_band_sk int , 378 | hd_buy_potential char(15) , 379 | hd_dep_count int , 380 | hd_vehicle_count int 381 | 382 | ) 383 | row format delimited 384 | fields terminated by '|' 385 | lines terminated by '\n' 386 | stored as orc 387 | ; 388 | 389 | create table web_page 390 | ( 391 | wp_web_page_sk int , 392 | wp_web_page_id char(16) , 393 | wp_rec_start_date date , 394 | wp_rec_end_date date , 395 | wp_creation_date_sk int , 396 | wp_access_date_sk int , 397 | wp_autogen_flag char(1) , 398 | wp_customer_sk int , 399 | wp_url varchar(100) , 400 | wp_type char(50) , 401 | wp_char_count int , 402 | wp_link_count int , 403 | wp_image_count int , 404 | wp_max_ad_count int 405 | ) 406 | row format delimited 407 | fields terminated by '|' 408 | lines terminated by '\n' 409 | stored as orc 410 | ; 411 | 412 | create table promotion 413 | ( 414 | p_promo_sk int , 415 | p_promo_id char(16) , 416 | p_start_date_sk int , 417 | p_end_date_sk int , 418 | p_item_sk int , 419 | p_cost decimal(15,2) , 420 | p_response_target int , 421 | p_promo_name char(50) , 422 | p_channel_dmail char(1) , 423 | p_channel_email char(1) , 424 | p_channel_catalog char(1) , 425 | p_channel_tv char(1) , 426 | p_channel_radio char(1) , 427 | p_channel_press char(1) , 428 | p_channel_event char(1) , 429 | p_channel_demo char(1) , 430 | p_channel_details varchar(100) , 431 | p_purpose char(15) , 432 | p_discount_active char(1) 433 | ) 434 | row format delimited 435 | fields terminated by '|' 436 | lines terminated by '\n' 437 | stored as orc 438 | ; 439 | 440 | create table catalog_page 441 | ( 442 | cp_catalog_page_sk int , 443 | cp_catalog_page_id char(16) , 444 | cp_start_date_sk int , 445 | cp_end_date_sk int , 446 | cp_department varchar(50) , 447 | cp_catalog_number int , 448 | cp_catalog_page_number int , 449 | cp_description varchar(100) , 450 | cp_type varchar(100) 451 | ) 452 | row format delimited 453 | fields terminated by '|' 454 | lines terminated by '\n' 455 | stored as orc 456 | ; 457 | 458 | create table inventory 459 | ( 460 | inv_date_sk int , 461 | inv_item_sk int , 462 | inv_warehouse_sk int , 463 | inv_quantity_on_hand int 464 | ) 465 | row format delimited 466 | fields terminated by '|' 467 | lines terminated by '\n' 468 | stored as orc 469 | ; 470 | 471 | create table catalog_returns 472 | ( 473 | cr_returned_date_sk int , 474 | cr_returned_time_sk int , 475 | cr_item_sk int , 476 | cr_refunded_customer_sk int , 477 | cr_refunded_cdemo_sk int , 478 | cr_refunded_hdemo_sk int , 479 | cr_refunded_addr_sk int , 480 | cr_returning_customer_sk int , 481 | cr_returning_cdemo_sk int , 482 | cr_returning_hdemo_sk int , 483 | cr_returning_addr_sk int , 484 | cr_call_center_sk int , 485 | cr_catalog_page_sk int , 486 | cr_ship_mode_sk int , 487 | cr_warehouse_sk int , 488 | cr_reason_sk int , 489 | cr_order_number int , 490 | cr_return_quantity int , 491 | cr_return_amount decimal(7,2) , 492 | cr_return_tax decimal(7,2) , 493 | cr_return_amt_inc_tax decimal(7,2) , 494 | cr_fee decimal(7,2) , 495 | cr_return_ship_cost decimal(7,2) , 496 | cr_refunded_cash decimal(7,2) , 497 | cr_reversed_charge decimal(7,2) , 498 | cr_store_credit decimal(7,2) , 499 | cr_net_loss decimal(7,2) 500 | ) 501 | row format delimited 502 | fields terminated by '|' 503 | lines terminated by '\n' 504 | stored as orc 505 | ; 506 | 507 | create table web_returns 508 | ( 509 | wr_returned_date_sk int , 510 | wr_returned_time_sk int , 511 | wr_item_sk int , 512 | wr_refunded_customer_sk int , 513 | wr_refunded_cdemo_sk int , 514 | wr_refunded_hdemo_sk int , 515 | wr_refunded_addr_sk int , 516 | wr_returning_customer_sk int , 517 | wr_returning_cdemo_sk int , 518 | wr_returning_hdemo_sk int , 519 | wr_returning_addr_sk int , 520 | wr_web_page_sk int , 521 | wr_reason_sk int , 522 | wr_order_number int , 523 | wr_return_quantity int , 524 | wr_return_amt decimal(7,2) , 525 | wr_return_tax decimal(7,2) , 526 | wr_return_amt_inc_tax decimal(7,2) , 527 | wr_fee decimal(7,2) , 528 | wr_return_ship_cost decimal(7,2) , 529 | wr_refunded_cash decimal(7,2) , 530 | wr_reversed_charge decimal(7,2) , 531 | wr_account_credit decimal(7,2) , 532 | wr_net_loss decimal(7,2) 533 | ) 534 | row format delimited 535 | fields terminated by '|' 536 | lines terminated by '\n' 537 | stored as orc 538 | ; 539 | 540 | create table web_sales 541 | ( 542 | ws_sold_date_sk int , 543 | ws_sold_time_sk int , 544 | ws_ship_date_sk int , 545 | ws_item_sk int , 546 | ws_bill_customer_sk int , 547 | ws_bill_cdemo_sk int , 548 | ws_bill_hdemo_sk int , 549 | ws_bill_addr_sk int , 550 | ws_ship_customer_sk int , 551 | ws_ship_cdemo_sk int , 552 | ws_ship_hdemo_sk int , 553 | ws_ship_addr_sk int , 554 | ws_web_page_sk int , 555 | ws_web_site_sk int , 556 | ws_ship_mode_sk int , 557 | ws_warehouse_sk int , 558 | ws_promo_sk int , 559 | ws_order_number int , 560 | ws_quantity int , 561 | ws_wholesale_cost decimal(7,2) , 562 | ws_list_price decimal(7,2) , 563 | ws_sales_price decimal(7,2) , 564 | ws_ext_discount_amt decimal(7,2) , 565 | ws_ext_sales_price decimal(7,2) , 566 | ws_ext_wholesale_cost decimal(7,2) , 567 | ws_ext_list_price decimal(7,2) , 568 | ws_ext_tax decimal(7,2) , 569 | ws_coupon_amt decimal(7,2) , 570 | ws_ext_ship_cost decimal(7,2) , 571 | ws_net_paid decimal(7,2) , 572 | ws_net_paid_inc_tax decimal(7,2) , 573 | ws_net_paid_inc_ship decimal(7,2) , 574 | ws_net_paid_inc_ship_tax decimal(7,2) , 575 | ws_net_profit decimal(7,2) 576 | ) 577 | row format delimited 578 | fields terminated by '|' 579 | lines terminated by '\n' 580 | stored as orc 581 | ; 582 | 583 | create table catalog_sales 584 | ( 585 | cs_sold_date_sk int , 586 | cs_sold_time_sk int , 587 | cs_ship_date_sk int , 588 | cs_bill_customer_sk int , 589 | cs_bill_cdemo_sk int , 590 | cs_bill_hdemo_sk int , 591 | cs_bill_addr_sk int , 592 | cs_ship_customer_sk int , 593 | cs_ship_cdemo_sk int , 594 | cs_ship_hdemo_sk int , 595 | cs_ship_addr_sk int , 596 | cs_call_center_sk int , 597 | cs_catalog_page_sk int , 598 | cs_ship_mode_sk int , 599 | cs_warehouse_sk int , 600 | cs_item_sk int , 601 | cs_promo_sk int , 602 | cs_order_number int , 603 | cs_quantity int , 604 | cs_wholesale_cost decimal(7,2) , 605 | cs_list_price decimal(7,2) , 606 | cs_sales_price decimal(7,2) , 607 | cs_ext_discount_amt decimal(7,2) , 608 | cs_ext_sales_price decimal(7,2) , 609 | cs_ext_wholesale_cost decimal(7,2) , 610 | cs_ext_list_price decimal(7,2) , 611 | cs_ext_tax decimal(7,2) , 612 | cs_coupon_amt decimal(7,2) , 613 | cs_ext_ship_cost decimal(7,2) , 614 | cs_net_paid decimal(7,2) , 615 | cs_net_paid_inc_tax decimal(7,2) , 616 | cs_net_paid_inc_ship decimal(7,2) , 617 | cs_net_paid_inc_ship_tax decimal(7,2) , 618 | cs_net_profit decimal(7,2) 619 | ) 620 | row format delimited 621 | fields terminated by '|' 622 | lines terminated by '\n' 623 | stored as orc 624 | ; 625 | 626 | create table store_sales 627 | ( 628 | ss_sold_date_sk int , 629 | ss_sold_time_sk int , 630 | ss_item_sk int , 631 | ss_customer_sk int , 632 | ss_cdemo_sk int , 633 | ss_hdemo_sk int , 634 | ss_addr_sk int , 635 | ss_store_sk int , 636 | ss_promo_sk int , 637 | ss_ticket_number int , 638 | ss_quantity int , 639 | ss_wholesale_cost decimal(7,2) , 640 | ss_list_price decimal(7,2) , 641 | ss_sales_price decimal(7,2) , 642 | ss_ext_discount_amt decimal(7,2) , 643 | ss_ext_sales_price decimal(7,2) , 644 | ss_ext_wholesale_cost decimal(7,2) , 645 | ss_ext_list_price decimal(7,2) , 646 | ss_ext_tax decimal(7,2) , 647 | ss_coupon_amt decimal(7,2) , 648 | ss_net_paid decimal(7,2) , 649 | ss_net_paid_inc_tax decimal(7,2) , 650 | ss_net_profit decimal(7,2) 651 | ) 652 | row format delimited 653 | fields terminated by '|' 654 | lines terminated by '\n' 655 | stored as orc 656 | ; 657 | 658 | 659 | --------------------------------------------------------------------------------