Showing preview only (536K chars total). Download the full file or copy to clipboard to get everything.
Repository: hortonworks/hive-testbench
Branch: hdp3
Commit: 35dd91a1d614
Files: 302
Total size: 473.3 KB
Directory structure:
gitextract_i96bxtes/
├── .gitignore
├── README.md
├── ddl-tpcds/
│ ├── bin_partitioned/
│ │ ├── add_constraints.sql
│ │ ├── analyze.sql
│ │ ├── call_center.sql
│ │ ├── catalog_page.sql
│ │ ├── catalog_returns.sql
│ │ ├── catalog_sales.sql
│ │ ├── customer.sql
│ │ ├── customer_address.sql
│ │ ├── customer_demographics.sql
│ │ ├── date_dim.sql
│ │ ├── household_demographics.sql
│ │ ├── income_band.sql
│ │ ├── inventory.sql
│ │ ├── item.sql
│ │ ├── promotion.sql
│ │ ├── reason.sql
│ │ ├── ship_mode.sql
│ │ ├── store.sql
│ │ ├── store_returns.sql
│ │ ├── store_sales.sql
│ │ ├── time_dim.sql
│ │ ├── warehouse.sql
│ │ ├── web_page.sql
│ │ ├── web_returns.sql
│ │ ├── web_sales.sql
│ │ └── web_site.sql
│ └── text/
│ ├── alltables.sql
│ └── analyze_everything.sql
├── ddl-tpch/
│ ├── bin_flat/
│ │ ├── alltables.sql
│ │ ├── analyze.sql
│ │ ├── customer.sql
│ │ ├── lineitem.sql
│ │ ├── nation.sql
│ │ ├── orders.sql
│ │ ├── part.sql
│ │ ├── partsupp.sql
│ │ ├── region.sql
│ │ └── supplier.sql
│ └── bin_partitioned/
│ ├── analyze.sql
│ ├── customer.sql
│ ├── lineitem.sql
│ ├── nation.sql
│ ├── orders.sql
│ ├── part.sql
│ ├── partsupp.sql
│ ├── region.sql
│ └── supplier.sql
├── runSuite.pl
├── sample-queries-tpcds/
│ ├── README.md
│ ├── query1.sql
│ ├── query10.sql
│ ├── query11.sql
│ ├── query12.sql
│ ├── query13.sql
│ ├── query14.sql
│ ├── query15.sql
│ ├── query16.sql
│ ├── query17.sql
│ ├── query18.sql
│ ├── query19.sql
│ ├── query2.sql
│ ├── query20.sql
│ ├── query21.sql
│ ├── query22.sql
│ ├── query23.sql
│ ├── query24.sql
│ ├── query25.sql
│ ├── query26.sql
│ ├── query27.sql
│ ├── query28.sql
│ ├── query29.sql
│ ├── query3.sql
│ ├── query30.sql
│ ├── query31.sql
│ ├── query32.sql
│ ├── query33.sql
│ ├── query34.sql
│ ├── query35.sql
│ ├── query36.sql
│ ├── query37.sql
│ ├── query38.sql
│ ├── query39.sql
│ ├── query4.sql
│ ├── query40.sql
│ ├── query41.sql
│ ├── query42.sql
│ ├── query43.sql
│ ├── query44.sql
│ ├── query45.sql
│ ├── query46.sql
│ ├── query47.sql
│ ├── query48.sql
│ ├── query49.sql
│ ├── query5.sql
│ ├── query50.sql
│ ├── query51.sql
│ ├── query52.sql
│ ├── query53.sql
│ ├── query54.sql
│ ├── query55.sql
│ ├── query56.sql
│ ├── query57.sql
│ ├── query58.sql
│ ├── query59.sql
│ ├── query6.sql
│ ├── query60.sql
│ ├── query61.sql
│ ├── query62.sql
│ ├── query63.sql
│ ├── query64.sql
│ ├── query65.sql
│ ├── query66.sql
│ ├── query67.sql
│ ├── query68.sql
│ ├── query69.sql
│ ├── query7.sql
│ ├── query70.sql
│ ├── query71.sql
│ ├── query72.sql
│ ├── query73.sql
│ ├── query74.sql
│ ├── query75.sql
│ ├── query76.sql
│ ├── query77.sql
│ ├── query78.sql
│ ├── query79.sql
│ ├── query8.sql
│ ├── query80.sql
│ ├── query81.sql
│ ├── query82.sql
│ ├── query83.sql
│ ├── query84.sql
│ ├── query85.sql
│ ├── query86.sql
│ ├── query87.sql
│ ├── query88.sql
│ ├── query89.sql
│ ├── query9.sql
│ ├── query90.sql
│ ├── query91.sql
│ ├── query92.sql
│ ├── query93.sql
│ ├── query94.sql
│ ├── query95.sql
│ ├── query96.sql
│ ├── query97.sql
│ ├── query98.sql
│ └── query99.sql
├── sample-queries-tpch/
│ ├── README.md
│ ├── testbench-withATS.settings
│ ├── testbench.settings
│ ├── tpch_query1.sql
│ ├── tpch_query10.sql
│ ├── tpch_query11.sql
│ ├── tpch_query12.sql
│ ├── tpch_query13.sql
│ ├── tpch_query14.sql
│ ├── tpch_query15.sql
│ ├── tpch_query16.sql
│ ├── tpch_query17.sql
│ ├── tpch_query18.sql
│ ├── tpch_query19.sql
│ ├── tpch_query2.sql
│ ├── tpch_query20.sql
│ ├── tpch_query21.sql
│ ├── tpch_query22.sql
│ ├── tpch_query3.sql
│ ├── tpch_query4.sql
│ ├── tpch_query5.sql
│ ├── tpch_query6.sql
│ ├── tpch_query7.sql
│ ├── tpch_query8.sql
│ └── tpch_query9.sql
├── settings/
│ ├── init.sql
│ ├── load-flat.sql
│ └── load-partitioned.sql
├── spark-queries-tpcds/
│ ├── LICENSE
│ ├── README.md
│ ├── q1.sql
│ ├── q10.sql
│ ├── q11.sql
│ ├── q12.sql
│ ├── q13.sql
│ ├── q14a.sql
│ ├── q14b.sql
│ ├── q15.sql
│ ├── q16.sql
│ ├── q17.sql
│ ├── q18.sql
│ ├── q19.sql
│ ├── q2.sql
│ ├── q20.sql
│ ├── q21.sql
│ ├── q22.sql
│ ├── q23a.sql
│ ├── q23b.sql
│ ├── q24a.sql
│ ├── q24b.sql
│ ├── q25.sql
│ ├── q26.sql
│ ├── q27.sql
│ ├── q28.sql
│ ├── q29.sql
│ ├── q3.sql
│ ├── q30.sql
│ ├── q31.sql
│ ├── q32.sql
│ ├── q33.sql
│ ├── q34.sql
│ ├── q35.sql
│ ├── q36.sql
│ ├── q37.sql
│ ├── q38.sql
│ ├── q39a.sql
│ ├── q39b.sql
│ ├── q4.sql
│ ├── q40.sql
│ ├── q41.sql
│ ├── q42.sql
│ ├── q43.sql
│ ├── q44.sql
│ ├── q45.sql
│ ├── q46.sql
│ ├── q47.sql
│ ├── q48.sql
│ ├── q49.sql
│ ├── q5.sql
│ ├── q50.sql
│ ├── q51.sql
│ ├── q52.sql
│ ├── q53.sql
│ ├── q54.sql
│ ├── q55.sql
│ ├── q56.sql
│ ├── q57.sql
│ ├── q58.sql
│ ├── q59.sql
│ ├── q6.sql
│ ├── q60.sql
│ ├── q61.sql
│ ├── q62.sql
│ ├── q63.sql
│ ├── q64.sql
│ ├── q65.sql
│ ├── q66.sql
│ ├── q67.sql
│ ├── q68.sql
│ ├── q69.sql
│ ├── q7.sql
│ ├── q70.sql
│ ├── q71.sql
│ ├── q72.sql
│ ├── q73.sql
│ ├── q74.sql
│ ├── q75.sql
│ ├── q76.sql
│ ├── q77.sql
│ ├── q78.sql
│ ├── q79.sql
│ ├── q8.sql
│ ├── q80.sql
│ ├── q81.sql
│ ├── q82.sql
│ ├── q83.sql
│ ├── q84.sql
│ ├── q85.sql
│ ├── q86.sql
│ ├── q87.sql
│ ├── q88.sql
│ ├── q89.sql
│ ├── q9.sql
│ ├── q90.sql
│ ├── q91.sql
│ ├── q92.sql
│ ├── q93.sql
│ ├── q94.sql
│ ├── q95.sql
│ ├── q96.sql
│ ├── q97.sql
│ ├── q98.sql
│ └── q99.sql
├── tpcds-build.sh
├── tpcds-gen/
│ ├── Makefile
│ ├── README.md
│ ├── patches/
│ │ ├── Darwin/
│ │ │ └── macosx.patch
│ │ └── all/
│ │ ├── tpcds-buffered.patch
│ │ ├── tpcds-strcpy.patch
│ │ └── tpcds_misspelled_header_guard.patch
│ ├── pom.xml
│ └── src/
│ └── main/
│ └── java/
│ └── org/
│ └── notmysock/
│ └── tpcds/
│ └── GenTable.java
├── tpcds-setup.sh
├── tpch-build.sh
├── tpch-gen/
│ ├── Makefile
│ ├── README.md
│ ├── ddl/
│ │ ├── orc.sql
│ │ └── text.sql
│ ├── patches/
│ │ └── Darwin/
│ │ └── macosx.patch
│ ├── pom.xml
│ └── src/
│ └── main/
│ └── java/
│ └── org/
│ └── notmysock/
│ └── tpch/
│ └── GenTable.java
└── tpch-setup.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
target/
tpcds_kit.zip
tpch_kit.zip
*.sql.log
derby.log
================================================
FILE: README.md
================================================
hive-testbench
==============
A testbench for experimenting with Apache Hive at any data scale.
Overview
========
The hive-testbench is a data generator and set of queries that lets you experiment with Apache Hive at scale. The testbench allows you to experience base Hive performance on large datasets, and gives an easy way to see the impact of Hive tuning parameters and advanced settings.
Prerequisites
=============
You will need:
* Hadoop 2.2 or later cluster or Sandbox.
* Apache Hive.
* Between 15 minutes and 2 days to generate data (depending on the Scale Factor you choose and available hardware).
* If you plan to generate 1TB or more of data, using Apache Hive 13+ to generate the data is STRONGLY suggested.
Install and Setup
=================
All of these steps should be carried out on your Hadoop cluster.
- Step 1: Prepare your environment.
In addition to Hadoop and Hive, before you begin ensure ```gcc``` is installed and available on your system path. If you system does not have it, install it using yum or apt-get.
- Step 2: Decide which test suite(s) you want to use.
hive-testbench comes with data generators and sample queries based on both the TPC-DS and TPC-H benchmarks. You can choose to use either or both of these benchmarks for experiementation. More information about these benchmarks can be found at the Transaction Processing Council homepage.
- Step 3: Compile and package the appropriate data generator.
For TPC-DS, ```./tpcds-build.sh``` downloads, compiles and packages the TPC-DS data generator.
For TPC-H, ```./tpch-build.sh``` downloads, compiles and packages the TPC-H data generator.
- Step 4: Decide how much data you want to generate.
You need to decide on a "Scale Factor" which represents how much data you will generate. Scale Factor roughly translates to gigabytes, so a Scale Factor of 100 is about 100 gigabytes and one terabyte is Scale Factor 1000. Decide how much data you want and keep it in mind for the next step. If you have a cluster of 4-10 nodes or just want to experiment at a smaller scale, scale 1000 (1 TB) of data is a good starting point. If you have a large cluster, you may want to choose Scale 10000 (10 TB) or more. The notion of scale factor is similar between TPC-DS and TPC-H.
If you want to generate a large amount of data, you should use Hive 13 or later. Hive 13 introduced an optimization that allows far more scalable data partitioning. Hive 12 and lower will likely crash if you generate more than a few hundred GB of data and tuning around the problem is difficult. You can generate text or RCFile data in Hive 13 and use it in multiple versions of Hive.
- Step 5: Generate and load the data.
The scripts ```tpcds-setup.sh``` and ```tpch-setup.sh``` generate and load data for TPC-DS and TPC-H, respectively. General usage is ```tpcds-setup.sh scale_factor [directory]``` or ```tpch-setup.sh scale_factor [directory]```
Some examples:
Build 1 TB of TPC-DS data: ```./tpcds-setup.sh 1000```
Build 1 TB of TPC-H data: ```./tpch-setup.sh 1000```
Build 100 TB of TPC-DS data: ```./tpcds-setup.sh 100000```
Build 30 TB of text formatted TPC-DS data: ```FORMAT=textfile ./tpcds-setup 30000```
Build 30 TB of RCFile formatted TPC-DS data: ```FORMAT=rcfile ./tpcds-setup 30000```
Also check other parameters in setup scripts important one is BUCKET_DATA.
- Step 6: Run queries.
More than 50 sample TPC-DS queries and all TPC-H queries are included for you to try. You can use ```hive```, ```beeline``` or the SQL tool of your choice. The testbench also includes a set of suggested settings.
This example assumes you have generated 1 TB of TPC-DS data during Step 5:
```
cd sample-queries-tpcds
hive -i testbench.settings
hive> use tpcds_bin_partitioned_orc_1000;
hive> source query55.sql;
```
Note that the database is named based on the Data Scale chosen in step 3. At Data Scale 10000, your database will be named tpcds_bin_partitioned_orc_10000. At Data Scale 1000 it would be named tpch_flat_orc_1000. You can always ```show databases``` to get a list of available databases.
Similarly, if you generated 1 TB of TPC-H data during Step 5:
```
cd sample-queries-tpch
hive -i testbench.settings
hive> use tpch_flat_orc_1000;
hive> source tpch_query1.sql;
```
Feedback
========
If you have questions, comments or problems, visit the [Hortonworks Hive forum](http://hortonworks.com/community/forums/forum/hive/).
If you have improvements, pull requests are accepted.
================================================
FILE: ddl-tpcds/bin_partitioned/add_constraints.sql
================================================
-- set hivevar:DB=tpcds_bin_partitioned_orc_10000
alter table customer_address add constraint ${DB}_pk_ca primary key (ca_address_sk) disable novalidate rely;
alter table customer_demographics add constraint ${DB}_pk_cd primary key (cd_demo_sk) disable novalidate rely;
alter table date_dim add constraint ${DB}_pk_dd primary key (d_date_sk) disable novalidate rely;
alter table warehouse add constraint ${DB}_pk_w primary key (w_warehouse_sk) disable novalidate rely;
alter table ship_mode add constraint ${DB}_pk_sm primary key (sm_ship_mode_sk) disable novalidate rely;
alter table time_dim add constraint ${DB}_pk_td primary key (t_time_sk) disable novalidate rely;
alter table reason add constraint ${DB}_pk_r primary key (r_reason_sk) disable novalidate rely;
alter table income_band add constraint ${DB}_pk_ib primary key (ib_income_band_sk) disable novalidate rely;
alter table item add constraint ${DB}_pk_i primary key (i_item_sk) disable novalidate rely;
alter table store add constraint ${DB}_pk_s primary key (s_store_sk) disable novalidate rely;
alter table call_center add constraint ${DB}_pk_cc primary key (cc_call_center_sk) disable novalidate rely;
alter table customer add constraint ${DB}_pk_c primary key (c_customer_sk) disable novalidate rely;
alter table web_site add constraint ${DB}_pk_ws primary key (web_site_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_pk_sr primary key (sr_item_sk, sr_ticket_number) disable novalidate rely;
alter table household_demographics add constraint ${DB}_pk_hd primary key (hd_demo_sk) disable novalidate rely;
alter table web_page add constraint ${DB}_pk_wp primary key (wp_web_page_sk) disable novalidate rely;
alter table promotion add constraint ${DB}_pk_p primary key (p_promo_sk) disable novalidate rely;
alter table catalog_page add constraint ${DB}_pk_cp primary key (cp_catalog_page_sk) disable novalidate rely;
-- partition_col case
alter table inventory add constraint ${DB}_pk_in primary key (inv_date_sk, inv_item_sk, inv_warehouse_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_pk_cr primary key (cr_item_sk, cr_order_number) disable novalidate rely;
alter table web_returns add constraint ${DB}_pk_wr primary key (wr_item_sk, wr_order_number) disable novalidate rely;
alter table web_sales add constraint ${DB}_pk_ws2 primary key (ws_item_sk, ws_order_number) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_pk_cs primary key (cs_item_sk, cs_order_number) disable novalidate rely;
alter table store_sales add constraint ${DB}_pk_ss primary key (ss_item_sk, ss_ticket_number) disable novalidate rely;
alter table call_center add constraint ${DB}_cc_d1 foreign key (cc_closed_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table call_center add constraint ${DB}_cc_d2 foreign key (cc_open_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table catalog_page add constraint ${DB}_cp_d1 foreign key (cp_end_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table catalog_page add constraint ${DB}_cp_d2 foreign key (cp_start_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_cc foreign key (cr_call_center_sk) references call_center (cc_call_center_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_cp foreign key (cr_catalog_page_sk) references catalog_page (cp_catalog_page_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_cs foreign key (cr_item_sk, cr_order_number) references catalog_sales (cs_item_sk, cs_order_number) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_i foreign key (cr_item_sk) references item (i_item_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_r foreign key (cr_reason_sk) references reason (r_reason_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_a1 foreign key (cr_refunded_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_cd1 foreign key (cr_refunded_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_c1 foreign key (cr_refunded_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_hd1 foreign key (cr_refunded_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
-- partition_col case
alter table catalog_returns add constraint ${DB}_cr_d1 foreign key (cr_returned_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_t foreign key (cr_returned_time_sk) references time_dim (t_time_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_a2 foreign key (cr_returning_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_cd2 foreign key (cr_returning_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_c2 foreign key (cr_returning_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_hd2 foreign key (cr_returning_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
-- alter table catalog_returns add constraint ${DB}_cr_d2 foreign key (cr_ship_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_sm foreign key (cr_ship_mode_sk) references ship_mode (sm_ship_mode_sk) disable novalidate rely;
alter table catalog_returns add constraint ${DB}_cr_w2 foreign key (cr_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_b_a foreign key (cs_bill_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_b_cd foreign key (cs_bill_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_b_c foreign key (cs_bill_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_b_hd foreign key (cs_bill_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_cc foreign key (cs_call_center_sk) references call_center (cc_call_center_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_cp foreign key (cs_catalog_page_sk) references catalog_page (cp_catalog_page_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_i foreign key (cs_item_sk) references item (i_item_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_p foreign key (cs_promo_sk) references promotion (p_promo_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_s_a foreign key (cs_ship_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_s_cd foreign key (cs_ship_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_s_c foreign key (cs_ship_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_d1 foreign key (cs_ship_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_s_hd foreign key (cs_ship_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_sm foreign key (cs_ship_mode_sk) references ship_mode (sm_ship_mode_sk) disable novalidate rely;
-- partition_col case
alter table catalog_sales add constraint ${DB}_cs_d2 foreign key (cs_sold_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_t foreign key (cs_sold_time_sk) references time_dim (t_time_sk) disable novalidate rely;
alter table catalog_sales add constraint ${DB}_cs_w foreign key (cs_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
alter table customer add constraint ${DB}_c_a foreign key (c_current_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table customer add constraint ${DB}_c_cd foreign key (c_current_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table customer add constraint ${DB}_c_hd foreign key (c_current_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table customer add constraint ${DB}_c_fsd foreign key (c_first_sales_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table customer add constraint ${DB}_c_fsd2 foreign key (c_first_shipto_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table household_demographics add constraint ${DB}_hd_ib foreign key (hd_income_band_sk) references income_band (ib_income_band_sk) disable novalidate rely;
-- partition_col case
alter table inventory add constraint ${DB}_inv_d foreign key (inv_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table inventory add constraint ${DB}_inv_i foreign key (inv_item_sk) references item (i_item_sk) disable novalidate rely;
alter table inventory add constraint ${DB}_inv_w foreign key (inv_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
alter table promotion add constraint ${DB}_p_end_date foreign key (p_end_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table promotion add constraint ${DB}_p_i foreign key (p_item_sk) references item (i_item_sk) disable novalidate rely;
alter table promotion add constraint ${DB}_p_start_date foreign key (p_start_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table store add constraint ${DB}_s_close_date foreign key (s_closed_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_a foreign key (sr_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_cd foreign key (sr_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_c foreign key (sr_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_hd foreign key (sr_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_i foreign key (sr_item_sk) references item (i_item_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_r foreign key (sr_reason_sk) references reason (r_reason_sk) disable novalidate rely;
-- partition_col case
alter table store_returns add constraint ${DB}_sr_ret_d foreign key (sr_returned_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_t foreign key (sr_return_time_sk) references time_dim (t_time_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_s foreign key (sr_store_sk) references store (s_store_sk) disable novalidate rely;
alter table store_returns add constraint ${DB}_sr_ss foreign key (sr_item_sk, sr_ticket_number) references store_sales (ss_item_sk, ss_ticket_number) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_a foreign key (ss_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_cd foreign key (ss_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_c foreign key (ss_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_hd foreign key (ss_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_i foreign key (ss_item_sk) references item (i_item_sk) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_p foreign key (ss_promo_sk) references promotion (p_promo_sk) disable novalidate rely;
-- partition_col case
alter table store_sales add constraint ${DB}_ss_d foreign key (ss_sold_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_t foreign key (ss_sold_time_sk) references time_dim (t_time_sk) disable novalidate rely;
alter table store_sales add constraint ${DB}_ss_s foreign key (ss_store_sk) references store (s_store_sk) disable novalidate rely;
alter table web_page add constraint ${DB}_wp_ad foreign key (wp_access_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table web_page add constraint ${DB}_wp_cd foreign key (wp_creation_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_i foreign key (wr_item_sk) references item (i_item_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_r foreign key (wr_reason_sk) references reason (r_reason_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ref_a foreign key (wr_refunded_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ref_cd foreign key (wr_refunded_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ref_c foreign key (wr_refunded_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ref_hd foreign key (wr_refunded_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
-- partition_col case
alter table web_returns add constraint ${DB}_wr_ret_d foreign key (wr_returned_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ret_t foreign key (wr_returned_time_sk) references time_dim (t_time_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ret_a foreign key (wr_returning_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ret_cd foreign key (wr_returning_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ret_c foreign key (wr_returning_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ret_hd foreign key (wr_returning_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_ws foreign key (wr_item_sk, wr_order_number) references web_sales (ws_item_sk, ws_order_number) disable novalidate rely;
alter table web_returns add constraint ${DB}_wr_wp foreign key (wr_web_page_sk) references web_page (wp_web_page_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_b_a foreign key (ws_bill_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_b_cd foreign key (ws_bill_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_b_c foreign key (ws_bill_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_b_hd foreign key (ws_bill_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_i foreign key (ws_item_sk) references item (i_item_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_p foreign key (ws_promo_sk) references promotion (p_promo_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_s_a foreign key (ws_ship_addr_sk) references customer_address (ca_address_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_s_cd foreign key (ws_ship_cdemo_sk) references customer_demographics (cd_demo_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_s_c foreign key (ws_ship_customer_sk) references customer (c_customer_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_s_d foreign key (ws_ship_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_s_hd foreign key (ws_ship_hdemo_sk) references household_demographics (hd_demo_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_sm foreign key (ws_ship_mode_sk) references ship_mode (sm_ship_mode_sk) disable novalidate rely;
-- partition_col case
alter table web_sales add constraint ${DB}_ws_d2 foreign key (ws_sold_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_t foreign key (ws_sold_time_sk) references time_dim (t_time_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_w2 foreign key (ws_warehouse_sk) references warehouse (w_warehouse_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_wp foreign key (ws_web_page_sk) references web_page (wp_web_page_sk) disable novalidate rely;
alter table web_sales add constraint ${DB}_ws_ws foreign key (ws_web_site_sk) references web_site (web_site_sk) disable novalidate rely;
alter table web_site add constraint ${DB}_web_d1 foreign key (web_close_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table web_site add constraint ${DB}_web_d2 foreign key (web_open_date_sk) references date_dim (d_date_sk) disable novalidate rely;
alter table store change column s_store_id s_store_id string constraint ${DB}_strid_nn not null disable novalidate rely;
alter table call_center change column cc_call_center_id cc_call_center_id string constraint ${DB}_ccid_nn not null disable novalidate rely;
alter table catalog_page change column cp_catalog_page_id cp_catalog_page_id string constraint ${DB}_cpid_nn not null disable novalidate rely;
alter table web_site change column web_site_id web_site_id string constraint ${DB}_wsid_nn not null disable novalidate rely;
alter table web_page change column wp_web_page_id wp_web_page_id string constraint ${DB}_wpid_nn not null disable novalidate rely;
alter table warehouse change column w_warehouse_id w_warehouse_id string constraint ${DB}_wid_nn not null disable novalidate rely;
alter table customer change column c_customer_id c_customer_id string constraint ${DB}_cid_nn not null disable novalidate rely;
alter table customer_address change column ca_address_id ca_address_id string constraint ${DB}_caid_nn not null disable novalidate rely;
alter table date_dim change column d_date_id d_date_id string constraint ${DB}_did_nn not null disable novalidate rely;
alter table item change column i_item_id i_item_id string constraint ${DB}_itid_nn not null disable novalidate rely;
alter table promotion change column p_promo_id p_promo_id string constraint ${DB}_pid_nn not null disable novalidate rely;
alter table reason change column r_reason_id r_reason_id string constraint ${DB}_rid_nn not null disable novalidate rely;
alter table ship_mode change column sm_ship_mode_id sm_ship_mode_id string constraint ${DB}_smid_nn not null disable novalidate rely;
alter table time_dim change column t_time_id t_time_id string constraint ${DB}_tid_nn not null disable novalidate rely;
alter table customer change column c_customer_id c_customer_id string constraint ${DB}_cid_uq unique disable novalidate rely;
================================================
FILE: ddl-tpcds/bin_partitioned/analyze.sql
================================================
analyze table call_center compute statistics for columns;
analyze table catalog_page compute statistics for columns;
analyze table catalog_returns compute statistics for columns;
analyze table catalog_sales compute statistics for columns;
analyze table customer compute statistics for columns;
analyze table customer_address compute statistics for columns;
analyze table customer_demographics compute statistics for columns;
analyze table date_dim compute statistics for columns;
analyze table household_demographics compute statistics for columns;
analyze table income_band compute statistics for columns;
analyze table inventory compute statistics for columns;
analyze table item compute statistics for columns;
analyze table promotion compute statistics for columns;
analyze table reason compute statistics for columns;
analyze table ship_mode compute statistics for columns;
analyze table store compute statistics for columns;
analyze table store_returns compute statistics for columns;
analyze table store_sales compute statistics for columns;
analyze table time_dim compute statistics for columns;
analyze table warehouse compute statistics for columns;
analyze table web_page compute statistics for columns;
analyze table web_returns compute statistics for columns;
analyze table web_sales compute statistics for columns;
analyze table web_site compute statistics for columns;
================================================
FILE: ddl-tpcds/bin_partitioned/call_center.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists call_center;
create table call_center
stored as ${FILE}
as select * from ${SOURCE}.call_center;
================================================
FILE: ddl-tpcds/bin_partitioned/catalog_page.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists catalog_page;
create table catalog_page
stored as ${FILE}
as select * from ${SOURCE}.catalog_page;
================================================
FILE: ddl-tpcds/bin_partitioned/catalog_returns.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists catalog_returns;
create table catalog_returns
(
cr_returned_time_sk bigint
, cr_item_sk bigint
, cr_refunded_customer_sk bigint
, cr_refunded_cdemo_sk bigint
, cr_refunded_hdemo_sk bigint
, cr_refunded_addr_sk bigint
, cr_returning_customer_sk bigint
, cr_returning_cdemo_sk bigint
, cr_returning_hdemo_sk bigint
, cr_returning_addr_sk bigint
, cr_call_center_sk bigint
, cr_catalog_page_sk bigint
, cr_ship_mode_sk bigint
, cr_warehouse_sk bigint
, cr_reason_sk bigint
, cr_order_number bigint
, cr_return_quantity int
, cr_return_amount decimal(7,2)
, cr_return_tax decimal(7,2)
, cr_return_amt_inc_tax decimal(7,2)
, cr_fee decimal(7,2)
, cr_return_ship_cost decimal(7,2)
, cr_refunded_cash decimal(7,2)
, cr_reversed_charge decimal(7,2)
, cr_store_credit decimal(7,2)
, cr_net_loss decimal(7,2)
)
partitioned by (cr_returned_date_sk bigint)
stored as ${FILE};
from ${SOURCE}.catalog_returns cr
insert overwrite table catalog_returns partition(cr_returned_date_sk)
select
cr.cr_returned_time_sk,
cr.cr_item_sk,
cr.cr_refunded_customer_sk,
cr.cr_refunded_cdemo_sk,
cr.cr_refunded_hdemo_sk,
cr.cr_refunded_addr_sk,
cr.cr_returning_customer_sk,
cr.cr_returning_cdemo_sk,
cr.cr_returning_hdemo_sk,
cr.cr_returning_addr_sk,
cr.cr_call_center_sk,
cr.cr_catalog_page_sk,
cr.cr_ship_mode_sk,
cr.cr_warehouse_sk,
cr.cr_reason_sk,
cr.cr_order_number,
cr.cr_return_quantity,
cr.cr_return_amount,
cr.cr_return_tax,
cr.cr_return_amt_inc_tax,
cr.cr_fee,
cr.cr_return_ship_cost,
cr.cr_refunded_cash,
cr.cr_reversed_charge,
cr.cr_store_credit,
cr.cr_net_loss,
cr.cr_returned_date_sk
where cr.cr_returned_date_sk is not null
insert overwrite table catalog_returns partition (cr_returned_date_sk)
select
cr.cr_returned_time_sk,
cr.cr_item_sk,
cr.cr_refunded_customer_sk,
cr.cr_refunded_cdemo_sk,
cr.cr_refunded_hdemo_sk,
cr.cr_refunded_addr_sk,
cr.cr_returning_customer_sk,
cr.cr_returning_cdemo_sk,
cr.cr_returning_hdemo_sk,
cr.cr_returning_addr_sk,
cr.cr_call_center_sk,
cr.cr_catalog_page_sk,
cr.cr_ship_mode_sk,
cr.cr_warehouse_sk,
cr.cr_reason_sk,
cr.cr_order_number,
cr.cr_return_quantity,
cr.cr_return_amount,
cr.cr_return_tax,
cr.cr_return_amt_inc_tax,
cr.cr_fee,
cr.cr_return_ship_cost,
cr.cr_refunded_cash,
cr.cr_reversed_charge,
cr.cr_store_credit,
cr.cr_net_loss,
cr.cr_returned_date_sk
where cr.cr_returned_date_sk is null
sort by cr_returned_date_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/catalog_sales.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists catalog_sales;
create table catalog_sales
(
cs_sold_time_sk bigint
, cs_ship_date_sk bigint
, cs_bill_customer_sk bigint
, cs_bill_cdemo_sk bigint
, cs_bill_hdemo_sk bigint
, cs_bill_addr_sk bigint
, cs_ship_customer_sk bigint
, cs_ship_cdemo_sk bigint
, cs_ship_hdemo_sk bigint
, cs_ship_addr_sk bigint
, cs_call_center_sk bigint
, cs_catalog_page_sk bigint
, cs_ship_mode_sk bigint
, cs_warehouse_sk bigint
, cs_item_sk bigint
, cs_promo_sk bigint
, cs_order_number bigint
, cs_quantity int
, cs_wholesale_cost decimal(7,2)
, cs_list_price decimal(7,2)
, cs_sales_price decimal(7,2)
, cs_ext_discount_amt decimal(7,2)
, cs_ext_sales_price decimal(7,2)
, cs_ext_wholesale_cost decimal(7,2)
, cs_ext_list_price decimal(7,2)
, cs_ext_tax decimal(7,2)
, cs_coupon_amt decimal(7,2)
, cs_ext_ship_cost decimal(7,2)
, cs_net_paid decimal(7,2)
, cs_net_paid_inc_tax decimal(7,2)
, cs_net_paid_inc_ship decimal(7,2)
, cs_net_paid_inc_ship_tax decimal(7,2)
, cs_net_profit decimal(7,2)
)
partitioned by (cs_sold_date_sk bigint)
stored as ${FILE};
from ${SOURCE}.catalog_sales cs
insert overwrite table catalog_sales partition (cs_sold_date_sk)
select
cs.cs_sold_time_sk,
cs.cs_ship_date_sk,
cs.cs_bill_customer_sk,
cs.cs_bill_cdemo_sk,
cs.cs_bill_hdemo_sk,
cs.cs_bill_addr_sk,
cs.cs_ship_customer_sk,
cs.cs_ship_cdemo_sk,
cs.cs_ship_hdemo_sk,
cs.cs_ship_addr_sk,
cs.cs_call_center_sk,
cs.cs_catalog_page_sk,
cs.cs_ship_mode_sk,
cs.cs_warehouse_sk,
cs.cs_item_sk,
cs.cs_promo_sk,
cs.cs_order_number,
cs.cs_quantity,
cs.cs_wholesale_cost,
cs.cs_list_price,
cs.cs_sales_price,
cs.cs_ext_discount_amt,
cs.cs_ext_sales_price,
cs.cs_ext_wholesale_cost,
cs.cs_ext_list_price,
cs.cs_ext_tax,
cs.cs_coupon_amt,
cs.cs_ext_ship_cost,
cs.cs_net_paid,
cs.cs_net_paid_inc_tax,
cs.cs_net_paid_inc_ship,
cs.cs_net_paid_inc_ship_tax,
cs.cs_net_profit,
cs.cs_sold_date_sk
where cs.cs_sold_date_sk is not null
insert overwrite table catalog_sales partition (cs_sold_date_sk)
select
cs.cs_sold_time_sk,
cs.cs_ship_date_sk,
cs.cs_bill_customer_sk,
cs.cs_bill_cdemo_sk,
cs.cs_bill_hdemo_sk,
cs.cs_bill_addr_sk,
cs.cs_ship_customer_sk,
cs.cs_ship_cdemo_sk,
cs.cs_ship_hdemo_sk,
cs.cs_ship_addr_sk,
cs.cs_call_center_sk,
cs.cs_catalog_page_sk,
cs.cs_ship_mode_sk,
cs.cs_warehouse_sk,
cs.cs_item_sk,
cs.cs_promo_sk,
cs.cs_order_number,
cs.cs_quantity,
cs.cs_wholesale_cost,
cs.cs_list_price,
cs.cs_sales_price,
cs.cs_ext_discount_amt,
cs.cs_ext_sales_price,
cs.cs_ext_wholesale_cost,
cs.cs_ext_list_price,
cs.cs_ext_tax,
cs.cs_coupon_amt,
cs.cs_ext_ship_cost,
cs.cs_net_paid,
cs.cs_net_paid_inc_tax,
cs.cs_net_paid_inc_ship,
cs.cs_net_paid_inc_ship_tax,
cs.cs_net_profit,
cs.cs_sold_date_sk
where cs.cs_sold_date_sk is null
sort by cs.cs_sold_date_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/customer.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists customer;
create table customer
stored as ${FILE}
as select * from ${SOURCE}.customer
CLUSTER BY c_customer_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/customer_address.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists customer_address;
create table customer_address
stored as ${FILE}
as select * from ${SOURCE}.customer_address
CLUSTER BY ca_address_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/customer_demographics.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists customer_demographics;
create table customer_demographics
stored as ${FILE}
as select * from ${SOURCE}.customer_demographics;
================================================
FILE: ddl-tpcds/bin_partitioned/date_dim.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists date_dim;
create table date_dim
stored as ${FILE}
as select * from ${SOURCE}.date_dim;
================================================
FILE: ddl-tpcds/bin_partitioned/household_demographics.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists household_demographics;
create table household_demographics
stored as ${FILE}
as select * from ${SOURCE}.household_demographics;
================================================
FILE: ddl-tpcds/bin_partitioned/income_band.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists income_band;
create table income_band
stored as ${FILE}
as select * from ${SOURCE}.income_band;
================================================
FILE: ddl-tpcds/bin_partitioned/inventory.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists inventory;
create table inventory
stored as ${FILE}
as select * from ${SOURCE}.inventory
CLUSTER BY inv_date_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/item.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists item;
create table item
stored as ${FILE}
as select * from ${SOURCE}.item
CLUSTER BY i_item_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/promotion.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists promotion;
create table promotion
stored as ${FILE}
as select * from ${SOURCE}.promotion;
================================================
FILE: ddl-tpcds/bin_partitioned/reason.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists reason;
create table reason
stored as ${FILE}
as select * from ${SOURCE}.reason;
================================================
FILE: ddl-tpcds/bin_partitioned/ship_mode.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists ship_mode;
create table ship_mode
stored as ${FILE}
as select * from ${SOURCE}.ship_mode;
================================================
FILE: ddl-tpcds/bin_partitioned/store.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists store;
create table store
stored as ${FILE}
as select * from ${SOURCE}.store
CLUSTER BY s_store_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/store_returns.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists store_returns;
create table store_returns
(
sr_return_time_sk bigint
, sr_item_sk bigint
, sr_customer_sk bigint
, sr_cdemo_sk bigint
, sr_hdemo_sk bigint
, sr_addr_sk bigint
, sr_store_sk bigint
, sr_reason_sk bigint
, sr_ticket_number bigint
, sr_return_quantity int
, sr_return_amt decimal(7,2)
, sr_return_tax decimal(7,2)
, sr_return_amt_inc_tax decimal(7,2)
, sr_fee decimal(7,2)
, sr_return_ship_cost decimal(7,2)
, sr_refunded_cash decimal(7,2)
, sr_reversed_charge decimal(7,2)
, sr_store_credit decimal(7,2)
, sr_net_loss decimal(7,2)
)
partitioned by (sr_returned_date_sk bigint)
stored as ${FILE};
from ${SOURCE}.store_returns sr
insert overwrite table store_returns partition (sr_returned_date_sk)
select
sr.sr_return_time_sk,
sr.sr_item_sk,
sr.sr_customer_sk,
sr.sr_cdemo_sk,
sr.sr_hdemo_sk,
sr.sr_addr_sk,
sr.sr_store_sk,
sr.sr_reason_sk,
sr.sr_ticket_number,
sr.sr_return_quantity,
sr.sr_return_amt,
sr.sr_return_tax,
sr.sr_return_amt_inc_tax,
sr.sr_fee,
sr.sr_return_ship_cost,
sr.sr_refunded_cash,
sr.sr_reversed_charge,
sr.sr_store_credit,
sr.sr_net_loss,
sr.sr_returned_date_sk
where sr.sr_returned_date_sk is not null
insert overwrite table store_returns partition (sr_returned_date_sk)
select
sr.sr_return_time_sk,
sr.sr_item_sk,
sr.sr_customer_sk,
sr.sr_cdemo_sk,
sr.sr_hdemo_sk,
sr.sr_addr_sk,
sr.sr_store_sk,
sr.sr_reason_sk,
sr.sr_ticket_number,
sr.sr_return_quantity,
sr.sr_return_amt,
sr.sr_return_tax,
sr.sr_return_amt_inc_tax,
sr.sr_fee,
sr.sr_return_ship_cost,
sr.sr_refunded_cash,
sr.sr_reversed_charge,
sr.sr_store_credit,
sr.sr_net_loss,
sr.sr_returned_date_sk
where sr.sr_returned_date_sk is null
sort by sr.sr_returned_date_sk
================================================
FILE: ddl-tpcds/bin_partitioned/store_sales.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists store_sales;
create table store_sales
(
ss_sold_time_sk bigint
, ss_item_sk bigint
, ss_customer_sk bigint
, ss_cdemo_sk bigint
, ss_hdemo_sk bigint
, ss_addr_sk bigint
, ss_store_sk bigint
, ss_promo_sk bigint
, ss_ticket_number bigint
, ss_quantity int
, ss_wholesale_cost decimal(7,2)
, ss_list_price decimal(7,2)
, ss_sales_price decimal(7,2)
, ss_ext_discount_amt decimal(7,2)
, ss_ext_sales_price decimal(7,2)
, ss_ext_wholesale_cost decimal(7,2)
, ss_ext_list_price decimal(7,2)
, ss_ext_tax decimal(7,2)
, ss_coupon_amt decimal(7,2)
, ss_net_paid decimal(7,2)
, ss_net_paid_inc_tax decimal(7,2)
, ss_net_profit decimal(7,2)
)
partitioned by (ss_sold_date_sk bigint)
stored as ${FILE};
from ${SOURCE}.store_sales ss
insert overwrite table store_sales partition (ss_sold_date_sk)
select
ss.ss_sold_time_sk,
ss.ss_item_sk,
ss.ss_customer_sk,
ss.ss_cdemo_sk,
ss.ss_hdemo_sk,
ss.ss_addr_sk,
ss.ss_store_sk,
ss.ss_promo_sk,
ss.ss_ticket_number,
ss.ss_quantity,
ss.ss_wholesale_cost,
ss.ss_list_price,
ss.ss_sales_price,
ss.ss_ext_discount_amt,
ss.ss_ext_sales_price,
ss.ss_ext_wholesale_cost,
ss.ss_ext_list_price,
ss.ss_ext_tax,
ss.ss_coupon_amt,
ss.ss_net_paid,
ss.ss_net_paid_inc_tax,
ss.ss_net_profit,
ss.ss_sold_date_sk
where ss.ss_sold_date_sk is not null
insert overwrite table store_sales partition (ss_sold_date_sk)
select
ss.ss_sold_time_sk,
ss.ss_item_sk,
ss.ss_customer_sk,
ss.ss_cdemo_sk,
ss.ss_hdemo_sk,
ss.ss_addr_sk,
ss.ss_store_sk,
ss.ss_promo_sk,
ss.ss_ticket_number,
ss.ss_quantity,
ss.ss_wholesale_cost,
ss.ss_list_price,
ss.ss_sales_price,
ss.ss_ext_discount_amt,
ss.ss_ext_sales_price,
ss.ss_ext_wholesale_cost,
ss.ss_ext_list_price,
ss.ss_ext_tax,
ss.ss_coupon_amt,
ss.ss_net_paid,
ss.ss_net_paid_inc_tax,
ss.ss_net_profit,
ss.ss_sold_date_sk
where ss.ss_sold_date_sk is null
sort by ss.ss_sold_date_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/time_dim.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists time_dim;
create table time_dim
stored as ${FILE}
as select * from ${SOURCE}.time_dim;
================================================
FILE: ddl-tpcds/bin_partitioned/warehouse.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists warehouse;
create table warehouse
stored as ${FILE}
as select * from ${SOURCE}.warehouse;
================================================
FILE: ddl-tpcds/bin_partitioned/web_page.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists web_page;
create table web_page
stored as ${FILE}
as select * from ${SOURCE}.web_page;
================================================
FILE: ddl-tpcds/bin_partitioned/web_returns.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists web_returns;
create table web_returns
(
wr_returned_time_sk bigint
, wr_item_sk bigint
, wr_refunded_customer_sk bigint
, wr_refunded_cdemo_sk bigint
, wr_refunded_hdemo_sk bigint
, wr_refunded_addr_sk bigint
, wr_returning_customer_sk bigint
, wr_returning_cdemo_sk bigint
, wr_returning_hdemo_sk bigint
, wr_returning_addr_sk bigint
, wr_web_page_sk bigint
, wr_reason_sk bigint
, wr_order_number bigint
, wr_return_quantity int
, wr_return_amt decimal(7,2)
, wr_return_tax decimal(7,2)
, wr_return_amt_inc_tax decimal(7,2)
, wr_fee decimal(7,2)
, wr_return_ship_cost decimal(7,2)
, wr_refunded_cash decimal(7,2)
, wr_reversed_charge decimal(7,2)
, wr_account_credit decimal(7,2)
, wr_net_loss decimal(7,2)
)
partitioned by (wr_returned_date_sk bigint)
stored as ${FILE};
from ${SOURCE}.web_returns wr
insert overwrite table web_returns partition (wr_returned_date_sk)
select
wr.wr_returned_time_sk,
wr.wr_item_sk,
wr.wr_refunded_customer_sk,
wr.wr_refunded_cdemo_sk,
wr.wr_refunded_hdemo_sk,
wr.wr_refunded_addr_sk,
wr.wr_returning_customer_sk,
wr.wr_returning_cdemo_sk,
wr.wr_returning_hdemo_sk,
wr.wr_returning_addr_sk,
wr.wr_web_page_sk,
wr.wr_reason_sk,
wr.wr_order_number,
wr.wr_return_quantity,
wr.wr_return_amt,
wr.wr_return_tax,
wr.wr_return_amt_inc_tax,
wr.wr_fee,
wr.wr_return_ship_cost,
wr.wr_refunded_cash,
wr.wr_reversed_charge,
wr.wr_account_credit,
wr.wr_net_loss,
wr.wr_returned_date_sk
where wr.wr_returned_date_sk is not null
insert overwrite table web_returns partition (wr_returned_date_sk)
select
wr.wr_returned_time_sk,
wr.wr_item_sk,
wr.wr_refunded_customer_sk,
wr.wr_refunded_cdemo_sk,
wr.wr_refunded_hdemo_sk,
wr.wr_refunded_addr_sk,
wr.wr_returning_customer_sk,
wr.wr_returning_cdemo_sk,
wr.wr_returning_hdemo_sk,
wr.wr_returning_addr_sk,
wr.wr_web_page_sk,
wr.wr_reason_sk,
wr.wr_order_number,
wr.wr_return_quantity,
wr.wr_return_amt,
wr.wr_return_tax,
wr.wr_return_amt_inc_tax,
wr.wr_fee,
wr.wr_return_ship_cost,
wr.wr_refunded_cash,
wr.wr_reversed_charge,
wr.wr_account_credit,
wr.wr_net_loss,
wr.wr_returned_date_sk
where wr.wr_returned_date_sk is null
sort by wr.wr_returned_date_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/web_sales.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists web_sales;
create table web_sales
(
ws_sold_time_sk bigint,
ws_ship_date_sk bigint,
ws_item_sk bigint,
ws_bill_customer_sk bigint,
ws_bill_cdemo_sk bigint,
ws_bill_hdemo_sk bigint,
ws_bill_addr_sk bigint,
ws_ship_customer_sk bigint,
ws_ship_cdemo_sk bigint,
ws_ship_hdemo_sk bigint,
ws_ship_addr_sk bigint,
ws_web_page_sk bigint,
ws_web_site_sk bigint,
ws_ship_mode_sk bigint,
ws_warehouse_sk bigint,
ws_promo_sk bigint,
ws_order_number bigint,
ws_quantity int,
ws_wholesale_cost decimal(7,2),
ws_list_price decimal(7,2),
ws_sales_price decimal(7,2),
ws_ext_discount_amt decimal(7,2),
ws_ext_sales_price decimal(7,2),
ws_ext_wholesale_cost decimal(7,2),
ws_ext_list_price decimal(7,2),
ws_ext_tax decimal(7,2),
ws_coupon_amt decimal(7,2),
ws_ext_ship_cost decimal(7,2),
ws_net_paid decimal(7,2),
ws_net_paid_inc_tax decimal(7,2),
ws_net_paid_inc_ship decimal(7,2),
ws_net_paid_inc_ship_tax decimal(7,2),
ws_net_profit decimal(7,2)
)
partitioned by (ws_sold_date_sk bigint)
stored as ${FILE};
from ${SOURCE}.web_sales ws
insert overwrite table web_sales partition (ws_sold_date_sk)
select
ws.ws_sold_time_sk,
ws.ws_ship_date_sk,
ws.ws_item_sk,
ws.ws_bill_customer_sk,
ws.ws_bill_cdemo_sk,
ws.ws_bill_hdemo_sk,
ws.ws_bill_addr_sk,
ws.ws_ship_customer_sk,
ws.ws_ship_cdemo_sk,
ws.ws_ship_hdemo_sk,
ws.ws_ship_addr_sk,
ws.ws_web_page_sk,
ws.ws_web_site_sk,
ws.ws_ship_mode_sk,
ws.ws_warehouse_sk,
ws.ws_promo_sk,
ws.ws_order_number,
ws.ws_quantity,
ws.ws_wholesale_cost,
ws.ws_list_price,
ws.ws_sales_price,
ws.ws_ext_discount_amt,
ws.ws_ext_sales_price,
ws.ws_ext_wholesale_cost,
ws.ws_ext_list_price,
ws.ws_ext_tax,
ws.ws_coupon_amt,
ws.ws_ext_ship_cost,
ws.ws_net_paid,
ws.ws_net_paid_inc_tax,
ws.ws_net_paid_inc_ship,
ws.ws_net_paid_inc_ship_tax,
ws.ws_net_profit,
ws.ws_sold_date_sk
where ws.ws_sold_date_sk is not null
insert overwrite table web_sales partition (ws_sold_date_sk)
select
ws.ws_sold_time_sk,
ws.ws_ship_date_sk,
ws.ws_item_sk,
ws.ws_bill_customer_sk,
ws.ws_bill_cdemo_sk,
ws.ws_bill_hdemo_sk,
ws.ws_bill_addr_sk,
ws.ws_ship_customer_sk,
ws.ws_ship_cdemo_sk,
ws.ws_ship_hdemo_sk,
ws.ws_ship_addr_sk,
ws.ws_web_page_sk,
ws.ws_web_site_sk,
ws.ws_ship_mode_sk,
ws.ws_warehouse_sk,
ws.ws_promo_sk,
ws.ws_order_number,
ws.ws_quantity,
ws.ws_wholesale_cost,
ws.ws_list_price,
ws.ws_sales_price,
ws.ws_ext_discount_amt,
ws.ws_ext_sales_price,
ws.ws_ext_wholesale_cost,
ws.ws_ext_list_price,
ws.ws_ext_tax,
ws.ws_coupon_amt,
ws.ws_ext_ship_cost,
ws.ws_net_paid,
ws.ws_net_paid_inc_tax,
ws.ws_net_paid_inc_ship,
ws.ws_net_paid_inc_ship_tax,
ws.ws_net_profit,
ws.ws_sold_date_sk
where ws.ws_sold_date_sk is null
sort by ws.ws_sold_date_sk
;
================================================
FILE: ddl-tpcds/bin_partitioned/web_site.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists web_site;
create table web_site
stored as ${FILE}
as select * from ${SOURCE}.web_site;
================================================
FILE: ddl-tpcds/text/alltables.sql
================================================
create database if not exists ${DB};
use ${DB};
-- Table<store_sales (23 cols) partition=ss_sold_date_sk>
drop table if exists store_sales;
create external table if not exists store_sales(
ss_sold_date_sk bigint
, ss_sold_time_sk bigint
, ss_item_sk bigint
, ss_customer_sk bigint
, ss_cdemo_sk bigint
, ss_hdemo_sk bigint
, ss_addr_sk bigint
, ss_store_sk bigint
, ss_promo_sk bigint
, ss_ticket_number bigint
, ss_quantity int
, ss_wholesale_cost decimal(7,2)
, ss_list_price decimal(7,2)
, ss_sales_price decimal(7,2)
, ss_ext_discount_amt decimal(7,2)
, ss_ext_sales_price decimal(7,2)
, ss_ext_wholesale_cost decimal(7,2)
, ss_ext_list_price decimal(7,2)
, ss_ext_tax decimal(7,2)
, ss_coupon_amt decimal(7,2)
, ss_net_paid decimal(7,2)
, ss_net_paid_inc_tax decimal(7,2)
, ss_net_profit decimal(7,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/store_sales'
;
-- Table<store_returns (20 cols) partition=sr_returned_date_sk>
drop table if exists store_returns;
create external table if not exists store_returns(
sr_returned_date_sk bigint
, sr_return_time_sk bigint
, sr_item_sk bigint
, sr_customer_sk bigint
, sr_cdemo_sk bigint
, sr_hdemo_sk bigint
, sr_addr_sk bigint
, sr_store_sk bigint
, sr_reason_sk bigint
, sr_ticket_number bigint
, sr_return_quantity int
, sr_return_amt decimal(7,2)
, sr_return_tax decimal(7,2)
, sr_return_amt_inc_tax decimal(7,2)
, sr_fee decimal(7,2)
, sr_return_ship_cost decimal(7,2)
, sr_refunded_cash decimal(7,2)
, sr_reversed_charge decimal(7,2)
, sr_store_credit decimal(7,2)
, sr_net_loss decimal(7,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/store_returns'
;
-- Table<catalog_sales (34 cols) partition=cs_sold_date_sk>
drop table if exists catalog_sales;
create external table if not exists catalog_sales(
cs_sold_date_sk bigint
, cs_sold_time_sk bigint
, cs_ship_date_sk bigint
, cs_bill_customer_sk bigint
, cs_bill_cdemo_sk bigint
, cs_bill_hdemo_sk bigint
, cs_bill_addr_sk bigint
, cs_ship_customer_sk bigint
, cs_ship_cdemo_sk bigint
, cs_ship_hdemo_sk bigint
, cs_ship_addr_sk bigint
, cs_call_center_sk bigint
, cs_catalog_page_sk bigint
, cs_ship_mode_sk bigint
, cs_warehouse_sk bigint
, cs_item_sk bigint
, cs_promo_sk bigint
, cs_order_number bigint
, cs_quantity int
, cs_wholesale_cost decimal(7,2)
, cs_list_price decimal(7,2)
, cs_sales_price decimal(7,2)
, cs_ext_discount_amt decimal(7,2)
, cs_ext_sales_price decimal(7,2)
, cs_ext_wholesale_cost decimal(7,2)
, cs_ext_list_price decimal(7,2)
, cs_ext_tax decimal(7,2)
, cs_coupon_amt decimal(7,2)
, cs_ext_ship_cost decimal(7,2)
, cs_net_paid decimal(7,2)
, cs_net_paid_inc_tax decimal(7,2)
, cs_net_paid_inc_ship decimal(7,2)
, cs_net_paid_inc_ship_tax decimal(7,2)
, cs_net_profit decimal(7,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/catalog_sales'
;
-- Table<catalog_returns (27 cols) partition=cr_returned_date_sk>
drop table if exists catalog_returns;
create external table if not exists catalog_returns(
cr_returned_date_sk bigint
, cr_returned_time_sk bigint
, cr_item_sk bigint
, cr_refunded_customer_sk bigint
, cr_refunded_cdemo_sk bigint
, cr_refunded_hdemo_sk bigint
, cr_refunded_addr_sk bigint
, cr_returning_customer_sk bigint
, cr_returning_cdemo_sk bigint
, cr_returning_hdemo_sk bigint
, cr_returning_addr_sk bigint
, cr_call_center_sk bigint
, cr_catalog_page_sk bigint
, cr_ship_mode_sk bigint
, cr_warehouse_sk bigint
, cr_reason_sk bigint
, cr_order_number bigint
, cr_return_quantity int
, cr_return_amount decimal(7,2)
, cr_return_tax decimal(7,2)
, cr_return_amt_inc_tax decimal(7,2)
, cr_fee decimal(7,2)
, cr_return_ship_cost decimal(7,2)
, cr_refunded_cash decimal(7,2)
, cr_reversed_charge decimal(7,2)
, cr_store_credit decimal(7,2)
, cr_net_loss decimal(7,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/catalog_returns'
;
-- Table<web_sales (34 cols) partition=ws_sold_date_sk>
drop table if exists web_sales;
create external table if not exists web_sales(
ws_sold_date_sk bigint
, ws_sold_time_sk bigint
, ws_ship_date_sk bigint
, ws_item_sk bigint
, ws_bill_customer_sk bigint
, ws_bill_cdemo_sk bigint
, ws_bill_hdemo_sk bigint
, ws_bill_addr_sk bigint
, ws_ship_customer_sk bigint
, ws_ship_cdemo_sk bigint
, ws_ship_hdemo_sk bigint
, ws_ship_addr_sk bigint
, ws_web_page_sk bigint
, ws_web_site_sk bigint
, ws_ship_mode_sk bigint
, ws_warehouse_sk bigint
, ws_promo_sk bigint
, ws_order_number bigint
, ws_quantity int
, ws_wholesale_cost decimal(7,2)
, ws_list_price decimal(7,2)
, ws_sales_price decimal(7,2)
, ws_ext_discount_amt decimal(7,2)
, ws_ext_sales_price decimal(7,2)
, ws_ext_wholesale_cost decimal(7,2)
, ws_ext_list_price decimal(7,2)
, ws_ext_tax decimal(7,2)
, ws_coupon_amt decimal(7,2)
, ws_ext_ship_cost decimal(7,2)
, ws_net_paid decimal(7,2)
, ws_net_paid_inc_tax decimal(7,2)
, ws_net_paid_inc_ship decimal(7,2)
, ws_net_paid_inc_ship_tax decimal(7,2)
, ws_net_profit decimal(7,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/web_sales'
;
-- Table<web_returns (24 cols) partition=wr_returned_date_sk>
drop table if exists web_returns;
create external table if not exists web_returns(
wr_returned_date_sk bigint
, wr_returned_time_sk bigint
, wr_item_sk bigint
, wr_refunded_customer_sk bigint
, wr_refunded_cdemo_sk bigint
, wr_refunded_hdemo_sk bigint
, wr_refunded_addr_sk bigint
, wr_returning_customer_sk bigint
, wr_returning_cdemo_sk bigint
, wr_returning_hdemo_sk bigint
, wr_returning_addr_sk bigint
, wr_web_page_sk bigint
, wr_reason_sk bigint
, wr_order_number bigint
, wr_return_quantity int
, wr_return_amt decimal(7,2)
, wr_return_tax decimal(7,2)
, wr_return_amt_inc_tax decimal(7,2)
, wr_fee decimal(7,2)
, wr_return_ship_cost decimal(7,2)
, wr_refunded_cash decimal(7,2)
, wr_reversed_charge decimal(7,2)
, wr_account_credit decimal(7,2)
, wr_net_loss decimal(7,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/web_returns'
;
-- Table<inventory (4 cols)>
drop table if exists inventory;
create external table if not exists inventory(
inv_date_sk bigint
, inv_item_sk bigint
, inv_warehouse_sk bigint
, inv_quantity_on_hand int
)
row format delimited fields terminated by '|'
location '${LOCATION}/inventory';
-- Table<store (29 cols)>
drop table if exists store;
create external table if not exists store(
s_store_sk bigint
, s_store_id char(16)
, s_rec_start_date date
, s_rec_end_date date
, s_closed_date_sk bigint
, s_store_name varchar(50)
, s_number_employees int
, s_floor_space int
, s_hours char(20)
, S_manager varchar(40)
, S_market_id int
, S_geography_class varchar(100)
, S_market_desc varchar(100)
, s_market_manager varchar(40)
, s_division_id int
, s_division_name varchar(50)
, s_company_id int
, s_company_name varchar(50)
, s_street_number varchar(10)
, s_street_name varchar(60)
, s_street_type char(15)
, s_suite_number char(10)
, s_city varchar(60)
, s_county varchar(30)
, s_state char(2)
, s_zip char(10)
, s_country varchar(20)
, s_gmt_offset decimal(5,2)
, s_tax_percentage decimal(5,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/store'
tblproperties ('serialization.null.format'='');
-- Table<call_center (31 cols)>
drop table if exists call_center;
create external table if not exists call_center(
cc_call_center_sk bigint
, cc_call_center_id char(16)
, cc_rec_start_date date
, cc_rec_end_date date
, cc_closed_date_sk bigint
, cc_open_date_sk bigint
, cc_name varchar(50)
, cc_class varchar(50)
, cc_employees int
, cc_sq_ft int
, cc_hours char(20)
, cc_manager varchar(40)
, cc_mkt_id int
, cc_mkt_class char(50)
, cc_mkt_desc varchar(100)
, cc_market_manager varchar(40)
, cc_division int
, cc_division_name varchar(50)
, cc_company int
, cc_company_name char(50)
, cc_street_number char(10)
, cc_street_name varchar(60)
, cc_street_type char(15)
, cc_suite_number char(10)
, cc_city varchar(60)
, cc_county varchar(30)
, cc_state char(2)
, cc_zip char(10)
, cc_country varchar(20)
, cc_gmt_offset decimal(5,2)
, cc_tax_percentage decimal(5,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/call_center'
tblproperties ('serialization.null.format'='');
-- Table<catalog_page (9 cols)>
drop table if exists catalog_page;
create external table if not exists catalog_page(
cp_catalog_page_sk bigint
, cp_catalog_page_id char(16)
, cp_start_date_sk bigint
, cp_end_date_sk bigint
, cp_department varchar(50)
, cp_catalog_number int
, cp_catalog_page_number int
, cp_description varchar(100)
, cp_type varchar(100)
)
row format delimited fields terminated by '|'
location '${LOCATION}/catalog_page'
tblproperties ('serialization.null.format'='');
-- Table<web_site (26 cols)>
drop table if exists web_site;
create external table if not exists web_site(
web_site_sk bigint
, web_site_id char(16)
, web_rec_start_date date
, web_rec_end_date date
, web_name varchar(50)
, web_open_date_sk bigint
, web_close_date_sk bigint
, web_class varchar(50)
, web_manager varchar(40)
, web_mkt_id int
, web_mkt_class varchar(50)
, web_mkt_desc varchar(100)
, web_market_manager varchar(40)
, web_company_id int
, web_company_name char(50)
, web_street_number char(10)
, web_street_name varchar(60)
, web_street_type char(15)
, web_suite_number char(10)
, web_city varchar(60)
, web_county varchar(30)
, web_state char(2)
, web_zip char(10)
, web_country varchar(20)
, web_gmt_offset decimal(5,2)
, web_tax_percentage decimal(5,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/web_site'
tblproperties ('serialization.null.format'='');
-- Table<web_page (14 cols)>
drop table if exists web_page;
create external table if not exists web_page(
wp_web_page_sk bigint
, wp_web_page_id char(16)
, wp_rec_start_date date
, wp_rec_end_date date
, wp_creation_date_sk bigint
, wp_access_date_sk bigint
, wp_autogen_flag char(1)
, wp_customer_sk bigint
, wp_url varchar(100)
, wp_type char(50)
, wp_char_count int
, wp_link_count int
, wp_image_count int
, wp_max_ad_count int
)
row format delimited fields terminated by '|'
location '${LOCATION}/web_page'
tblproperties ('serialization.null.format'='');
-- Table<warehouse (14 cols)>
drop table if exists warehouse;
create external table if not exists warehouse(
w_warehouse_sk bigint
, w_warehouse_id char(16)
, w_warehouse_name varchar(20)
, w_warehouse_sq_ft int
, w_street_number char(10)
, w_street_name varchar(60)
, w_street_type char(15)
, w_suite_number char(10)
, w_city varchar(60)
, w_county varchar(30)
, w_state char(2)
, w_zip char(10)
, w_country varchar(20)
, w_gmt_offset decimal(5,2)
)
row format delimited fields terminated by '|'
location '${LOCATION}/warehouse'
tblproperties ('serialization.null.format'='');
-- Table<customer (18 cols)>
drop table if exists customer;
create external table if not exists customer(
c_customer_sk bigint
, c_customer_id char(16)
, c_current_cdemo_sk bigint
, c_current_hdemo_sk bigint
, c_current_addr_sk bigint
, c_first_shipto_date_sk bigint
, c_first_sales_date_sk bigint
, c_salutation char(10)
, c_first_name char(20)
, c_last_name char(30)
, c_preferred_cust_flag char(1)
, c_birth_day int
, c_birth_month int
, c_birth_year int
, c_birth_country varchar(20)
, c_login char(13)
, c_email_address char(50)
, c_last_review_date_sk bigint
)
row format delimited fields terminated by '|'
location '${LOCATION}/customer'
tblproperties ('serialization.null.format'='');
-- Table<customer_address (13 cols)>
drop table if exists customer_address;
create external table if not exists customer_address(
ca_address_sk bigint
, ca_address_id char(16)
, ca_street_number char(10)
, ca_street_name varchar(60)
, ca_street_type char(15)
, ca_suite_number char(10)
, ca_city varchar(60)
, ca_county varchar(30)
, ca_state char(2)
, ca_zip char(10)
, ca_country varchar(20)
, ca_gmt_offset decimal(5,2)
, ca_location_type char(20)
)
row format delimited fields terminated by '|'
location '${LOCATION}/customer_address'
tblproperties ('serialization.null.format'='');
-- Table<customer_demographics (9 cols)>
drop table if exists customer_demographics;
create external table if not exists customer_demographics(
cd_demo_sk bigint
, cd_gender char(1)
, cd_marital_status char(1)
, cd_education_status char(20)
, cd_purchase_estimate int
, cd_credit_rating char(10)
, cd_dep_count int
, cd_dep_employed_count int
, cd_dep_college_count int
)
row format delimited fields terminated by '|'
location '${LOCATION}/customer_demographics'
tblproperties ('serialization.null.format'='');
-- Table<date_dim (28 cols)>
drop table if exists date_dim;
create external table if not exists date_dim(
d_date_sk bigint
, d_date_id char(16)
, d_date date
, d_month_seq int
, d_week_seq int
, d_quarter_seq int
, d_year int
, d_dow int
, d_moy int
, d_dom int
, d_qoy int
, d_fy_year int
, d_fy_quarter_seq int
, d_fy_week_seq int
, d_day_name char(9)
, d_quarter_name char(6)
, d_holiday char(1)
, d_weekend char(1)
, d_following_holiday char(1)
, d_first_dom int
, d_last_dom int
, d_same_day_ly int
, d_same_day_lq int
, d_current_day char(1)
, d_current_week char(1)
, d_current_month char(1)
, d_current_quarter char(1)
, d_current_year char(1)
)
row format delimited fields terminated by '|'
location '${LOCATION}/date_dim'
tblproperties ('serialization.null.format'='');
-- Table<household_demographics (5 cols)>
drop table if exists household_demographics;
create external table if not exists household_demographics(
hd_demo_sk bigint
, hd_income_band_sk bigint
, hd_buy_potential char(15)
, hd_dep_count int
, hd_vehicle_count int
)
row format delimited fields terminated by '|'
location '${LOCATION}/household_demographics'
tblproperties ('serialization.null.format'='');
-- Table<item (22 cols)>
drop table if exists item;
create external table if not exists item(
i_item_sk bigint
, i_item_id char(16)
, i_rec_start_date date
, i_rec_end_date date
, i_item_desc varchar(200)
, i_current_price decimal(7,2)
, i_wholesale_cost decimal(7,2)
, i_brand_id int
, i_brand char(50)
, i_class_id int
, i_class char(50)
, i_category_id int
, i_category char(50)
, i_manufact_id int
, i_manufact char(50)
, i_size char(20)
, i_formulation char(20)
, i_color char(20)
, i_units char(10)
, i_container char(10)
, i_manager_id int
, i_product_name char(50)
)
row format delimited fields terminated by '|'
location '${LOCATION}/item'
tblproperties ('serialization.null.format'='');
-- Table<income_band (3 cols)>
drop table if exists income_band;
create external table if not exists income_band(
ib_income_band_sk bigint
, ib_lower_bound int
, ib_upper_bound int
)
row format delimited fields terminated by '|'
location '${LOCATION}/income_band';
-- Table<promotion (19 cols)>
drop table if exists promotion;
create external table if not exists promotion(
p_promo_sk bigint
, p_promo_id char(16)
, p_start_date_sk bigint
, p_end_date_sk bigint
, p_item_sk bigint
, p_cost decimal(15,2)
, p_response_target int
, p_promo_name char(50)
, p_channel_dmail char(1)
, p_channel_email char(1)
, p_channel_catalog char(1)
, p_channel_tv char(1)
, p_channel_radio char(1)
, p_channel_press char(1)
, p_channel_event char(1)
, p_channel_demo char(1)
, p_channel_details varchar(100)
, p_purpose char(15)
, p_discount_active char(1)
)
row format delimited fields terminated by '|'
location '${LOCATION}/promotion'
tblproperties ('serialization.null.format'='');
-- Table<reason (3 cols)>
drop table if exists reason;
create external table if not exists reason(
r_reason_sk bigint
, r_reason_id char(16)
, r_reason_desc char(100)
)
row format delimited fields terminated by '|'
location '${LOCATION}/reason'
tblproperties ('serialization.null.format'='');
-- Table<ship_mode (6 cols)>
drop table if exists ship_mode;
create external table if not exists ship_mode(
sm_ship_mode_sk bigint
, sm_ship_mode_id char(16)
, sm_type char(30)
, sm_code char(10)
, sm_carrier char(20)
, sm_contract char(20)
)
row format delimited fields terminated by '|'
location '${LOCATION}/ship_mode'
tblproperties ('serialization.null.format'='');
-- Table<time_dim (10 cols)>
drop table if exists time_dim;
create external table if not exists time_dim(
t_time_sk bigint
, t_time_id char(16)
, t_time int
, t_hour int
, t_minute int
, t_second int
, t_am_pm char(2)
, t_shift char(20)
, t_sub_shift char(20)
, t_meal_time char(20)
)
row format delimited fields terminated by '|'
location '${LOCATION}/time_dim'
tblproperties ('serialization.null.format'='');
================================================
FILE: ddl-tpcds/text/analyze_everything.sql
================================================
analyze table call_center compute statistics for columns;
analyze table catalog_page compute statistics for columns;
analyze table catalog_returns compute statistics for columns;
analyze table catalog_sales compute statistics for columns;
analyze table customer compute statistics for columns;
analyze table customer_address compute statistics for columns;
analyze table customer_demographics compute statistics for columns;
analyze table date_dim compute statistics for columns;
analyze table household_demographics compute statistics for columns;
analyze table income_band compute statistics for columns;
analyze table inventory compute statistics for columns;
analyze table item compute statistics for columns;
analyze table promotion compute statistics for columns;
analyze table reason compute statistics for columns;
analyze table ship_mode compute statistics for columns;
analyze table store compute statistics for columns;
analyze table store_returns compute statistics for columns;
analyze table store_sales compute statistics for columns;
analyze table time_dim compute statistics for columns;
analyze table warehouse compute statistics for columns;
analyze table web_page compute statistics for columns;
analyze table web_returns compute statistics for columns;
analyze table web_sales compute statistics for columns;
analyze table web_site compute statistics for columns;
================================================
FILE: ddl-tpch/bin_flat/alltables.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists lineitem;
create external table lineitem
(L_ORDERKEY BIGINT,
L_PARTKEY BIGINT,
L_SUPPKEY BIGINT,
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 '${LOCATION}/lineitem';
drop table if exists part;
create external table part (P_PARTKEY BIGINT,
P_NAME STRING,
P_MFGR STRING,
P_BRAND STRING,
P_TYPE STRING,
P_SIZE INT,
P_CONTAINER STRING,
P_RETAILPRICE DOUBLE,
P_COMMENT STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION '${LOCATION}/part/';
drop table if exists supplier;
create external table supplier (S_SUPPKEY BIGINT,
S_NAME STRING,
S_ADDRESS STRING,
S_NATIONKEY BIGINT,
S_PHONE STRING,
S_ACCTBAL DOUBLE,
S_COMMENT STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION '${LOCATION}/supplier/';
drop table if exists partsupp;
create external table partsupp (PS_PARTKEY BIGINT,
PS_SUPPKEY BIGINT,
PS_AVAILQTY INT,
PS_SUPPLYCOST DOUBLE,
PS_COMMENT STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION'${LOCATION}/partsupp';
drop table if exists nation;
create external table nation (N_NATIONKEY BIGINT,
N_NAME STRING,
N_REGIONKEY BIGINT,
N_COMMENT STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION '${LOCATION}/nation';
drop table if exists region;
create external table region (R_REGIONKEY BIGINT,
R_NAME STRING,
R_COMMENT STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION '${LOCATION}/region';
drop table if exists customer;
create external table customer (C_CUSTKEY BIGINT,
C_NAME STRING,
C_ADDRESS STRING,
C_NATIONKEY BIGINT,
C_PHONE STRING,
C_ACCTBAL DOUBLE,
C_MKTSEGMENT STRING,
C_COMMENT STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION '${LOCATION}/customer';
drop table if exists orders;
create external table orders (O_ORDERKEY BIGINT,
O_CUSTKEY BIGINT,
O_ORDERSTATUS STRING,
O_TOTALPRICE DOUBLE,
O_ORDERDATE STRING,
O_ORDERPRIORITY STRING,
O_CLERK STRING,
O_SHIPPRIORITY INT,
O_COMMENT STRING)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|' STORED AS TEXTFILE
LOCATION '${LOCATION}/orders';
================================================
FILE: ddl-tpch/bin_flat/analyze.sql
================================================
analyze table nation compute statistics for columns;
analyze table region compute statistics for columns;
analyze table supplier compute statistics for columns;
analyze table part compute statistics for columns;
analyze table partsupp compute statistics for columns;
analyze table customer compute statistics for columns;
analyze table orders compute statistics for columns;
analyze table lineitem compute statistics for columns;
================================================
FILE: ddl-tpch/bin_flat/customer.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists customer;
create table customer
stored as ${FILE}
as select * from ${SOURCE}.customer
cluster by C_MKTSEGMENT
;
================================================
FILE: ddl-tpch/bin_flat/lineitem.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists lineitem;
create table lineitem
stored as ${FILE}
as select * from ${SOURCE}.lineitem
cluster by L_SHIPDATE
;
================================================
FILE: ddl-tpch/bin_flat/nation.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists nation;
create table nation
stored as ${FILE}
as select distinct * from ${SOURCE}.nation;
================================================
FILE: ddl-tpch/bin_flat/orders.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists orders;
create table orders
stored as ${FILE}
as select * from ${SOURCE}.orders
cluster by o_orderdate
;
================================================
FILE: ddl-tpch/bin_flat/part.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists part;
create table part
stored as ${FILE}
as select * from ${SOURCE}.part
cluster by p_brand
;
================================================
FILE: ddl-tpch/bin_flat/partsupp.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists partsupp;
create table partsupp
stored as ${FILE}
as select * from ${SOURCE}.partsupp
cluster by PS_SUPPKEY
;
================================================
FILE: ddl-tpch/bin_flat/region.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists region;
create table region
stored as ${FILE}
as select distinct * from ${SOURCE}.region;
================================================
FILE: ddl-tpch/bin_flat/supplier.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists supplier;
create table supplier
stored as ${FILE}
as select * from ${SOURCE}.supplier
cluster by s_nationkey, s_suppkey
;
================================================
FILE: ddl-tpch/bin_partitioned/analyze.sql
================================================
analyze table nation compute statistics for columns;
analyze table region compute statistics for columns;
analyze table supplier compute statistics for columns;
analyze table part compute statistics for columns;
analyze table partsupp compute statistics for columns;
analyze table customer compute statistics for columns;
analyze table orders compute statistics for columns;
analyze table lineitem compute statistics for columns;
================================================
FILE: ddl-tpch/bin_partitioned/customer.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists customer;
create table customer
stored as ${FILE}
TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB')
as select * from ${SOURCE}.customer
cluster by C_MKTSEGMENT
;
================================================
FILE: ddl-tpch/bin_partitioned/lineitem.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists lineitem;
create table lineitem
(L_ORDERKEY BIGINT,
L_PARTKEY BIGINT,
L_SUPPKEY BIGINT,
L_LINENUMBER INT,
L_QUANTITY DOUBLE,
L_EXTENDEDPRICE DOUBLE,
L_DISCOUNT DOUBLE,
L_TAX DOUBLE,
L_RETURNFLAG STRING,
L_LINESTATUS STRING,
L_COMMITDATE STRING,
L_RECEIPTDATE STRING,
L_SHIPINSTRUCT STRING,
L_SHIPMODE STRING,
L_COMMENT STRING)
partitioned by (L_SHIPDATE STRING)
stored as ${FILE}
;
ALTER TABLE lineitem SET TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB');
INSERT OVERWRITE TABLE lineitem Partition(L_SHIPDATE)
select
L_ORDERKEY ,
L_PARTKEY ,
L_SUPPKEY ,
L_LINENUMBER ,
L_QUANTITY ,
L_EXTENDEDPRICE ,
L_DISCOUNT ,
L_TAX ,
L_RETURNFLAG ,
L_LINESTATUS ,
L_COMMITDATE ,
L_RECEIPTDATE ,
L_SHIPINSTRUCT ,
L_SHIPMODE ,
L_COMMENT ,
L_SHIPDATE
from ${SOURCE}.lineitem
;
================================================
FILE: ddl-tpch/bin_partitioned/nation.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists nation;
create table nation
stored as ${FILE}
TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB')
as select distinct * from ${SOURCE}.nation;
================================================
FILE: ddl-tpch/bin_partitioned/orders.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists orders;
create table orders (O_ORDERKEY BIGINT,
O_CUSTKEY BIGINT,
O_ORDERSTATUS STRING,
O_TOTALPRICE DOUBLE,
O_ORDERPRIORITY STRING,
O_CLERK STRING,
O_SHIPPRIORITY INT,
O_COMMENT STRING)
partitioned by (O_ORDERDATE STRING)
stored as ${FILE}
;
ALTER TABLE orders SET TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB');
INSERT OVERWRITE TABLE orders partition(O_ORDERDATE)
select
O_ORDERKEY ,
O_CUSTKEY ,
O_ORDERSTATUS ,
O_TOTALPRICE ,
O_ORDERPRIORITY ,
O_CLERK ,
O_SHIPPRIORITY ,
O_COMMENT,
O_ORDERDATE
from ${SOURCE}.orders
;
================================================
FILE: ddl-tpch/bin_partitioned/part.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists part;
create table part
stored as ${FILE}
TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB')
as select * from ${SOURCE}.part
cluster by p_brand
;
================================================
FILE: ddl-tpch/bin_partitioned/partsupp.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists partsupp;
create table partsupp
stored as ${FILE}
TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB')
as select * from ${SOURCE}.partsupp
cluster by PS_SUPPKEY
;
================================================
FILE: ddl-tpch/bin_partitioned/region.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists region;
create table region
stored as ${FILE}
TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB')
as select distinct * from ${SOURCE}.region;
================================================
FILE: ddl-tpch/bin_partitioned/supplier.sql
================================================
create database if not exists ${DB};
use ${DB};
drop table if exists supplier;
create table supplier
stored as ${FILE}
TBLPROPERTIES('orc.bloom.filter.columns'='*','orc.compress'='ZLIB')
as select * from ${SOURCE}.supplier
cluster by s_nationkey, s_suppkey
;
================================================
FILE: runSuite.pl
================================================
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
# PROTOTYPES
sub dieWithUsage(;$);
# GLOBALS
my $SCRIPT_NAME = basename( __FILE__ );
my $SCRIPT_PATH = dirname( __FILE__ );
# MAIN
dieWithUsage("one or more parameters not defined") unless @ARGV >= 1;
my $suite = shift;
my $scale = shift || 2;
dieWithUsage("suite name required") unless $suite eq "tpcds" or $suite eq "tpch";
chdir $SCRIPT_PATH;
if( $suite eq 'tpcds' ) {
chdir "sample-queries-tpcds";
} else {
chdir 'sample-queries-tpch';
} # end if
my @queries = glob '*.sql';
my $db = {
'tpcds' => "tpcds_bin_partitioned_orc_$scale",
'tpch' => "tpch_flat_orc_$scale"
};
print "filename,status,time,rows\n";
for my $query ( @queries ) {
my $logname = "$query.log";
my $cmd="echo 'use $db->{${suite}}; source $query;' | hive -i testbench.settings 2>&1 | tee $query.log";
# my $cmd="cat $query.log";
#print $cmd ; exit;
my $hiveStart = time();
my @hiveoutput=`$cmd`;
die "${SCRIPT_NAME}:: ERROR: hive command unexpectedly exited \$? = '$?', \$! = '$!'" if $?;
my $hiveEnd = time();
my $hiveTime = $hiveEnd - $hiveStart;
foreach my $line ( @hiveoutput ) {
if( $line =~ /Time taken:\s+([\d\.]+)\s+seconds,\s+Fetched:\s+(\d+)\s+row/ ) {
print "$query,success,$hiveTime,$2\n";
} elsif(
$line =~ /^FAILED: /
# || /Task failed!/
) {
print "$query,failed,$hiveTime\n";
} # end if
} # end while
} # end for
sub dieWithUsage(;$) {
my $err = shift || '';
if( $err ne '' ) {
chomp $err;
$err = "ERROR: $err\n\n";
} # end if
print STDERR <<USAGE;
${err}Usage:
perl ${SCRIPT_NAME} [tpcds|tpch] [scale]
Description:
This script runs the sample queries and outputs a CSV file of the time it took each query to run. Also, all hive output is kept as a log file named 'queryXX.sql.log' for each query file of the form 'queryXX.sql'. Defaults to scale of 2.
USAGE
exit 1;
}
================================================
FILE: sample-queries-tpcds/README.md
================================================
Sample TPC-DS Queries
=====================
This directory contains sample TPC-DS queries you can run once you have generated your data. Queries are compatible with HDP 2.6 and up.
================================================
FILE: sample-queries-tpcds/query1.sql
================================================
-- start query 1 in stream 0 using template query1.tpl and seed 2031708268
with customer_total_return as
(select sr_customer_sk as ctr_customer_sk
,sr_store_sk as ctr_store_sk
,sum(SR_FEE) as ctr_total_return
from store_returns
,date_dim
where sr_returned_date_sk = d_date_sk
and d_year =2000
group by sr_customer_sk
,sr_store_sk)
select c_customer_id
from customer_total_return ctr1
,store
,customer
where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
from customer_total_return ctr2
where ctr1.ctr_store_sk = ctr2.ctr_store_sk)
and s_store_sk = ctr1.ctr_store_sk
and s_state = 'NM'
and ctr1.ctr_customer_sk = c_customer_sk
order by c_customer_id
limit 100;
-- end query 1 in stream 0 using template query1.tpl
================================================
FILE: sample-queries-tpcds/query10.sql
================================================
-- start query 1 in stream 0 using template query10.tpl and seed 797269820
select
cd_gender,
cd_marital_status,
cd_education_status,
count(*) cnt1,
cd_purchase_estimate,
count(*) cnt2,
cd_credit_rating,
count(*) cnt3,
cd_dep_count,
count(*) cnt4,
cd_dep_employed_count,
count(*) cnt5,
cd_dep_college_count,
count(*) cnt6
from
customer c,customer_address ca,customer_demographics
where
c.c_current_addr_sk = ca.ca_address_sk and
ca_county in ('Fillmore County','McPherson County','Bonneville County','Boone County','Brown County') and
cd_demo_sk = c.c_current_cdemo_sk and
exists (select *
from store_sales,date_dim
where c.c_customer_sk = ss_customer_sk and
ss_sold_date_sk = d_date_sk and
d_year = 2000 and
d_moy between 3 and 3+3) and
(exists (select *
from web_sales,date_dim
where c.c_customer_sk = ws_bill_customer_sk and
ws_sold_date_sk = d_date_sk and
d_year = 2000 and
d_moy between 3 ANd 3+3) or
exists (select *
from catalog_sales,date_dim
where c.c_customer_sk = cs_ship_customer_sk and
cs_sold_date_sk = d_date_sk and
d_year = 2000 and
d_moy between 3 and 3+3))
group by cd_gender,
cd_marital_status,
cd_education_status,
cd_purchase_estimate,
cd_credit_rating,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
order by cd_gender,
cd_marital_status,
cd_education_status,
cd_purchase_estimate,
cd_credit_rating,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
limit 100;
-- end query 1 in stream 0 using template query10.tpl
================================================
FILE: sample-queries-tpcds/query11.sql
================================================
-- start query 1 in stream 0 using template query11.tpl and seed 1819994127
with year_total as (
select c_customer_id customer_id
,c_first_name customer_first_name
,c_last_name customer_last_name
,c_preferred_cust_flag customer_preferred_cust_flag
,c_birth_country customer_birth_country
,c_login customer_login
,c_email_address customer_email_address
,d_year dyear
,sum(ss_ext_list_price-ss_ext_discount_amt) year_total
,'s' sale_type
from customer
,store_sales
,date_dim
where c_customer_sk = ss_customer_sk
and ss_sold_date_sk = d_date_sk
group by c_customer_id
,c_first_name
,c_last_name
,c_preferred_cust_flag
,c_birth_country
,c_login
,c_email_address
,d_year
union all
select c_customer_id customer_id
,c_first_name customer_first_name
,c_last_name customer_last_name
,c_preferred_cust_flag customer_preferred_cust_flag
,c_birth_country customer_birth_country
,c_login customer_login
,c_email_address customer_email_address
,d_year dyear
,sum(ws_ext_list_price-ws_ext_discount_amt) year_total
,'w' sale_type
from customer
,web_sales
,date_dim
where c_customer_sk = ws_bill_customer_sk
and ws_sold_date_sk = d_date_sk
group by c_customer_id
,c_first_name
,c_last_name
,c_preferred_cust_flag
,c_birth_country
,c_login
,c_email_address
,d_year
)
select
t_s_secyear.customer_id
,t_s_secyear.customer_first_name
,t_s_secyear.customer_last_name
,t_s_secyear.customer_birth_country
from year_total t_s_firstyear
,year_total t_s_secyear
,year_total t_w_firstyear
,year_total t_w_secyear
where t_s_secyear.customer_id = t_s_firstyear.customer_id
and t_s_firstyear.customer_id = t_w_secyear.customer_id
and t_s_firstyear.customer_id = t_w_firstyear.customer_id
and t_s_firstyear.sale_type = 's'
and t_w_firstyear.sale_type = 'w'
and t_s_secyear.sale_type = 's'
and t_w_secyear.sale_type = 'w'
and t_s_firstyear.dyear = 1999
and t_s_secyear.dyear = 1999+1
and t_w_firstyear.dyear = 1999
and t_w_secyear.dyear = 1999+1
and t_s_firstyear.year_total > 0
and t_w_firstyear.year_total > 0
and case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0 end
> case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else 0.0 end
order by t_s_secyear.customer_id
,t_s_secyear.customer_first_name
,t_s_secyear.customer_last_name
,t_s_secyear.customer_birth_country
limit 100;
-- end query 1 in stream 0 using template query11.tpl
================================================
FILE: sample-queries-tpcds/query12.sql
================================================
-- start query 1 in stream 0 using template query12.tpl and seed 345591136
select i_item_id
,i_item_desc
,i_category
,i_class
,i_current_price
,sum(ws_ext_sales_price) as itemrevenue
,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
(partition by i_class) as revenueratio
from
web_sales
,item
,date_dim
where
ws_item_sk = i_item_sk
and i_category in ('Electronics', 'Books', 'Women')
and ws_sold_date_sk = d_date_sk
and d_date between cast('1998-01-06' as date)
and (cast('1998-01-06' as date) + 30 days)
group by
i_item_id
,i_item_desc
,i_category
,i_class
,i_current_price
order by
i_category
,i_class
,i_item_id
,i_item_desc
,revenueratio
limit 100;
-- end query 1 in stream 0 using template query12.tpl
================================================
FILE: sample-queries-tpcds/query13.sql
================================================
-- start query 1 in stream 0 using template query13.tpl and seed 622697896
select avg(ss_quantity)
,avg(ss_ext_sales_price)
,avg(ss_ext_wholesale_cost)
,sum(ss_ext_wholesale_cost)
from store_sales
,store
,customer_demographics
,household_demographics
,customer_address
,date_dim
where s_store_sk = ss_store_sk
and ss_sold_date_sk = d_date_sk and d_year = 2001
and((ss_hdemo_sk=hd_demo_sk
and cd_demo_sk = ss_cdemo_sk
and cd_marital_status = 'U'
and cd_education_status = 'Secondary'
and ss_sales_price between 100.00 and 150.00
and hd_dep_count = 3
)or
(ss_hdemo_sk=hd_demo_sk
and cd_demo_sk = ss_cdemo_sk
and cd_marital_status = 'W'
and cd_education_status = 'College'
and ss_sales_price between 50.00 and 100.00
and hd_dep_count = 1
) or
(ss_hdemo_sk=hd_demo_sk
and cd_demo_sk = ss_cdemo_sk
and cd_marital_status = 'D'
and cd_education_status = 'Primary'
and ss_sales_price between 150.00 and 200.00
and hd_dep_count = 1
))
and((ss_addr_sk = ca_address_sk
and ca_country = 'United States'
and ca_state in ('TX', 'OK', 'MI')
and ss_net_profit between 100 and 200
) or
(ss_addr_sk = ca_address_sk
and ca_country = 'United States'
and ca_state in ('WA', 'NC', 'OH')
and ss_net_profit between 150 and 300
) or
(ss_addr_sk = ca_address_sk
and ca_country = 'United States'
and ca_state in ('MT', 'FL', 'GA')
and ss_net_profit between 50 and 250
))
;
-- end query 1 in stream 0 using template query13.tpl
================================================
FILE: sample-queries-tpcds/query14.sql
================================================
-- start query 1 in stream 0 using template query14.tpl and seed 1819994127
with cross_items as
(select i_item_sk ss_item_sk
from item,
(select iss.i_brand_id brand_id
,iss.i_class_id class_id
,iss.i_category_id category_id
from store_sales
,item iss
,date_dim d1
where ss_item_sk = iss.i_item_sk
and ss_sold_date_sk = d1.d_date_sk
and d1.d_year between 2000 AND 2000 + 2
intersect
select ics.i_brand_id
,ics.i_class_id
,ics.i_category_id
from catalog_sales
,item ics
,date_dim d2
where cs_item_sk = ics.i_item_sk
and cs_sold_date_sk = d2.d_date_sk
and d2.d_year between 2000 AND 2000 + 2
intersect
select iws.i_brand_id
,iws.i_class_id
,iws.i_category_id
from web_sales
,item iws
,date_dim d3
where ws_item_sk = iws.i_item_sk
and ws_sold_date_sk = d3.d_date_sk
and d3.d_year between 2000 AND 2000 + 2) x
where i_brand_id = brand_id
and i_class_id = class_id
and i_category_id = category_id
),
avg_sales as
(select avg(quantity*list_price) average_sales
from (select ss_quantity quantity
,ss_list_price list_price
from store_sales
,date_dim
where ss_sold_date_sk = d_date_sk
and d_year between 2000 and 2000 + 2
union all
select cs_quantity quantity
,cs_list_price list_price
from catalog_sales
,date_dim
where cs_sold_date_sk = d_date_sk
and d_year between 2000 and 2000 + 2
union all
select ws_quantity quantity
,ws_list_price list_price
from web_sales
,date_dim
where ws_sold_date_sk = d_date_sk
and d_year between 2000 and 2000 + 2) x)
select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales)
from(
select 'store' channel, i_brand_id,i_class_id
,i_category_id,sum(ss_quantity*ss_list_price) sales
, count(*) number_sales
from store_sales
,item
,date_dim
where ss_item_sk in (select ss_item_sk from cross_items)
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_year = 2000+2
and d_moy = 11
group by i_brand_id,i_class_id,i_category_id
having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)
union all
select 'catalog' channel, i_brand_id,i_class_id,i_category_id, sum(cs_quantity*cs_list_price) sales, count(*) number_sales
from catalog_sales
,item
,date_dim
where cs_item_sk in (select ss_item_sk from cross_items)
and cs_item_sk = i_item_sk
and cs_sold_date_sk = d_date_sk
and d_year = 2000+2
and d_moy = 11
group by i_brand_id,i_class_id,i_category_id
having sum(cs_quantity*cs_list_price) > (select average_sales from avg_sales)
union all
select 'web' channel, i_brand_id,i_class_id,i_category_id, sum(ws_quantity*ws_list_price) sales , count(*) number_sales
from web_sales
,item
,date_dim
where ws_item_sk in (select ss_item_sk from cross_items)
and ws_item_sk = i_item_sk
and ws_sold_date_sk = d_date_sk
and d_year = 2000+2
and d_moy = 11
group by i_brand_id,i_class_id,i_category_id
having sum(ws_quantity*ws_list_price) > (select average_sales from avg_sales)
) y
group by rollup (channel, i_brand_id,i_class_id,i_category_id)
order by channel,i_brand_id,i_class_id,i_category_id
limit 100;
with cross_items as
(select i_item_sk ss_item_sk
from item,
(select iss.i_brand_id brand_id
,iss.i_class_id class_id
,iss.i_category_id category_id
from store_sales
,item iss
,date_dim d1
where ss_item_sk = iss.i_item_sk
and ss_sold_date_sk = d1.d_date_sk
and d1.d_year between 2000 AND 2000 + 2
intersect
select ics.i_brand_id
,ics.i_class_id
,ics.i_category_id
from catalog_sales
,item ics
,date_dim d2
where cs_item_sk = ics.i_item_sk
and cs_sold_date_sk = d2.d_date_sk
and d2.d_year between 2000 AND 2000 + 2
intersect
select iws.i_brand_id
,iws.i_class_id
,iws.i_category_id
from web_sales
,item iws
,date_dim d3
where ws_item_sk = iws.i_item_sk
and ws_sold_date_sk = d3.d_date_sk
and d3.d_year between 2000 AND 2000 + 2) x
where i_brand_id = brand_id
and i_class_id = class_id
and i_category_id = category_id
),
avg_sales as
(select avg(quantity*list_price) average_sales
from (select ss_quantity quantity
,ss_list_price list_price
from store_sales
,date_dim
where ss_sold_date_sk = d_date_sk
and d_year between 2000 and 2000 + 2
union all
select cs_quantity quantity
,cs_list_price list_price
from catalog_sales
,date_dim
where cs_sold_date_sk = d_date_sk
and d_year between 2000 and 2000 + 2
union all
select ws_quantity quantity
,ws_list_price list_price
from web_sales
,date_dim
where ws_sold_date_sk = d_date_sk
and d_year between 2000 and 2000 + 2) x)
select this_year.channel ty_channel
,this_year.i_brand_id ty_brand
,this_year.i_class_id ty_class
,this_year.i_category_id ty_category
,this_year.sales ty_sales
,this_year.number_sales ty_number_sales
,last_year.channel ly_channel
,last_year.i_brand_id ly_brand
,last_year.i_class_id ly_class
,last_year.i_category_id ly_category
,last_year.sales ly_sales
,last_year.number_sales ly_number_sales
from
(select 'store' channel, i_brand_id,i_class_id,i_category_id
,sum(ss_quantity*ss_list_price) sales, count(*) number_sales
from store_sales
,item
,date_dim
where ss_item_sk in (select ss_item_sk from cross_items)
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_week_seq = (select d_week_seq
from date_dim
where d_year = 2000 + 1
and d_moy = 12
and d_dom = 15)
group by i_brand_id,i_class_id,i_category_id
having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) this_year,
(select 'store' channel, i_brand_id,i_class_id
,i_category_id, sum(ss_quantity*ss_list_price) sales, count(*) number_sales
from store_sales
,item
,date_dim
where ss_item_sk in (select ss_item_sk from cross_items)
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_week_seq = (select d_week_seq
from date_dim
where d_year = 2000
and d_moy = 12
and d_dom = 15)
group by i_brand_id,i_class_id,i_category_id
having sum(ss_quantity*ss_list_price) > (select average_sales from avg_sales)) last_year
where this_year.i_brand_id= last_year.i_brand_id
and this_year.i_class_id = last_year.i_class_id
and this_year.i_category_id = last_year.i_category_id
order by this_year.channel, this_year.i_brand_id, this_year.i_class_id, this_year.i_category_id
limit 100;
-- end query 1 in stream 0 using template query14.tpl
================================================
FILE: sample-queries-tpcds/query15.sql
================================================
-- start query 1 in stream 0 using template query15.tpl and seed 1819994127
select ca_zip
,sum(cs_sales_price)
from catalog_sales
,customer
,customer_address
,date_dim
where cs_bill_customer_sk = c_customer_sk
and c_current_addr_sk = ca_address_sk
and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
'85392', '85460', '80348', '81792')
or ca_state in ('CA','WA','GA')
or cs_sales_price > 500)
and cs_sold_date_sk = d_date_sk
and d_qoy = 2 and d_year = 1998
group by ca_zip
order by ca_zip
limit 100;
-- end query 1 in stream 0 using template query15.tpl
================================================
FILE: sample-queries-tpcds/query16.sql
================================================
-- start query 1 in stream 0 using template query16.tpl and seed 171719422
select
count(distinct cs_order_number) as `order count`
,sum(cs_ext_ship_cost) as `total shipping cost`
,sum(cs_net_profit) as `total net profit`
from
catalog_sales cs1
,date_dim
,customer_address
,call_center
where
d_date between '1999-4-01' and
(cast('1999-4-01' as date) + 60 days)
and cs1.cs_ship_date_sk = d_date_sk
and cs1.cs_ship_addr_sk = ca_address_sk
and ca_state = 'IL'
and cs1.cs_call_center_sk = cc_call_center_sk
and cc_county in ('Richland County','Bronx County','Maverick County','Mesa County',
'Raleigh County'
)
and exists (select *
from catalog_sales cs2
where cs1.cs_order_number = cs2.cs_order_number
and cs1.cs_warehouse_sk <> cs2.cs_warehouse_sk)
and not exists(select *
from catalog_returns cr1
where cs1.cs_order_number = cr1.cr_order_number)
order by count(distinct cs_order_number)
limit 100;
-- end query 1 in stream 0 using template query16.tpl
================================================
FILE: sample-queries-tpcds/query17.sql
================================================
-- start query 1 in stream 0 using template query17.tpl and seed 1819994127
select i_item_id
,i_item_desc
,s_state
,count(ss_quantity) as store_sales_quantitycount
,avg(ss_quantity) as store_sales_quantityave
,stddev_samp(ss_quantity) as store_sales_quantitystdev
,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
,count(sr_return_quantity) as store_returns_quantitycount
,avg(sr_return_quantity) as store_returns_quantityave
,stddev_samp(sr_return_quantity) as store_returns_quantitystdev
,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
,stddev_samp(cs_quantity) as catalog_sales_quantitystdev
,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
from store_sales
,store_returns
,catalog_sales
,date_dim d1
,date_dim d2
,date_dim d3
,store
,item
where d1.d_quarter_name = '2000Q1'
and d1.d_date_sk = ss_sold_date_sk
and i_item_sk = ss_item_sk
and s_store_sk = ss_store_sk
and ss_customer_sk = sr_customer_sk
and ss_item_sk = sr_item_sk
and ss_ticket_number = sr_ticket_number
and sr_returned_date_sk = d2.d_date_sk
and d2.d_quarter_name in ('2000Q1','2000Q2','2000Q3')
and sr_customer_sk = cs_bill_customer_sk
and sr_item_sk = cs_item_sk
and cs_sold_date_sk = d3.d_date_sk
and d3.d_quarter_name in ('2000Q1','2000Q2','2000Q3')
group by i_item_id
,i_item_desc
,s_state
order by i_item_id
,i_item_desc
,s_state
limit 100;
-- end query 1 in stream 0 using template query17.tpl
================================================
FILE: sample-queries-tpcds/query18.sql
================================================
-- start query 1 in stream 0 using template query18.tpl and seed 1978355063
select i_item_id,
ca_country,
ca_state,
ca_county,
avg( cast(cs_quantity as decimal(12,2))) agg1,
avg( cast(cs_list_price as decimal(12,2))) agg2,
avg( cast(cs_coupon_amt as decimal(12,2))) agg3,
avg( cast(cs_sales_price as decimal(12,2))) agg4,
avg( cast(cs_net_profit as decimal(12,2))) agg5,
avg( cast(c_birth_year as decimal(12,2))) agg6,
avg( cast(cd1.cd_dep_count as decimal(12,2))) agg7
from catalog_sales, customer_demographics cd1,
customer_demographics cd2, customer, customer_address, date_dim, item
where cs_sold_date_sk = d_date_sk and
cs_item_sk = i_item_sk and
cs_bill_cdemo_sk = cd1.cd_demo_sk and
cs_bill_customer_sk = c_customer_sk and
cd1.cd_gender = 'M' and
cd1.cd_education_status = 'Unknown' and
c_current_cdemo_sk = cd2.cd_demo_sk and
c_current_addr_sk = ca_address_sk and
c_birth_month in (5,1,4,7,8,9) and
d_year = 2002 and
ca_state in ('AR','TX','NC'
,'GA','MS','WV','AL')
group by rollup (i_item_id, ca_country, ca_state, ca_county)
order by ca_country,
ca_state,
ca_county,
i_item_id
limit 100;
-- end query 1 in stream 0 using template query18.tpl
================================================
FILE: sample-queries-tpcds/query19.sql
================================================
-- start query 1 in stream 0 using template query19.tpl and seed 1930872976
select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
sum(ss_ext_sales_price) ext_price
from date_dim, store_sales, item,customer,customer_address,store
where d_date_sk = ss_sold_date_sk
and ss_item_sk = i_item_sk
and i_manager_id=16
and d_moy=12
and d_year=1998
and ss_customer_sk = c_customer_sk
and c_current_addr_sk = ca_address_sk
and substr(ca_zip,1,5) <> substr(s_zip,1,5)
and ss_store_sk = s_store_sk
group by i_brand
,i_brand_id
,i_manufact_id
,i_manufact
order by ext_price desc
,i_brand
,i_brand_id
,i_manufact_id
,i_manufact
limit 100 ;
-- end query 1 in stream 0 using template query19.tpl
================================================
FILE: sample-queries-tpcds/query2.sql
================================================
-- start query 1 in stream 0 using template query2.tpl and seed 1819994127
with wscs as
(select sold_date_sk
,sales_price
from (select ws_sold_date_sk sold_date_sk
,ws_ext_sales_price sales_price
from web_sales) x
union all
(select cs_sold_date_sk sold_date_sk
,cs_ext_sales_price sales_price
from catalog_sales)),
wswscs as
(select d_week_seq,
sum(case when (d_day_name='Sunday') then sales_price else null end) sun_sales,
sum(case when (d_day_name='Monday') then sales_price else null end) mon_sales,
sum(case when (d_day_name='Tuesday') then sales_price else null end) tue_sales,
sum(case when (d_day_name='Wednesday') then sales_price else null end) wed_sales,
sum(case when (d_day_name='Thursday') then sales_price else null end) thu_sales,
sum(case when (d_day_name='Friday') then sales_price else null end) fri_sales,
sum(case when (d_day_name='Saturday') then sales_price else null end) sat_sales
from wscs
,date_dim
where d_date_sk = sold_date_sk
group by d_week_seq)
select d_week_seq1
,round(sun_sales1/sun_sales2,2)
,round(mon_sales1/mon_sales2,2)
,round(tue_sales1/tue_sales2,2)
,round(wed_sales1/wed_sales2,2)
,round(thu_sales1/thu_sales2,2)
,round(fri_sales1/fri_sales2,2)
,round(sat_sales1/sat_sales2,2)
from
(select wswscs.d_week_seq d_week_seq1
,sun_sales sun_sales1
,mon_sales mon_sales1
,tue_sales tue_sales1
,wed_sales wed_sales1
,thu_sales thu_sales1
,fri_sales fri_sales1
,sat_sales sat_sales1
from wswscs,date_dim
where date_dim.d_week_seq = wswscs.d_week_seq and
d_year = 1998) y,
(select wswscs.d_week_seq d_week_seq2
,sun_sales sun_sales2
,mon_sales mon_sales2
,tue_sales tue_sales2
,wed_sales wed_sales2
,thu_sales thu_sales2
,fri_sales fri_sales2
,sat_sales sat_sales2
from wswscs
,date_dim
where date_dim.d_week_seq = wswscs.d_week_seq and
d_year = 1998+1) z
where d_week_seq1=d_week_seq2-53
order by d_week_seq1;
-- end query 1 in stream 0 using template query2.tpl
================================================
FILE: sample-queries-tpcds/query20.sql
================================================
-- start query 1 in stream 0 using template query20.tpl and seed 345591136
select i_item_id
,i_item_desc
,i_category
,i_class
,i_current_price
,sum(cs_ext_sales_price) as itemrevenue
,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
(partition by i_class) as revenueratio
from catalog_sales
,item
,date_dim
where cs_item_sk = i_item_sk
and i_category in ('Shoes', 'Electronics', 'Children')
and cs_sold_date_sk = d_date_sk
and d_date between cast('2001-03-14' as date)
and (cast('2001-03-14' as date) + 30 days)
group by i_item_id
,i_item_desc
,i_category
,i_class
,i_current_price
order by i_category
,i_class
,i_item_id
,i_item_desc
,revenueratio
limit 100;
-- end query 1 in stream 0 using template query20.tpl
================================================
FILE: sample-queries-tpcds/query21.sql
================================================
-- start query 1 in stream 0 using template query21.tpl and seed 1819994127
select *
from(select w_warehouse_name
,i_item_id
,sum(case when (cast(d_date as date) < cast ('1999-03-20' as date))
then inv_quantity_on_hand
else 0 end) as inv_before
,sum(case when (cast(d_date as date) >= cast ('1999-03-20' as date))
then inv_quantity_on_hand
else 0 end) as inv_after
from inventory
,warehouse
,item
,date_dim
where i_current_price between 0.99 and 1.49
and i_item_sk = inv_item_sk
and inv_warehouse_sk = w_warehouse_sk
and inv_date_sk = d_date_sk
and d_date between (cast ('1999-03-20' as date) - 30 days)
and (cast ('1999-03-20' as date) + 30 days)
group by w_warehouse_name, i_item_id) x
where (case when inv_before > 0
then inv_after / inv_before
else null
end) between 2.0/3.0 and 3.0/2.0
order by w_warehouse_name
,i_item_id
limit 100;
-- end query 1 in stream 0 using template query21.tpl
================================================
FILE: sample-queries-tpcds/query22.sql
================================================
-- start query 1 in stream 0 using template query22.tpl and seed 1819994127
select i_product_name
,i_brand
,i_class
,i_category
,avg(inv_quantity_on_hand) qoh
from inventory
,date_dim
,item
where inv_date_sk=d_date_sk
and inv_item_sk=i_item_sk
and d_month_seq between 1186 and 1186 + 11
group by rollup(i_product_name
,i_brand
,i_class
,i_category)
order by qoh, i_product_name, i_brand, i_class, i_category
limit 100;
-- end query 1 in stream 0 using template query22.tpl
================================================
FILE: sample-queries-tpcds/query23.sql
================================================
-- start query 1 in stream 0 using template query23.tpl and seed 2031708268
with frequent_ss_items as
(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt
from store_sales
,date_dim
,item
where ss_sold_date_sk = d_date_sk
and ss_item_sk = i_item_sk
and d_year in (2000,2000+1,2000+2,2000+3)
group by substr(i_item_desc,1,30),i_item_sk,d_date
having count(*) >4),
max_store_sales as
(select max(csales) tpcds_cmax
from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales
from store_sales
,customer
,date_dim
where ss_customer_sk = c_customer_sk
and ss_sold_date_sk = d_date_sk
and d_year in (2000,2000+1,2000+2,2000+3)
group by c_customer_sk) x),
best_ss_customer as
(select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales
from store_sales
,customer
where ss_customer_sk = c_customer_sk
group by c_customer_sk
having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select
*
from
max_store_sales))
select sum(sales)
from (select cs_quantity*cs_list_price sales
from catalog_sales
,date_dim
where d_year = 2000
and d_moy = 3
and cs_sold_date_sk = d_date_sk
and cs_item_sk in (select item_sk from frequent_ss_items)
and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer)
union all
select ws_quantity*ws_list_price sales
from web_sales
,date_dim
where d_year = 2000
and d_moy = 3
and ws_sold_date_sk = d_date_sk
and ws_item_sk in (select item_sk from frequent_ss_items)
and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) y
limit 100;
with frequent_ss_items as
(select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt
from store_sales
,date_dim
,item
where ss_sold_date_sk = d_date_sk
and ss_item_sk = i_item_sk
and d_year in (2000,2000 + 1,2000 + 2,2000 + 3)
group by substr(i_item_desc,1,30),i_item_sk,d_date
having count(*) >4),
max_store_sales as
(select max(csales) tpcds_cmax
from (select c_customer_sk,sum(ss_quantity*ss_sales_price) csales
from store_sales
,customer
,date_dim
where ss_customer_sk = c_customer_sk
and ss_sold_date_sk = d_date_sk
and d_year in (2000,2000+1,2000+2,2000+3)
group by c_customer_sk) x),
best_ss_customer as
(select c_customer_sk,sum(ss_quantity*ss_sales_price) ssales
from store_sales
,customer
where ss_customer_sk = c_customer_sk
group by c_customer_sk
having sum(ss_quantity*ss_sales_price) > (95/100.0) * (select
*
from max_store_sales))
select c_last_name,c_first_name,sales
from (select c_last_name,c_first_name,sum(cs_quantity*cs_list_price) sales
from catalog_sales
,customer
,date_dim
where d_year = 2000
and d_moy = 3
and cs_sold_date_sk = d_date_sk
and cs_item_sk in (select item_sk from frequent_ss_items)
and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer)
and cs_bill_customer_sk = c_customer_sk
group by c_last_name,c_first_name
union all
select c_last_name,c_first_name,sum(ws_quantity*ws_list_price) sales
from web_sales
,customer
,date_dim
where d_year = 2000
and d_moy = 3
and ws_sold_date_sk = d_date_sk
and ws_item_sk in (select item_sk from frequent_ss_items)
and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)
and ws_bill_customer_sk = c_customer_sk
group by c_last_name,c_first_name) y
order by c_last_name,c_first_name,sales
limit 100;
-- end query 1 in stream 0 using template query23.tpl
================================================
FILE: sample-queries-tpcds/query24.sql
================================================
-- start query 1 in stream 0 using template query24.tpl and seed 1220860970
with ssales as
(select c_last_name
,c_first_name
,s_store_name
,ca_state
,s_state
,i_color
,i_current_price
,i_manager_id
,i_units
,i_size
,sum(ss_sales_price) netpaid
from store_sales
,store_returns
,store
,item
,customer
,customer_address
where ss_ticket_number = sr_ticket_number
and ss_item_sk = sr_item_sk
and ss_customer_sk = c_customer_sk
and ss_item_sk = i_item_sk
and ss_store_sk = s_store_sk
and c_current_addr_sk = ca_address_sk
and c_birth_country <> upper(ca_country)
and s_zip = ca_zip
and s_market_id=10
group by c_last_name
,c_first_name
,s_store_name
,ca_state
,s_state
,i_color
,i_current_price
,i_manager_id
,i_units
,i_size)
select c_last_name
,c_first_name
,s_store_name
,sum(netpaid) paid
from ssales
where i_color = 'snow'
group by c_last_name
,c_first_name
,s_store_name
having sum(netpaid) > (select 0.05*avg(netpaid)
from ssales)
order by c_last_name
,c_first_name
,s_store_name
;
with ssales as
(select c_last_name
,c_first_name
,s_store_name
,ca_state
,s_state
,i_color
,i_current_price
,i_manager_id
,i_units
,i_size
,sum(ss_sales_price) netpaid
from store_sales
,store_returns
,store
,item
,customer
,customer_address
where ss_ticket_number = sr_ticket_number
and ss_item_sk = sr_item_sk
and ss_customer_sk = c_customer_sk
and ss_item_sk = i_item_sk
and ss_store_sk = s_store_sk
and c_current_addr_sk = ca_address_sk
and c_birth_country <> upper(ca_country)
and s_zip = ca_zip
and s_market_id = 10
group by c_last_name
,c_first_name
,s_store_name
,ca_state
,s_state
,i_color
,i_current_price
,i_manager_id
,i_units
,i_size)
select c_last_name
,c_first_name
,s_store_name
,sum(netpaid) paid
from ssales
where i_color = 'chiffon'
group by c_last_name
,c_first_name
,s_store_name
having sum(netpaid) > (select 0.05*avg(netpaid)
from ssales)
order by c_last_name
,c_first_name
,s_store_name
;
-- end query 1 in stream 0 using template query24.tpl
================================================
FILE: sample-queries-tpcds/query25.sql
================================================
-- start query 1 in stream 0 using template query25.tpl and seed 1819994127
select
i_item_id
,i_item_desc
,s_store_id
,s_store_name
,sum(ss_net_profit) as store_sales_profit
,sum(sr_net_loss) as store_returns_loss
,sum(cs_net_profit) as catalog_sales_profit
from
store_sales
,store_returns
,catalog_sales
,date_dim d1
,date_dim d2
,date_dim d3
,store
,item
where
d1.d_moy = 4
and d1.d_year = 2000
and d1.d_date_sk = ss_sold_date_sk
and i_item_sk = ss_item_sk
and s_store_sk = ss_store_sk
and ss_customer_sk = sr_customer_sk
and ss_item_sk = sr_item_sk
and ss_ticket_number = sr_ticket_number
and sr_returned_date_sk = d2.d_date_sk
and d2.d_moy between 4 and 10
and d2.d_year = 2000
and sr_customer_sk = cs_bill_customer_sk
and sr_item_sk = cs_item_sk
and cs_sold_date_sk = d3.d_date_sk
and d3.d_moy between 4 and 10
and d3.d_year = 2000
group by
i_item_id
,i_item_desc
,s_store_id
,s_store_name
order by
i_item_id
,i_item_desc
,s_store_id
,s_store_name
limit 100;
-- end query 1 in stream 0 using template query25.tpl
================================================
FILE: sample-queries-tpcds/query26.sql
================================================
-- start query 1 in stream 0 using template query26.tpl and seed 1930872976
select i_item_id,
avg(cs_quantity) agg1,
avg(cs_list_price) agg2,
avg(cs_coupon_amt) agg3,
avg(cs_sales_price) agg4
from catalog_sales, customer_demographics, date_dim, item, promotion
where cs_sold_date_sk = d_date_sk and
cs_item_sk = i_item_sk and
cs_bill_cdemo_sk = cd_demo_sk and
cs_promo_sk = p_promo_sk and
cd_gender = 'F' and
cd_marital_status = 'S' and
cd_education_status = 'College' and
(p_channel_email = 'N' or p_channel_event = 'N') and
d_year = 1998
group by i_item_id
order by i_item_id
limit 100;
-- end query 1 in stream 0 using template query26.tpl
================================================
FILE: sample-queries-tpcds/query27.sql
================================================
-- start query 1 in stream 0 using template query27.tpl and seed 2017787633
select i_item_id,
s_state, grouping(s_state) g_state,
avg(ss_quantity) agg1,
avg(ss_list_price) agg2,
avg(ss_coupon_amt) agg3,
avg(ss_sales_price) agg4
from store_sales, customer_demographics, date_dim, store, item
where ss_sold_date_sk = d_date_sk and
ss_item_sk = i_item_sk and
ss_store_sk = s_store_sk and
ss_cdemo_sk = cd_demo_sk and
cd_gender = 'F' and
cd_marital_status = 'U' and
cd_education_status = '2 yr Degree' and
d_year = 2000 and
s_state in ('AL','IN', 'SC', 'NY', 'OH', 'FL')
group by rollup (i_item_id, s_state)
order by i_item_id
,s_state
limit 100;
-- end query 1 in stream 0 using template query27.tpl
================================================
FILE: sample-queries-tpcds/query28.sql
================================================
-- start query 1 in stream 0 using template query28.tpl and seed 444293455
select *
from (select avg(ss_list_price) B1_LP
,count(ss_list_price) B1_CNT
,count(distinct ss_list_price) B1_CNTD
from store_sales
where ss_quantity between 0 and 5
and (ss_list_price between 73 and 73+10
or ss_coupon_amt between 7826 and 7826+1000
or ss_wholesale_cost between 70 and 70+20)) B1,
(select avg(ss_list_price) B2_LP
,count(ss_list_price) B2_CNT
,count(distinct ss_list_price) B2_CNTD
from store_sales
where ss_quantity between 6 and 10
and (ss_list_price between 152 and 152+10
or ss_coupon_amt between 2196 and 2196+1000
or ss_wholesale_cost between 56 and 56+20)) B2,
(select avg(ss_list_price) B3_LP
,count(ss_list_price) B3_CNT
,count(distinct ss_list_price) B3_CNTD
from store_sales
where ss_quantity between 11 and 15
and (ss_list_price between 53 and 53+10
or ss_coupon_amt between 3430 and 3430+1000
or ss_wholesale_cost between 13 and 13+20)) B3,
(select avg(ss_list_price) B4_LP
,count(ss_list_price) B4_CNT
,count(distinct ss_list_price) B4_CNTD
from store_sales
where ss_quantity between 16 and 20
and (ss_list_price between 182 and 182+10
or ss_coupon_amt between 3262 and 3262+1000
or ss_wholesale_cost between 20 and 20+20)) B4,
(select avg(ss_list_price) B5_LP
,count(ss_list_price) B5_CNT
,count(distinct ss_list_price) B5_CNTD
from store_sales
where ss_quantity between 21 and 25
and (ss_list_price between 85 and 85+10
or ss_coupon_amt between 3310 and 3310+1000
or ss_wholesale_cost between 37 and 37+20)) B5,
(select avg(ss_list_price) B6_LP
,count(ss_list_price) B6_CNT
,count(distinct ss_list_price) B6_CNTD
from store_sales
where ss_quantity between 26 and 30
and (ss_list_price between 180 and 180+10
or ss_coupon_amt between 12592 and 12592+1000
or ss_wholesale_cost between 22 and 22+20)) B6
limit 100;
-- end query 1 in stream 0 using template query28.tpl
================================================
FILE: sample-queries-tpcds/query29.sql
================================================
-- start query 1 in stream 0 using template query29.tpl and seed 2031708268
select
i_item_id
,i_item_desc
,s_store_id
,s_store_name
,stddev_samp(ss_quantity) as store_sales_quantity
,stddev_samp(sr_return_quantity) as store_returns_quantity
,stddev_samp(cs_quantity) as catalog_sales_quantity
from
store_sales
,store_returns
,catalog_sales
,date_dim d1
,date_dim d2
,date_dim d3
,store
,item
where
d1.d_moy = 4
and d1.d_year = 1998
and d1.d_date_sk = ss_sold_date_sk
and i_item_sk = ss_item_sk
and s_store_sk = ss_store_sk
and ss_customer_sk = sr_customer_sk
and ss_item_sk = sr_item_sk
and ss_ticket_number = sr_ticket_number
and sr_returned_date_sk = d2.d_date_sk
and d2.d_moy between 4 and 4 + 3
and d2.d_year = 1998
and sr_customer_sk = cs_bill_customer_sk
and sr_item_sk = cs_item_sk
and cs_sold_date_sk = d3.d_date_sk
and d3.d_year in (1998,1998+1,1998+2)
group by
i_item_id
,i_item_desc
,s_store_id
,s_store_name
order by
i_item_id
,i_item_desc
,s_store_id
,s_store_name
limit 100;
-- end query 1 in stream 0 using template query29.tpl
================================================
FILE: sample-queries-tpcds/query3.sql
================================================
-- start query 1 in stream 0 using template query3.tpl and seed 2031708268
select dt.d_year
,item.i_brand_id brand_id
,item.i_brand brand
,sum(ss_sales_price) sum_agg
from date_dim dt
,store_sales
,item
where dt.d_date_sk = store_sales.ss_sold_date_sk
and store_sales.ss_item_sk = item.i_item_sk
and item.i_manufact_id = 816
and dt.d_moy=11
group by dt.d_year
,item.i_brand
,item.i_brand_id
order by dt.d_year
,sum_agg desc
,brand_id
limit 100;
-- end query 1 in stream 0 using template query3.tpl
================================================
FILE: sample-queries-tpcds/query30.sql
================================================
-- start query 1 in stream 0 using template query30.tpl and seed 1819994127
with customer_total_return as
(select wr_returning_customer_sk as ctr_customer_sk
,ca_state as ctr_state,
sum(wr_return_amt) as ctr_total_return
from web_returns
,date_dim
,customer_address
where wr_returned_date_sk = d_date_sk
and d_year =2000
and wr_returning_addr_sk = ca_address_sk
group by wr_returning_customer_sk
,ca_state)
select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
,c_last_review_date_sk,ctr_total_return
from customer_total_return ctr1
,customer_address
,customer
where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2
from customer_total_return ctr2
where ctr1.ctr_state = ctr2.ctr_state)
and ca_address_sk = c_current_addr_sk
and ca_state = 'GA'
and ctr1.ctr_customer_sk = c_customer_sk
order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag
,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address
,c_last_review_date_sk,ctr_total_return
limit 100;
-- end query 1 in stream 0 using template query30.tpl
================================================
FILE: sample-queries-tpcds/query31.sql
================================================
-- start query 1 in stream 0 using template query31.tpl and seed 1819994127
with ss as
(select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales
from store_sales,date_dim,customer_address
where ss_sold_date_sk = d_date_sk
and ss_addr_sk=ca_address_sk
group by ca_county,d_qoy, d_year),
ws as
(select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales
from web_sales,date_dim,customer_address
where ws_sold_date_sk = d_date_sk
and ws_bill_addr_sk=ca_address_sk
group by ca_county,d_qoy, d_year)
select
ss1.ca_county
,ss1.d_year
,ws2.web_sales/ws1.web_sales web_q1_q2_increase
,ss2.store_sales/ss1.store_sales store_q1_q2_increase
,ws3.web_sales/ws2.web_sales web_q2_q3_increase
,ss3.store_sales/ss2.store_sales store_q2_q3_increase
from
ss ss1
,ss ss2
,ss ss3
,ws ws1
,ws ws2
,ws ws3
where
ss1.d_qoy = 1
and ss1.d_year = 1999
and ss1.ca_county = ss2.ca_county
and ss2.d_qoy = 2
and ss2.d_year = 1999
and ss2.ca_county = ss3.ca_county
and ss3.d_qoy = 3
and ss3.d_year = 1999
and ss1.ca_county = ws1.ca_county
and ws1.d_qoy = 1
and ws1.d_year = 1999
and ws1.ca_county = ws2.ca_county
and ws2.d_qoy = 2
and ws2.d_year = 1999
and ws1.ca_county = ws3.ca_county
and ws3.d_qoy = 3
and ws3.d_year =1999
and case when ws1.web_sales > 0 then ws2.web_sales/ws1.web_sales else null end
> case when ss1.store_sales > 0 then ss2.store_sales/ss1.store_sales else null end
and case when ws2.web_sales > 0 then ws3.web_sales/ws2.web_sales else null end
> case when ss2.store_sales > 0 then ss3.store_sales/ss2.store_sales else null end
order by ss1.d_year;
-- end query 1 in stream 0 using template query31.tpl
================================================
FILE: sample-queries-tpcds/query32.sql
================================================
-- start query 1 in stream 0 using template query32.tpl and seed 2031708268
select sum(cs_ext_discount_amt) as `excess discount amount`
from
catalog_sales
,item
,date_dim
where
i_manufact_id = 66
and i_item_sk = cs_item_sk
and d_date between '2002-03-29' and
(cast('2002-03-29' as date) + 90 days)
and d_date_sk = cs_sold_date_sk
and cs_ext_discount_amt
> (
select
1.3 * avg(cs_ext_discount_amt)
from
catalog_sales
,date_dim
where
cs_item_sk = i_item_sk
and d_date between '2002-03-29' and
(cast('2002-03-29' as date) + 90 days)
and d_date_sk = cs_sold_date_sk
)
limit 100;
-- end query 1 in stream 0 using template query32.tpl
================================================
FILE: sample-queries-tpcds/query33.sql
================================================
-- start query 1 in stream 0 using template query33.tpl and seed 1930872976
with ss as (
select
i_manufact_id,sum(ss_ext_sales_price) total_sales
from
store_sales,
date_dim,
customer_address,
item
where
i_manufact_id in (select
i_manufact_id
from
item
where i_category in ('Home'))
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_year = 1998
and d_moy = 5
and ss_addr_sk = ca_address_sk
and ca_gmt_offset = -6
group by i_manufact_id),
cs as (
select
i_manufact_id,sum(cs_ext_sales_price) total_sales
from
catalog_sales,
date_dim,
customer_address,
item
where
i_manufact_id in (select
i_manufact_id
from
item
where i_category in ('Home'))
and cs_item_sk = i_item_sk
and cs_sold_date_sk = d_date_sk
and d_year = 1998
and d_moy = 5
and cs_bill_addr_sk = ca_address_sk
and ca_gmt_offset = -6
group by i_manufact_id),
ws as (
select
i_manufact_id,sum(ws_ext_sales_price) total_sales
from
web_sales,
date_dim,
customer_address,
item
where
i_manufact_id in (select
i_manufact_id
from
item
where i_category in ('Home'))
and ws_item_sk = i_item_sk
and ws_sold_date_sk = d_date_sk
and d_year = 1998
and d_moy = 5
and ws_bill_addr_sk = ca_address_sk
and ca_gmt_offset = -6
group by i_manufact_id)
select i_manufact_id ,sum(total_sales) total_sales
from (select * from ss
union all
select * from cs
union all
select * from ws) tmp1
group by i_manufact_id
order by total_sales
limit 100;
-- end query 1 in stream 0 using template query33.tpl
================================================
FILE: sample-queries-tpcds/query34.sql
================================================
-- start query 1 in stream 0 using template query34.tpl and seed 1971067816
select c_last_name
,c_first_name
,c_salutation
,c_preferred_cust_flag
,ss_ticket_number
,cnt from
(select ss_ticket_number
,ss_customer_sk
,count(*) cnt
from store_sales,date_dim,store,household_demographics
where store_sales.ss_sold_date_sk = date_dim.d_date_sk
and store_sales.ss_store_sk = store.s_store_sk
and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
and (household_demographics.hd_buy_potential = '>10000' or
household_demographics.hd_buy_potential = 'Unknown')
and household_demographics.hd_vehicle_count > 0
and (case when household_demographics.hd_vehicle_count > 0
then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count
else null
end) > 1.2
and date_dim.d_year in (2000,2000+1,2000+2)
and store.s_county in ('Salem County','Terrell County','Arthur County','Oglethorpe County',
'Lunenburg County','Perry County','Halifax County','Sumner County')
group by ss_ticket_number,ss_customer_sk) dn,customer
where ss_customer_sk = c_customer_sk
and cnt between 15 and 20
order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc, ss_ticket_number;
-- end query 1 in stream 0 using template query34.tpl
================================================
FILE: sample-queries-tpcds/query35.sql
================================================
-- start query 1 in stream 0 using template query35.tpl and seed 1930872976
select
ca_state,
cd_gender,
cd_marital_status,
cd_dep_count,
count(*) cnt1,
avg(cd_dep_count),
min(cd_dep_count),
stddev_samp(cd_dep_count),
cd_dep_employed_count,
count(*) cnt2,
avg(cd_dep_employed_count),
min(cd_dep_employed_count),
stddev_samp(cd_dep_employed_count),
cd_dep_college_count,
count(*) cnt3,
avg(cd_dep_college_count),
min(cd_dep_college_count),
stddev_samp(cd_dep_college_count)
from
customer c,customer_address ca,customer_demographics
where
c.c_current_addr_sk = ca.ca_address_sk and
cd_demo_sk = c.c_current_cdemo_sk and
exists (select *
from store_sales,date_dim
where c.c_customer_sk = ss_customer_sk and
ss_sold_date_sk = d_date_sk and
d_year = 2001 and
d_qoy < 4) and
(exists (select *
from web_sales,date_dim
where c.c_customer_sk = ws_bill_customer_sk and
ws_sold_date_sk = d_date_sk and
d_year = 2001 and
d_qoy < 4) or
exists (select *
from catalog_sales,date_dim
where c.c_customer_sk = cs_ship_customer_sk and
cs_sold_date_sk = d_date_sk and
d_year = 2001 and
d_qoy < 4))
group by ca_state,
cd_gender,
cd_marital_status,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
order by ca_state,
cd_gender,
cd_marital_status,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
limit 100;
-- end query 1 in stream 0 using template query35.tpl
================================================
FILE: sample-queries-tpcds/query36.sql
================================================
-- start query 1 in stream 0 using template query36.tpl and seed 1544728811
select
sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin
,i_category
,i_class
,grouping(i_category)+grouping(i_class) as lochierarchy
,rank() over (
partition by grouping(i_category)+grouping(i_class),
case when grouping(i_class) = 0 then i_category end
order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent
from
store_sales
,date_dim d1
,item
,store
where
d1.d_year = 1999
and d1.d_date_sk = ss_sold_date_sk
and i_item_sk = ss_item_sk
and s_store_sk = ss_store_sk
and s_state in ('IN','AL','MI','MN',
'TN','LA','FL','NM')
group by rollup(i_category,i_class)
order by
lochierarchy desc
,case when lochierarchy = 0 then i_category end
,rank_within_parent
limit 100;
-- end query 1 in stream 0 using template query36.tpl
================================================
FILE: sample-queries-tpcds/query37.sql
================================================
-- start query 1 in stream 0 using template query37.tpl and seed 301843662
select i_item_id
,i_item_desc
,i_current_price
from item, inventory, date_dim, catalog_sales
where i_current_price between 39 and 39 + 30
and inv_item_sk = i_item_sk
and d_date_sk=inv_date_sk
and d_date between cast('2001-01-16' as date) and (cast('2001-01-16' as date) + 60 days)
and i_manufact_id in (765,886,889,728)
and inv_quantity_on_hand between 100 and 500
and cs_item_sk = i_item_sk
group by i_item_id,i_item_desc,i_current_price
order by i_item_id
limit 100;
-- end query 1 in stream 0 using template query37.tpl
================================================
FILE: sample-queries-tpcds/query38.sql
================================================
-- start query 1 in stream 0 using template query38.tpl and seed 1819994127
select count(*) from (
select distinct c_last_name, c_first_name, d_date
from store_sales, date_dim, customer
where store_sales.ss_sold_date_sk = date_dim.d_date_sk
and store_sales.ss_customer_sk = customer.c_customer_sk
and d_month_seq between 1186 and 1186 + 11
intersect
select distinct c_last_name, c_first_name, d_date
from catalog_sales, date_dim, customer
where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
and d_month_seq between 1186 and 1186 + 11
intersect
select distinct c_last_name, c_first_name, d_date
from web_sales, date_dim, customer
where web_sales.ws_sold_date_sk = date_dim.d_date_sk
and web_sales.ws_bill_customer_sk = customer.c_customer_sk
and d_month_seq between 1186 and 1186 + 11
) hot_cust
limit 100;
-- end query 1 in stream 0 using template query38.tpl
================================================
FILE: sample-queries-tpcds/query39.sql
================================================
-- start query 1 in stream 0 using template query39.tpl and seed 1327317894
with inv as
(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
,stdev,mean, case mean when 0 then null else stdev/mean end cov
from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
from inventory
,item
,warehouse
,date_dim
where inv_item_sk = i_item_sk
and inv_warehouse_sk = w_warehouse_sk
and inv_date_sk = d_date_sk
and d_year =2000
group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
where case mean when 0 then 0 else stdev/mean end > 1)
select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
from inv inv1,inv inv2
where inv1.i_item_sk = inv2.i_item_sk
and inv1.w_warehouse_sk = inv2.w_warehouse_sk
and inv1.d_moy=2
and inv2.d_moy=2+1
order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
,inv2.d_moy,inv2.mean, inv2.cov
;
with inv as
(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
,stdev,mean, case mean when 0 then null else stdev/mean end cov
from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
from inventory
,item
,warehouse
,date_dim
where inv_item_sk = i_item_sk
and inv_warehouse_sk = w_warehouse_sk
and inv_date_sk = d_date_sk
and d_year =2000
group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
where case mean when 0 then 0 else stdev/mean end > 1)
select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
from inv inv1,inv inv2
where inv1.i_item_sk = inv2.i_item_sk
and inv1.w_warehouse_sk = inv2.w_warehouse_sk
and inv1.d_moy=2
and inv2.d_moy=2+1
and inv1.cov > 1.5
order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
,inv2.d_moy,inv2.mean, inv2.cov
;
-- end query 1 in stream 0 using template query39.tpl
================================================
FILE: sample-queries-tpcds/query4.sql
================================================
-- start query 1 in stream 0 using template query4.tpl and seed 1819994127
with year_total as (
select c_customer_id customer_id
,c_first_name customer_first_name
,c_last_name customer_last_name
,c_preferred_cust_flag customer_preferred_cust_flag
,c_birth_country customer_birth_country
,c_login customer_login
,c_email_address customer_email_address
,d_year dyear
,sum(((ss_ext_list_price-ss_ext_wholesale_cost-ss_ext_discount_amt)+ss_ext_sales_price)/2) year_total
,'s' sale_type
from customer
,store_sales
,date_dim
where c_customer_sk = ss_customer_sk
and ss_sold_date_sk = d_date_sk
group by c_customer_id
,c_first_name
,c_last_name
,c_preferred_cust_flag
,c_birth_country
,c_login
,c_email_address
,d_year
union all
select c_customer_id customer_id
,c_first_name customer_first_name
,c_last_name customer_last_name
,c_preferred_cust_flag customer_preferred_cust_flag
,c_birth_country customer_birth_country
,c_login customer_login
,c_email_address customer_email_address
,d_year dyear
,sum((((cs_ext_list_price-cs_ext_wholesale_cost-cs_ext_discount_amt)+cs_ext_sales_price)/2) ) year_total
,'c' sale_type
from customer
,catalog_sales
,date_dim
where c_customer_sk = cs_bill_customer_sk
and cs_sold_date_sk = d_date_sk
group by c_customer_id
,c_first_name
,c_last_name
,c_preferred_cust_flag
,c_birth_country
,c_login
,c_email_address
,d_year
union all
select c_customer_id customer_id
,c_first_name customer_first_name
,c_last_name customer_last_name
,c_preferred_cust_flag customer_preferred_cust_flag
,c_birth_country customer_birth_country
,c_login customer_login
,c_email_address customer_email_address
,d_year dyear
,sum((((ws_ext_list_price-ws_ext_wholesale_cost-ws_ext_discount_amt)+ws_ext_sales_price)/2) ) year_total
,'w' sale_type
from customer
,web_sales
,date_dim
where c_customer_sk = ws_bill_customer_sk
and ws_sold_date_sk = d_date_sk
group by c_customer_id
,c_first_name
,c_last_name
,c_preferred_cust_flag
,c_birth_country
,c_login
,c_email_address
,d_year
)
select
t_s_secyear.customer_id
,t_s_secyear.customer_first_name
,t_s_secyear.customer_last_name
,t_s_secyear.customer_birth_country
from year_total t_s_firstyear
,year_total t_s_secyear
,year_total t_c_firstyear
,year_total t_c_secyear
,year_total t_w_firstyear
,year_total t_w_secyear
where t_s_secyear.customer_id = t_s_firstyear.customer_id
and t_s_firstyear.customer_id = t_c_secyear.customer_id
and t_s_firstyear.customer_id = t_c_firstyear.customer_id
and t_s_firstyear.customer_id = t_w_firstyear.customer_id
and t_s_firstyear.customer_id = t_w_secyear.customer_id
and t_s_firstyear.sale_type = 's'
and t_c_firstyear.sale_type = 'c'
and t_w_firstyear.sale_type = 'w'
and t_s_secyear.sale_type = 's'
and t_c_secyear.sale_type = 'c'
and t_w_secyear.sale_type = 'w'
and t_s_firstyear.dyear = 1999
and t_s_secyear.dyear = 1999+1
and t_c_firstyear.dyear = 1999
and t_c_secyear.dyear = 1999+1
and t_w_firstyear.dyear = 1999
and t_w_secyear.dyear = 1999+1
and t_s_firstyear.year_total > 0
and t_c_firstyear.year_total > 0
and t_w_firstyear.year_total > 0
and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
> case when t_s_firstyear.year_total > 0 then t_s_secyear.year_total / t_s_firstyear.year_total else null end
and case when t_c_firstyear.year_total > 0 then t_c_secyear.year_total / t_c_firstyear.year_total else null end
> case when t_w_firstyear.year_total > 0 then t_w_secyear.year_total / t_w_firstyear.year_total else null end
order by t_s_secyear.customer_id
,t_s_secyear.customer_first_name
,t_s_secyear.customer_last_name
,t_s_secyear.customer_birth_country
limit 100;
-- end query 1 in stream 0 using template query4.tpl
================================================
FILE: sample-queries-tpcds/query40.sql
================================================
-- start query 1 in stream 0 using template query40.tpl and seed 1819994127
select
w_state
,i_item_id
,sum(case when (cast(d_date as date) < cast ('2000-03-18' as date))
then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
,sum(case when (cast(d_date as date) >= cast ('2000-03-18' as date))
then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
from
catalog_sales left outer join catalog_returns on
(cs_order_number = cr_order_number
and cs_item_sk = cr_item_sk)
,warehouse
,item
,date_dim
where
i_current_price between 0.99 and 1.49
and i_item_sk = cs_item_sk
and cs_warehouse_sk = w_warehouse_sk
and cs_sold_date_sk = d_date_sk
and d_date between (cast ('2000-03-18' as date) - 30 days)
and (cast ('2000-03-18' as date) + 30 days)
group by
w_state,i_item_id
order by w_state,i_item_id
limit 100;
-- end query 1 in stream 0 using template query40.tpl
================================================
FILE: sample-queries-tpcds/query41.sql
================================================
-- start query 1 in stream 0 using template query41.tpl and seed 1581015815
select distinct(i_product_name)
from item i1
where i_manufact_id between 970 and 970+40
and (select count(*) as item_cnt
from item
where (i_manufact = i1.i_manufact and
((i_category = 'Women' and
(i_color = 'frosted' or i_color = 'rose') and
(i_units = 'Lb' or i_units = 'Gross') and
(i_size = 'medium' or i_size = 'large')
) or
(i_category = 'Women' and
(i_color = 'chocolate' or i_color = 'black') and
(i_units = 'Box' or i_units = 'Dram') and
(i_size = 'economy' or i_size = 'petite')
) or
(i_category = 'Men' and
(i_color = 'slate' or i_color = 'magenta') and
(i_units = 'Carton' or i_units = 'Bundle') and
(i_size = 'N/A' or i_size = 'small')
) or
(i_category = 'Men' and
(i_color = 'cornflower' or i_color = 'firebrick') and
(i_units = 'Pound' or i_units = 'Oz') and
(i_size = 'medium' or i_size = 'large')
))) or
(i_manufact = i1.i_manufact and
((i_category = 'Women' and
(i_color = 'almond' or i_color = 'steel') and
(i_units = 'Tsp' or i_units = 'Case') and
(i_size = 'medium' or i_size = 'large')
) or
(i_category = 'Women' and
(i_color = 'purple' or i_color = 'aquamarine') and
(i_units = 'Bunch' or i_units = 'Gram') and
(i_size = 'economy' or i_size = 'petite')
) or
(i_category = 'Men' and
(i_color = 'lavender' or i_color = 'papaya') and
(i_units = 'Pallet' or i_units = 'Cup') and
(i_size = 'N/A' or i_size = 'small')
) or
(i_category = 'Men' and
(i_color = 'maroon' or i_color = 'cyan') and
(i_units = 'Each' or i_units = 'N/A') and
(i_size = 'medium' or i_size = 'large')
)))) > 0
order by i_product_name
limit 100;
-- end query 1 in stream 0 using template query41.tpl
================================================
FILE: sample-queries-tpcds/query42.sql
================================================
-- start query 1 in stream 0 using template query42.tpl and seed 1819994127
select dt.d_year
,item.i_category_id
,item.i_category
,sum(ss_ext_sales_price)
from date_dim dt
,store_sales
,item
where dt.d_date_sk = store_sales.ss_sold_date_sk
and store_sales.ss_item_sk = item.i_item_sk
and item.i_manager_id = 1
and dt.d_moy=12
and dt.d_year=1998
group by dt.d_year
,item.i_category_id
,item.i_category
order by sum(ss_ext_sales_price) desc,dt.d_year
,item.i_category_id
,item.i_category
limit 100 ;
-- end query 1 in stream 0 using template query42.tpl
================================================
FILE: sample-queries-tpcds/query43.sql
================================================
-- start query 1 in stream 0 using template query43.tpl and seed 1819994127
select s_store_name, s_store_id,
sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales,
sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
from date_dim, store_sales, store
where d_date_sk = ss_sold_date_sk and
s_store_sk = ss_store_sk and
s_gmt_offset = -6 and
d_year = 2001
group by s_store_name, s_store_id
order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
limit 100;
-- end query 1 in stream 0 using template query43.tpl
================================================
FILE: sample-queries-tpcds/query44.sql
================================================
-- start query 1 in stream 0 using template query44.tpl and seed 1819994127
select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing
from(select *
from (select item_sk,rank() over (order by rank_col asc) rnk
from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
from store_sales ss1
where ss_store_sk = 366
group by ss_item_sk
having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
from store_sales
where ss_store_sk = 366
and ss_cdemo_sk is null
group by ss_store_sk))V1)V11
where rnk < 11) asceding,
(select *
from (select item_sk,rank() over (order by rank_col desc) rnk
from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col
from store_sales ss1
where ss_store_sk = 366
group by ss_item_sk
having avg(ss_net_profit) > 0.9*(select avg(ss_net_profit) rank_col
from store_sales
where ss_store_sk = 366
and ss_cdemo_sk is null
group by ss_store_sk))V2)V21
where rnk < 11) descending,
item i1,
item i2
where asceding.rnk = descending.rnk
and i1.i_item_sk=asceding.item_sk
and i2.i_item_sk=descending.item_sk
order by asceding.rnk
limit 100;
-- end query 1 in stream 0 using template query44.tpl
================================================
FILE: sample-queries-tpcds/query45.sql
================================================
-- start query 1 in stream 0 using template query45.tpl and seed 2031708268
select ca_zip, ca_county, sum(ws_sales_price)
from web_sales, customer, customer_address, date_dim, item
where ws_bill_customer_sk = c_customer_sk
and c_current_addr_sk = ca_address_sk
and ws_item_sk = i_item_sk
and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792')
or
i_item_id in (select i_item_id
from item
where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
)
)
and ws_sold_date_sk = d_date_sk
and d_qoy = 1 and d_year = 1998
group by ca_zip, ca_county
order by ca_zip, ca_county
limit 100;
-- end query 1 in stream 0 using template query45.tpl
================================================
FILE: sample-queries-tpcds/query46.sql
================================================
-- start query 1 in stream 0 using template query46.tpl and seed 803547492
select c_last_name
,c_first_name
,ca_city
,bought_city
,ss_ticket_number
,amt,profit
from
(select ss_ticket_number
,ss_customer_sk
,ca_city bought_city
,sum(ss_coupon_amt) amt
,sum(ss_net_profit) profit
from store_sales,date_dim,store,household_demographics,customer_address
where store_sales.ss_sold_date_sk = date_dim.d_date_sk
and store_sales.ss_store_sk = store.s_store_sk
and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
and store_sales.ss_addr_sk = customer_address.ca_address_sk
and (household_demographics.hd_dep_count = 0 or
household_demographics.hd_vehicle_count= 1)
and date_dim.d_dow in (6,0)
and date_dim.d_year in (2000,2000+1,2000+2)
and store.s_city in ('Five Forks','Oakland','Fairview','Winchester','Farmington')
group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
where ss_customer_sk = c_customer_sk
and customer.c_current_addr_sk = current_addr.ca_address_sk
and current_addr.ca_city <> bought_city
order by c_last_name
,c_first_name
,ca_city
,bought_city
,ss_ticket_number
limit 100;
-- end query 1 in stream 0 using template query46.tpl
================================================
FILE: sample-queries-tpcds/query47.sql
================================================
-- start query 1 in stream 0 using template query47.tpl and seed 2031708268
with v1 as(
select i_category, i_brand,
s_store_name, s_company_name,
d_year, d_moy,
sum(ss_sales_price) sum_sales,
avg(sum(ss_sales_price)) over
(partition by i_category, i_brand,
s_store_name, s_company_name, d_year)
avg_monthly_sales,
rank() over
(partition by i_category, i_brand,
s_store_name, s_company_name
order by d_year, d_moy) rn
from item, store_sales, date_dim, store
where ss_item_sk = i_item_sk and
ss_sold_date_sk = d_date_sk and
ss_store_sk = s_store_sk and
(
d_year = 1999 or
( d_year = 1999-1 and d_moy =12) or
( d_year = 1999+1 and d_moy =1)
)
group by i_category, i_brand,
s_store_name, s_company_name,
d_year, d_moy),
v2 as(
select v1.s_store_name
,v1.d_year, v1.d_moy
,v1.avg_monthly_sales
,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
from v1, v1 v1_lag, v1 v1_lead
where v1.i_category = v1_lag.i_category and
v1.i_category = v1_lead.i_category and
v1.i_brand = v1_lag.i_brand and
v1.i_brand = v1_lead.i_brand and
v1.s_store_name = v1_lag.s_store_name and
v1.s_store_name = v1_lead.s_store_name and
v1.s_company_name = v1_lag.s_company_name and
v1.s_company_name = v1_lead.s_company_name and
v1.rn = v1_lag.rn + 1 and
v1.rn = v1_lead.rn - 1)
select *
from v2
where d_year = 1999 and
avg_monthly_sales > 0 and
case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
order by sum_sales - avg_monthly_sales, sum_sales
limit 100;
-- end query 1 in stream 0 using template query47.tpl
================================================
FILE: sample-queries-tpcds/query48.sql
================================================
-- start query 1 in stream 0 using template query48.tpl and seed 622697896
select sum (ss_quantity)
from store_sales, store, customer_demographics, customer_address, date_dim
where s_store_sk = ss_store_sk
and ss_sold_date_sk = d_date_sk and d_year = 1998
and
(
(
cd_demo_sk = ss_cdemo_sk
and
cd_marital_status = 'M'
and
cd_education_status = 'Unknown'
and
ss_sales_price between 100.00 and 150.00
)
or
(
cd_demo_sk = ss_cdemo_sk
and
cd_marital_status = 'W'
and
cd_education_status = 'College'
and
ss_sales_price between 50.00 and 100.00
)
or
(
cd_demo_sk = ss_cdemo_sk
and
cd_marital_status = 'D'
and
cd_education_status = 'Primary'
and
ss_sales_price between 150.00 and 200.00
)
)
and
(
(
ss_addr_sk = ca_address_sk
and
ca_country = 'United States'
and
ca_state in ('MI', 'GA', 'NH')
and ss_net_profit between 0 and 2000
)
or
(ss_addr_sk = ca_address_sk
and
ca_country = 'United States'
and
ca_state in ('TX', 'KY', 'SD')
and ss_net_profit between 150 and 3000
)
or
(ss_addr_sk = ca_address_sk
and
ca_country = 'United States'
and
ca_state in ('NY', 'OH', 'FL')
and ss_net_profit between 50 and 25000
)
)
;
-- end query 1 in stream 0 using template query48.tpl
================================================
FILE: sample-queries-tpcds/query49.sql
================================================
-- start query 1 in stream 0 using template query49.tpl and seed 1819994127
select channel, item, return_ratio, return_rank, currency_rank from
(select
'web' as channel
,web.item as item
,web.return_ratio as return_ratio
,web.return_rank as return_rank
,web.currency_rank as currency_rank
from (
select
item
,return_ratio
,currency_ratio
,rank() over (order by return_ratio) as return_rank
,rank() over (order by currency_ratio) as currency_rank
from
( select ws.ws_item_sk as item
,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/
cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio
,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/
cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio
from
web_sales ws left outer join web_returns wr
on (ws.ws_order_number = wr.wr_order_number and
ws.ws_item_sk = wr.wr_item_sk)
,date_dim
where
wr.wr_return_amt > 10000
and ws.ws_net_profit > 1
and ws.ws_net_paid > 0
and ws.ws_quantity > 0
and ws_sold_date_sk = d_date_sk
and d_year = 2000
and d_moy = 12
group by ws.ws_item_sk
) in_web
) web
where
(
web.return_rank <= 10
or
web.currency_rank <= 10
)
union
select
'catalog' as channel
,catalog.item as item
,catalog.return_ratio as return_ratio
,catalog.return_rank as return_rank
,catalog.currency_rank as currency_rank
from (
select
item
,return_ratio
,currency_ratio
,rank() over (order by return_ratio) as return_rank
,rank() over (order by currency_ratio) as currency_rank
from
( select
cs.cs_item_sk as item
,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/
cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio
,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/
cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio
from
catalog_sales cs left outer join catalog_returns cr
on (cs.cs_order_number = cr.cr_order_number and
cs.cs_item_sk = cr.cr_item_sk)
,date_dim
where
cr.cr_return_amount > 10000
and cs.cs_net_profit > 1
and cs.cs_net_paid > 0
and cs.cs_quantity > 0
and cs_sold_date_sk = d_date_sk
and d_year = 2000
and d_moy = 12
group by cs.cs_item_sk
) in_cat
) catalog
where
(
catalog.return_rank <= 10
or
catalog.currency_rank <=10
)
union
select
'store' as channel
,store.item as item
,store.return_ratio as return_ratio
,store.return_rank as return_rank
,store.currency_rank as currency_rank
from (
select
item
,return_ratio
,currency_ratio
,rank() over (order by return_ratio) as return_rank
,rank() over (order by currency_ratio) as currency_rank
from
( select sts.ss_item_sk as item
,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio
,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio
from
store_sales sts left outer join store_returns sr
on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
,date_dim
where
sr.sr_return_amt > 10000
and sts.ss_net_profit > 1
and sts.ss_net_paid > 0
and sts.ss_quantity > 0
and ss_sold_date_sk = d_date_sk
and d_year = 2000
and d_moy = 12
group by sts.ss_item_sk
) in_store
) store
where (
store.return_rank <= 10
or
store.currency_rank <= 10
)
) y
order by 1,4,5,2
limit 100;
-- end query 1 in stream 0 using template query49.tpl
================================================
FILE: sample-queries-tpcds/query5.sql
================================================
-- start query 1 in stream 0 using template query5.tpl and seed 1819994127
with ssr as
(select s_store_id,
sum(sales_price) as sales,
sum(profit) as profit,
sum(return_amt) as returns,
sum(net_loss) as profit_loss
from
( select ss_store_sk as store_sk,
ss_sold_date_sk as date_sk,
ss_ext_sales_price as sales_price,
ss_net_profit as profit,
cast(0 as decimal(7,2)) as return_amt,
cast(0 as decimal(7,2)) as net_loss
from store_sales
union all
select sr_store_sk as store_sk,
sr_returned_date_sk as date_sk,
cast(0 as decimal(7,2)) as sales_price,
cast(0 as decimal(7,2)) as profit,
sr_return_amt as return_amt,
sr_net_loss as net_loss
from store_returns
) salesreturns,
date_dim,
store
where date_sk = d_date_sk
and d_date between cast('2000-08-19' as date)
and (cast('2000-08-19' as date) + 14 days)
and store_sk = s_store_sk
group by s_store_id)
,
csr as
(select cp_catalog_page_id,
sum(sales_price) as sales,
sum(profit) as profit,
sum(return_amt) as returns,
sum(net_loss) as profit_loss
from
( select cs_catalog_page_sk as page_sk,
cs_sold_date_sk as date_sk,
cs_ext_sales_price as sales_price,
cs_net_profit as profit,
cast(0 as decimal(7,2)) as return_amt,
cast(0 as decimal(7,2)) as net_loss
from catalog_sales
union all
select cr_catalog_page_sk as page_sk,
cr_returned_date_sk as date_sk,
cast(0 as decimal(7,2)) as sales_price,
cast(0 as decimal(7,2)) as profit,
cr_return_amount as return_amt,
cr_net_loss as net_loss
from catalog_returns
) salesreturns,
date_dim,
catalog_page
where date_sk = d_date_sk
and d_date between cast('2000-08-19' as date)
and (cast('2000-08-19' as date) + 14 days)
and page_sk = cp_catalog_page_sk
group by cp_catalog_page_id)
,
wsr as
(select web_site_id,
sum(sales_price) as sales,
sum(profit) as profit,
sum(return_amt) as returns,
sum(net_loss) as profit_loss
from
( select ws_web_site_sk as wsr_web_site_sk,
ws_sold_date_sk as date_sk,
ws_ext_sales_price as sales_price,
ws_net_profit as profit,
cast(0 as decimal(7,2)) as return_amt,
cast(0 as decimal(7,2)) as net_loss
from web_sales
union all
select ws_web_site_sk as wsr_web_site_sk,
wr_returned_date_sk as date_sk,
cast(0 as decimal(7,2)) as sales_price,
cast(0 as decimal(7,2)) as profit,
wr_return_amt as return_amt,
wr_net_loss as net_loss
from web_returns left outer join web_sales on
( wr_item_sk = ws_item_sk
and wr_order_number = ws_order_number)
) salesreturns,
date_dim,
web_site
where date_sk = d_date_sk
and d_date between cast('2000-08-19' as date)
and (cast('2000-08-19' as date) + 14 days)
and wsr_web_site_sk = web_site_sk
group by web_site_id)
select channel
, id
, sum(sales) as sales
, sum(returns) as returns
, sum(profit) as profit
from
(select 'store channel' as channel
, 'store' || s_store_id as id
, sales
, returns
, (profit - profit_loss) as profit
from ssr
union all
select 'catalog channel' as channel
, 'catalog_page' || cp_catalog_page_id as id
, sales
, returns
, (profit - profit_loss) as profit
from csr
union all
select 'web channel' as channel
, 'web_site' || web_site_id as id
, sales
, returns
, (profit - profit_loss) as profit
from wsr
) x
group by rollup (channel, id)
order by channel
,id
limit 100;
-- end query 1 in stream 0 using template query5.tpl
================================================
FILE: sample-queries-tpcds/query50.sql
================================================
-- start query 1 in stream 0 using template query50.tpl and seed 1819994127
select
s_store_name
,s_company_id
,s_street_number
,s_street_name
,s_street_type
,s_suite_number
,s_city
,s_county
,s_state
,s_zip
,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end) as `30 days`
,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and
(sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end ) as `31-60 days`
,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and
(sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end) as `61-90 days`
,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
(sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end) as `91-120 days`
,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 120) then 1 else 0 end) as `>120 days`
from
store_sales
,store_returns
,store
,date_dim d1
,date_dim d2
where
d2.d_year = 1998
and d2.d_moy = 9
and ss_ticket_number = sr_ticket_number
and ss_item_sk = sr_item_sk
and ss_sold_date_sk = d1.d_date_sk
and sr_returned_date_sk = d2.d_date_sk
and ss_customer_sk = sr_customer_sk
and ss_store_sk = s_store_sk
group by
s_store_name
,s_company_id
,s_street_number
,s_street_name
,s_street_type
,s_suite_number
,s_city
,s_county
,s_state
,s_zip
order by s_store_name
,s_company_id
,s_street_number
,s_street_name
,s_street_type
,s_suite_number
,s_city
,s_county
,s_state
,s_zip
limit 100;
-- end query 1 in stream 0 using template query50.tpl
================================================
FILE: sample-queries-tpcds/query51.sql
================================================
-- start query 1 in stream 0 using template query51.tpl and seed 1819994127
WITH web_v1 as (
select
ws_item_sk item_sk, d_date,
sum(sum(ws_sales_price))
over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
from web_sales
,date_dim
where ws_sold_date_sk=d_date_sk
and d_month_seq between 1214 and 1214+11
and ws_item_sk is not NULL
group by ws_item_sk, d_date),
store_v1 as (
select
ss_item_sk item_sk, d_date,
sum(sum(ss_sales_price))
over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
from store_sales
,date_dim
where ss_sold_date_sk=d_date_sk
and d_month_seq between 1214 and 1214+11
and ss_item_sk is not NULL
group by ss_item_sk, d_date)
select *
from (select item_sk
,d_date
,web_sales
,store_sales
,max(web_sales)
over (partition by item_sk order by d_date rows between unbounded preceding and current row) web_cumulative
,max(store_sales)
over (partition by item_sk order by d_date rows between unbounded preceding and current row) store_cumulative
from (select case when web.item_sk is not null then web.item_sk else store.item_sk end item_sk
,case when web.d_date is not null then web.d_date else store.d_date end d_date
,web.cume_sales web_sales
,store.cume_sales store_sales
from web_v1 web full outer join store_v1 store on (web.item_sk = store.item_sk
and web.d_date = store.d_date)
)x )y
where web_cumulative > store_cumulative
order by item_sk
,d_date
limit 100;
-- end query 1 in stream 0 using template query51.tpl
================================================
FILE: sample-queries-tpcds/query52.sql
================================================
-- start query 1 in stream 0 using template query52.tpl and seed 1819994127
select dt.d_year
,item.i_brand_id brand_id
,item.i_brand brand
,sum(ss_ext_sales_price) ext_price
from date_dim dt
,store_sales
,item
where dt.d_date_sk = store_sales.ss_sold_date_sk
and store_sales.ss_item_sk = item.i_item_sk
and item.i_manager_id = 1
and dt.d_moy=12
and dt.d_year=2000
group by dt.d_year
,item.i_brand
,item.i_brand_id
order by dt.d_year
,ext_price desc
,brand_id
limit 100 ;
-- end query 1 in stream 0 using template query52.tpl
================================================
FILE: sample-queries-tpcds/query53.sql
================================================
-- start query 1 in stream 0 using template query53.tpl and seed 1819994127
select * from
(select i_manufact_id,
sum(ss_sales_price) sum_sales,
avg(sum(ss_sales_price)) over (partition by i_manufact_id) avg_quarterly_sales
from item, store_sales, date_dim, store
where ss_item_sk = i_item_sk and
ss_sold_date_sk = d_date_sk and
ss_store_sk = s_store_sk and
d_month_seq in (1212,1212+1,1212+2,1212+3,1212+4,1212+5,1212+6,1212+7,1212+8,1212+9,1212+10,1212+11) and
((i_category in ('Books','Children','Electronics') and
i_class in ('personal','portable','reference','self-help') and
i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
'exportiunivamalg #9','scholaramalgamalg #9'))
or(i_category in ('Women','Music','Men') and
i_class in ('accessories','classical','fragrances','pants') and
i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
'importoamalg #1')))
group by i_manufact_id, d_qoy ) tmp1
where case when avg_quarterly_sales > 0
then abs (sum_sales - avg_quarterly_sales)/ avg_quarterly_sales
else null end > 0.1
order by avg_quarterly_sales,
sum_sales,
i_manufact_id
limit 100;
-- end query 1 in stream 0 using template query53.tpl
================================================
FILE: sample-queries-tpcds/query54.sql
================================================
-- start query 1 in stream 0 using template query54.tpl and seed 1930872976
with my_customers as (
select distinct c_customer_sk
, c_current_addr_sk
from
( select cs_sold_date_sk sold_date_sk,
cs_bill_customer_sk customer_sk,
cs_item_sk item_sk
from catalog_sales
union all
select ws_sold_date_sk sold_date_sk,
ws_bill_customer_sk customer_sk,
ws_item_sk item_sk
from web_sales
) cs_or_ws_sales,
item,
date_dim,
customer
where sold_date_sk = d_date_sk
and item_sk = i_item_sk
and i_category = 'Books'
and i_class = 'business'
and c_customer_sk = cs_or_ws_sales.customer_sk
and d_moy = 2
and d_year = 2000
)
, my_revenue as (
select c_customer_sk,
sum(ss_ext_sales_price) as revenue
from my_customers,
store_sales,
customer_address,
store,
date_dim
where c_current_addr_sk = ca_address_sk
and ca_county = s_county
and ca_state = s_state
and ss_sold_date_sk = d_date_sk
and c_customer_sk = ss_customer_sk
and d_month_seq between (select distinct d_month_seq+1
from date_dim where d_year = 2000 and d_moy = 2)
and (select distinct d_month_seq+3
from date_dim where d_year = 2000 and d_moy = 2)
group by c_customer_sk
)
, segments as
(select cast((revenue/50) as int) as segment
from my_revenue
)
select segment, count(*) as num_customers, segment*50 as segment_base
from segments
group by segment
order by segment, num_customers
limit 100;
-- end query 1 in stream 0 using template query54.tpl
================================================
FILE: sample-queries-tpcds/query55.sql
================================================
-- start query 1 in stream 0 using template query55.tpl and seed 2031708268
select i_brand_id brand_id, i_brand brand,
sum(ss_ext_sales_price) ext_price
from date_dim, store_sales, item
where d_date_sk = ss_sold_date_sk
and ss_item_sk = i_item_sk
and i_manager_id=13
and d_moy=11
and d_year=1999
group by i_brand, i_brand_id
order by ext_price desc, i_brand_id
limit 100 ;
-- end query 1 in stream 0 using template query55.tpl
================================================
FILE: sample-queries-tpcds/query56.sql
================================================
-- start query 1 in stream 0 using template query56.tpl and seed 1951559352
with ss as (
select i_item_id,sum(ss_ext_sales_price) total_sales
from
store_sales,
date_dim,
customer_address,
item
where i_item_id in (select
i_item_id
from item
where i_color in ('chiffon','smoke','lace'))
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_year = 2001
and d_moy = 5
and ss_addr_sk = ca_address_sk
and ca_gmt_offset = -6
group by i_item_id),
cs as (
select i_item_id,sum(cs_ext_sales_price) total_sales
from
catalog_sales,
date_dim,
customer_address,
item
where
i_item_id in (select
i_item_id
from item
where i_color in ('chiffon','smoke','lace'))
and cs_item_sk = i_item_sk
and cs_sold_date_sk = d_date_sk
and d_year = 2001
and d_moy = 5
and cs_bill_addr_sk = ca_address_sk
and ca_gmt_offset = -6
group by i_item_id),
ws as (
select i_item_id,sum(ws_ext_sales_price) total_sales
from
web_sales,
date_dim,
customer_address,
item
where
i_item_id in (select
i_item_id
from item
where i_color in ('chiffon','smoke','lace'))
and ws_item_sk = i_item_sk
and ws_sold_date_sk = d_date_sk
and d_year = 2001
and d_moy = 5
and ws_bill_addr_sk = ca_address_sk
and ca_gmt_offset = -6
group by i_item_id)
select i_item_id ,sum(total_sales) total_sales
from (select * from ss
union all
select * from cs
union all
select * from ws) tmp1
group by i_item_id
order by total_sales,
i_item_id
limit 100;
-- end query 1 in stream 0 using template query56.tpl
================================================
FILE: sample-queries-tpcds/query57.sql
================================================
-- start query 1 in stream 0 using template query57.tpl and seed 2031708268
with v1 as(
select i_category, i_brand,
cc_name,
d_year, d_moy,
sum(cs_sales_price) sum_sales,
avg(sum(cs_sales_price)) over
(partition by i_category, i_brand,
cc_name, d_year)
avg_monthly_sales,
rank() over
(partition by i_category, i_brand,
cc_name
order by d_year, d_moy) rn
from item, catalog_sales, date_dim, call_center
where cs_item_sk = i_item_sk and
cs_sold_date_sk = d_date_sk and
cc_call_center_sk= cs_call_center_sk and
(
d_year = 1999 or
( d_year = 1999-1 and d_moy =12) or
( d_year = 1999+1 and d_moy =1)
)
group by i_category, i_brand,
cc_name , d_year, d_moy),
v2 as(
select v1.i_category, v1.i_brand
,v1.d_year, v1.d_moy
,v1.avg_monthly_sales
,v1.sum_sales, v1_lag.sum_sales psum, v1_lead.sum_sales nsum
from v1, v1 v1_lag, v1 v1_lead
where v1.i_category = v1_lag.i_category and
v1.i_category = v1_lead.i_category and
v1.i_brand = v1_lag.i_brand and
v1.i_brand = v1_lead.i_brand and
v1. cc_name = v1_lag. cc_name and
v1. cc_name = v1_lead. cc_name and
v1.rn = v1_lag.rn + 1 and
v1.rn = v1_lead.rn - 1)
select *
from v2
where d_year = 1999 and
avg_monthly_sales > 0 and
case when avg_monthly_sales > 0 then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
order by sum_sales - avg_monthly_sales, avg_monthly_sales
limit 100;
-- end query 1 in stream 0 using template query57.tpl
================================================
FILE: sample-queries-tpcds/query58.sql
================================================
-- start query 1 in stream 0 using template query58.tpl and seed 1819994127
with ss_items as
(select i_item_id item_id
,sum(ss_ext_sales_price) ss_item_rev
from store_sales
,item
,date_dim
where ss_item_sk = i_item_sk
and d_date in (select d_date
from date_dim
where d_week_seq = (select d_week_seq
from date_dim
where d_date = '1998-02-21'))
and ss_sold_date_sk = d_date_sk
group by i_item_id),
cs_items as
(select i_item_id item_id
,sum(cs_ext_sales_price) cs_item_rev
from catalog_sales
,item
,date_dim
where cs_item_sk = i_item_sk
and d_date in (select d_date
from date_dim
where d_week_seq = (select d_week_seq
from date_dim
where d_date = '1998-02-21'))
and cs_sold_date_sk = d_date_sk
group by i_item_id),
ws_items as
(select i_item_id item_id
,sum(ws_ext_sales_price) ws_item_rev
from web_sales
,item
,date_dim
where ws_item_sk = i_item_sk
and d_date in (select d_date
from date_dim
where d_week_seq =(select d_week_seq
from date_dim
where d_date = '1998-02-21'))
and ws_sold_date_sk = d_date_sk
group by i_item_id)
select ss_items.item_id
,ss_item_rev
,ss_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ss_dev
,cs_item_rev
,cs_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 cs_dev
,ws_item_rev
,ws_item_rev/((ss_item_rev+cs_item_rev+ws_item_rev)/3) * 100 ws_dev
,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
from ss_items,cs_items,ws_items
where ss_items.item_id=cs_items.item_id
and ss_items.item_id=ws_items.item_id
and ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
order by item_id
,ss_item_rev
limit 100;
-- end query 1 in stream 0 using template query58.tpl
================================================
FILE: sample-queries-tpcds/query59.sql
================================================
-- start query 1 in stream 0 using template query59.tpl and seed 1819994127
with wss as
(select d_week_seq,
ss_store_sk,
sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
sum(case when (d_day_name='Tuesday') then ss_sales_price else null end) tue_sales,
sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
from store_sales,date_dim
where d_date_sk = ss_sold_date_sk
group by d_week_seq,ss_store_sk
)
select s_store_name1,s_store_id1,d_week_seq1
,sun_sales1/sun_sales2,mon_sales1/mon_sales2
,tue_sales1/tue_sales2,wed_sales1/wed_sales2,thu_sales1/thu_sales2
,fri_sales1/fri_sales2,sat_sales1/sat_sales2
from
(select s_store_name s_store_name1,wss.d_week_seq d_week_seq1
,s_store_id s_store_id1,sun_sales sun_sales1
,mon_sales mon_sales1,tue_sales tue_sales1
,wed_sales wed_sales1,thu_sales thu_sales1
,fri_sales fri_sales1,sat_sales sat_sales1
from wss,store,date_dim d
where d.d_week_seq = wss.d_week_seq and
ss_store_sk = s_store_sk and
d_month_seq between 1205 and 1205 + 11) y,
(select s_store_name s_store_name2,wss.d_week_seq d_week_seq2
,s_store_id s_store_id2,sun_sales sun_sales2
,mon_sales mon_sales2,tue_sales tue_sales2
,wed_sales wed_sales2,thu_sales thu_sales2
,fri_sales fri_sales2,sat_sales sat_sales2
from wss,store,date_dim d
where d.d_week_seq = wss.d_week_seq and
ss_store_sk = s_store_sk and
d_month_seq between 1205+ 12 and 1205 + 23) x
where s_store_id1=s_store_id2
and d_week_seq1=d_week_seq2-52
order by s_store_name1,s_store_id1,d_week_seq1
limit 100;
-- end query 1 in stream 0 using template query59.tpl
================================================
FILE: sample-queries-tpcds/query6.sql
================================================
-- start query 1 in stream 0 using template query6.tpl and seed 1819994127
select a.ca_state state, count(*) cnt
from customer_address a
,customer c
,store_sales s
,date_dim d
,item i
where a.ca_address_sk = c.c_current_addr_sk
and c.c_customer_sk = s.ss_customer_sk
and s.ss_sold_date_sk = d.d_date_sk
and s.ss_item_sk = i.i_item_sk
and d.d_month_seq =
(select distinct (d_month_seq)
from date_dim
where d_year = 2002
and d_moy = 3 )
and i.i_current_price > 1.2 *
(select avg(j.i_current_price)
from item j
where j.i_category = i.i_category)
group by a.ca_state
having count(*) >= 10
order by cnt, a.ca_state
limit 100;
-- end query 1 in stream 0 using template query6.tpl
================================================
FILE: sample-queries-tpcds/query60.sql
================================================
-- start query 1 in stream 0 using template query60.tpl and seed 1930872976
with ss as (
select
i_item_id,sum(ss_ext_sales_price) total_sales
from
store_sales,
date_dim,
customer_address,
item
where
i_item_id in (select
i_item_id
from
item
where i_category in ('Children'))
and ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and d_year = 1998
and d_moy = 10
and ss_addr_sk = ca_address_sk
and ca_gmt_offset = -5
group by i_item_id),
cs as (
select
i_item_id,sum(cs_ext_sales_price) total_sales
from
catalog_sales,
date_dim,
customer_address,
item
where
i_item_id in (select
i_item_id
from
item
where i_category in ('Children'))
and cs_item_sk = i_item_sk
and cs_sold_date_sk = d_date_sk
and d_year = 1998
and d_moy = 10
and cs_bill_addr_sk = ca_address_sk
and ca_gmt_offset = -5
group by i_item_id),
ws as (
select
i_item_id,sum(ws_ext_sales_price) total_sales
from
web_sales,
date_dim,
customer_address,
item
where
i_item_id in (select
i_item_id
from
item
where i_category in ('Children'))
and ws_item_sk = i_item_sk
and ws_sold_date_sk = d_date_sk
and d_year = 1998
and d_moy = 10
and ws_bill_addr_sk = ca_address_sk
and ca_gmt_offset = -5
group by i_item_id)
select
i_item_id
,sum(total_sales) total_sales
from (select * from ss
union all
select * from cs
union all
select * from ws) tmp1
group by i_item_id
order by i_item_id
,total_sales
limit 100;
-- end query 1 in stream 0 using template query60.tpl
================================================
FILE: sample-queries-tpcds/query61.sql
================================================
-- start query 1 in stream 0 using template query61.tpl and seed 1930872976
select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100
from
(select sum(ss_ext_sales_price) promotions
from store_sales
,store
,promotion
,date_dim
,customer
,customer_address
,item
where ss_sold_date_sk = d_date_sk
and ss_store_sk = s_store_sk
and ss_promo_sk = p_promo_sk
and ss_customer_sk= c_customer_sk
and ca_address_sk = c_current_addr_sk
and ss_item_sk = i_item_sk
and ca_gmt_offset = -6
and i_category = 'Sports'
and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
and s_gmt_offset = -6
and d_year = 2001
and d_moy = 12) promotional_sales,
(select sum(ss_ext_sales_price) total
from store_sales
,store
,date_dim
,customer
,customer_address
,item
where ss_sold_date_sk = d_date_sk
and ss_store_sk = s_store_sk
and ss_customer_sk= c_customer_sk
and ca_address_sk = c_current_addr_sk
and ss_item_sk = i_item_sk
and ca_gmt_offset = -6
and i_category = 'Sports'
and s_gmt_offset = -6
and d_year = 2001
and d_moy = 12) all_sales
order by promotions, total
limit 100;
-- end query 1 in stream 0 using template query61.tpl
================================================
FILE: sample-queries-tpcds/query62.sql
================================================
-- start query 1 in stream 0 using template query62.tpl and seed 1819994127
select
substr(w_warehouse_name,1,20)
,sm_type
,web_name
,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as `30 days`
,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and
(ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end ) as `31-60 days`
,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and
(ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end) as `61-90 days`
,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and
(ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end) as `91-120 days`
,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 120) then 1 else 0 end) as `>120 days`
from
web_sales
,warehouse
,ship_mode
,web_site
,date_dim
where
d_month_seq between 1215 and 1215 + 11
and ws_ship_date_sk = d_date_sk
and ws_warehouse_sk = w_warehouse_sk
and ws_ship_mode_sk = sm_ship_mode_sk
and ws_web_site_sk = web_site_sk
group by
substr(w_warehouse_name,1,20)
,sm_type
,web_name
order by substr(w_warehouse_name,1,20)
,sm_type
,web_name
limit 100;
-- end query 1 in stream 0 using template query62.tpl
================================================
FILE: sample-queries-tpcds/query63.sql
================================================
-- start query 1 in stream 0 using template query63.tpl and seed 1819994127
select *
from (select i_manager_id
,sum(ss_sales_price) sum_sales
,avg(sum(ss_sales_price)) over (partition by i_manager_id) avg_monthly_sales
from item
,store_sales
,date_dim
,store
where ss_item_sk = i_item_sk
and ss_sold_date_sk = d_date_sk
and ss_store_sk = s_store_sk
and d_month_seq in (1211,1211+1,1211+2,1211+3,1211+4,1211+5,1211+6,1211+7,1211+8,1211+9,1211+10,1211+11)
and (( i_category in ('Books','Children','Electronics')
and i_class in ('personal','portable','reference','self-help')
and i_brand in ('scholaramalgamalg #14','scholaramalgamalg #7',
'exportiunivamalg #9','scholaramalgamalg #9'))
or( i_category in ('Women','Music','Men')
and i_class in ('accessories','classical','fragrances','pants')
and i_brand in ('amalgimporto #1','edu packscholar #1','exportiimporto #1',
'importoamalg #1')))
group by i_manager_id, d_moy) tmp1
where case when avg_monthly_sales > 0 then abs (sum_sales - avg_monthly_sales) / avg_monthly_sales else null end > 0.1
order by i_manager_id
,avg_monthly_sales
,sum_sales
limit 100;
-- end query 1 in stream 0 using template query63.tpl
================================================
FILE: sample-queries-tpcds/query64.sql
================================================
-- start query 1 in stream 0 using template query64.tpl and seed 1220860970
with cs_ui as
(select cs_item_sk
,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
from catalog_sales
,catalog_returns
where cs_item_sk = cr_item_sk
and cs_order_number = cr_order_number
group by cs_item_sk
having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)),
cross_sales as
(select i_product_name product_name
,i_item_sk item_sk
,s_store_name store_name
,s_zip store_zip
,ad1.ca_street_number b_street_number
,ad1.ca_street_name b_street_name
,ad1.ca_city b_city
,ad1.ca_zip b_zip
,ad2.ca_street_number c_street_number
,ad2.ca_street_name c_street_name
,ad2.ca_city c_city
,ad2.ca_zip c_zip
,d1.d_year as syear
,d2.d_year as fsyear
,d3.d_year s2year
,count(*) cnt
,sum(ss_wholesale_cost) s1
,sum(ss_list_price) s2
,sum(ss_coupon_amt) s3
FROM store_sales
,store_returns
,cs_ui
,date_dim d1
,date_dim d2
,date_dim d3
,store
,customer
,customer_demographics cd1
,customer_demographics cd2
,promotion
,household_demographics hd1
,household_demographics hd2
,customer_address ad1
,customer_address ad2
,income_band ib1
,income_band ib2
,item
WHERE ss_store_sk = s_store_sk AND
ss_sold_date_sk = d1.d_date_sk AND
ss_customer_sk = c_customer_sk AND
ss_cdemo_sk= cd1.cd_demo_sk AND
ss_hdemo_sk = hd1.hd_demo_sk AND
ss_addr_sk = ad1.ca_address_sk and
ss_item_sk = i_item_sk and
ss_item_sk = sr_item_sk and
ss_ticket_number = sr_ticket_number and
ss_item_sk = cs_ui.cs_item_sk and
c_current_cdemo_sk = cd2.cd_demo_sk AND
c_current_hdemo_sk = hd2.hd_demo_sk AND
c_current_addr_sk = ad2.ca_address_sk and
c_first_sales_date_sk = d2.d_date_sk and
c_first_shipto_date_sk = d3.d_date_sk and
ss_promo_sk = p_promo_sk and
hd1.hd_income_band_sk = ib1.ib_income_band_sk and
hd2.hd_income_band_sk = ib2.ib_income_band_sk and
cd1.cd_marital_status <> cd2.cd_marital_status and
i_color in ('azure','gainsboro','misty','blush','hot','lemon') and
i_current_price between 80 and 80 + 10 and
i_current_price between 80 + 1 and 80 + 15
group by i_product_name
,i_item_sk
,s_store_name
,s_zip
,ad1.ca_street_number
,ad1.ca_street_name
,ad1.ca_city
,ad1.ca_zip
,ad2.ca_street_number
,ad2.ca_street_name
,ad2.ca_city
,ad2.ca_zip
,d1.d_year
,d2.d_year
,d3.d_year
)
select cs1.product_name
,cs1.store_name
,cs1.store_zip
,cs1.b_street_number
,cs1.b_street_name
,cs1.b_city
,cs1.b_zip
,cs1.c_street_number
,cs1.c_street_name
,cs1.c_city
,cs1.c_zip
,cs1.syear
,cs1.cnt
,cs1.s1 as s11
,cs1.s2 as s21
,cs1.s3 as s31
,cs2.s1 as s12
,cs2.s2 as s22
,cs2.s3 as s32
,cs2.syear
,cs2.cnt
from cross_sales cs1,cross_sales cs2
where cs1.item_sk=cs2.item_sk and
cs1.syear = 1999 and
cs2.syear = 1999 + 1 and
cs2.cnt <= cs1.cnt and
cs1.store_name = cs2.store_name and
cs1.store_zip = cs2.store_zip
order by cs1.product_name
,cs1.store_name
,cs2.cnt
,cs1.s1
,cs2.s1;
-- end query 1 in stream 0 using template query64.tpl
================================================
FILE: sample-queries-tpcds/query65.sql
================================================
-- start query 1 in stream 0 using template query65.tpl and seed 1819994127
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 1186 and 1186+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 1186 and 1186+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 100;
-- end query 1 in stream 0 using template query65.tpl
================================================
FILE: sample-queries-tpcds/query66.sql
================================================
-- start query 1 in stream 0 using template query66.tpl and seed 2042478054
select
w_warehouse_name
,w_warehouse_sq_ft
,w_city
,w_county
,w_state
,w_country
,ship_carriers
,year
,sum(jan_sales) as jan_sales
,sum(feb_sales) as feb_sales
,sum(mar_sales) as mar_sales
,sum(apr_sales) as apr_sales
,sum(may_sales) as may_sales
,sum(jun_sales) as jun_sales
,sum(jul_sales) as jul_sales
,sum(aug_sales) as aug_sales
,sum(sep_sales) as sep_sales
,sum(oct_sales) as oct_sales
,sum(nov_sales) as nov_sales
,sum(dec_sales) as dec_sales
,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
,sum(jan_net) as jan_net
,sum(feb_net) as feb_net
,sum(mar_net) as mar_net
,sum(apr_net) as apr_net
,sum(may_net) as may_net
,sum(jun_net) as jun_net
,sum(jul_net) as jul_net
,sum(aug_net) as aug_net
,sum(sep_net) as sep_net
,sum(oct_net) as oct_net
,sum(nov_net) as nov_net
,sum(dec_net) as dec_net
from (
select
w_warehouse_name
,w_warehouse_sq_ft
,w_city
,w_county
,w_state
,w_country
,'MSC' || ',' || 'GERMA' as ship_carriers
,d_year as year
,sum(case when d_moy = 1
then ws_sales_price* ws_quantity else 0 end) as jan_sales
,sum(case when d_moy = 2
then ws_sales_price* ws_quantity else 0 end) as feb_sales
,sum(case when d_moy = 3
then ws_sales_price* ws_quantity else 0 end) as mar_sales
,sum(case when d_moy = 4
then ws_sales_price* ws_quantity else 0 end) as apr_sales
,sum(case when d_moy = 5
then ws_sales_price* ws_quantity else 0 end) as may_sales
,sum(case when d_moy = 6
then ws_sales_price* ws_quantity else 0 end) as jun_sales
,sum(case when d_moy = 7
then ws_sales_price* ws_quantity else 0 end) as jul_sales
,sum(case when d_moy = 8
then ws_sales_price* ws_quantity else 0 end) as aug_sales
,sum(case when d_moy = 9
then ws_sales_price* ws_quantity else 0 end) as sep_sales
,sum(case when d_moy = 10
then ws_sales_price* ws_quantity else 0 end) as oct_sales
,sum(case when d_moy = 11
then ws_sales_price* ws_quantity else 0 end) as nov_sales
,sum(case when d_moy = 12
then ws_sales_price* ws_quantity else 0 end) as dec_sales
,sum(case when d_moy = 1
then ws_net_paid_inc_ship_tax * ws_quantity else 0 end) as jan_net
,sum(case when d_moy = 2
then ws
gitextract_i96bxtes/ ├── .gitignore ├── README.md ├── ddl-tpcds/ │ ├── bin_partitioned/ │ │ ├── add_constraints.sql │ │ ├── analyze.sql │ │ ├── call_center.sql │ │ ├── catalog_page.sql │ │ ├── catalog_returns.sql │ │ ├── catalog_sales.sql │ │ ├── customer.sql │ │ ├── customer_address.sql │ │ ├── customer_demographics.sql │ │ ├── date_dim.sql │ │ ├── household_demographics.sql │ │ ├── income_band.sql │ │ ├── inventory.sql │ │ ├── item.sql │ │ ├── promotion.sql │ │ ├── reason.sql │ │ ├── ship_mode.sql │ │ ├── store.sql │ │ ├── store_returns.sql │ │ ├── store_sales.sql │ │ ├── time_dim.sql │ │ ├── warehouse.sql │ │ ├── web_page.sql │ │ ├── web_returns.sql │ │ ├── web_sales.sql │ │ └── web_site.sql │ └── text/ │ ├── alltables.sql │ └── analyze_everything.sql ├── ddl-tpch/ │ ├── bin_flat/ │ │ ├── alltables.sql │ │ ├── analyze.sql │ │ ├── customer.sql │ │ ├── lineitem.sql │ │ ├── nation.sql │ │ ├── orders.sql │ │ ├── part.sql │ │ ├── partsupp.sql │ │ ├── region.sql │ │ └── supplier.sql │ └── bin_partitioned/ │ ├── analyze.sql │ ├── customer.sql │ ├── lineitem.sql │ ├── nation.sql │ ├── orders.sql │ ├── part.sql │ ├── partsupp.sql │ ├── region.sql │ └── supplier.sql ├── runSuite.pl ├── sample-queries-tpcds/ │ ├── README.md │ ├── query1.sql │ ├── query10.sql │ ├── query11.sql │ ├── query12.sql │ ├── query13.sql │ ├── query14.sql │ ├── query15.sql │ ├── query16.sql │ ├── query17.sql │ ├── query18.sql │ ├── query19.sql │ ├── query2.sql │ ├── query20.sql │ ├── query21.sql │ ├── query22.sql │ ├── query23.sql │ ├── query24.sql │ ├── query25.sql │ ├── query26.sql │ ├── query27.sql │ ├── query28.sql │ ├── query29.sql │ ├── query3.sql │ ├── query30.sql │ ├── query31.sql │ ├── query32.sql │ ├── query33.sql │ ├── query34.sql │ ├── query35.sql │ ├── query36.sql │ ├── query37.sql │ ├── query38.sql │ ├── query39.sql │ ├── query4.sql │ ├── query40.sql │ ├── query41.sql │ ├── query42.sql │ ├── query43.sql │ ├── query44.sql │ ├── query45.sql │ ├── query46.sql │ ├── query47.sql │ ├── query48.sql │ ├── query49.sql │ ├── query5.sql │ ├── query50.sql │ ├── query51.sql │ ├── query52.sql │ ├── query53.sql │ ├── query54.sql │ ├── query55.sql │ ├── query56.sql │ ├── query57.sql │ ├── query58.sql │ ├── query59.sql │ ├── query6.sql │ ├── query60.sql │ ├── query61.sql │ ├── query62.sql │ ├── query63.sql │ ├── query64.sql │ ├── query65.sql │ ├── query66.sql │ ├── query67.sql │ ├── query68.sql │ ├── query69.sql │ ├── query7.sql │ ├── query70.sql │ ├── query71.sql │ ├── query72.sql │ ├── query73.sql │ ├── query74.sql │ ├── query75.sql │ ├── query76.sql │ ├── query77.sql │ ├── query78.sql │ ├── query79.sql │ ├── query8.sql │ ├── query80.sql │ ├── query81.sql │ ├── query82.sql │ ├── query83.sql │ ├── query84.sql │ ├── query85.sql │ ├── query86.sql │ ├── query87.sql │ ├── query88.sql │ ├── query89.sql │ ├── query9.sql │ ├── query90.sql │ ├── query91.sql │ ├── query92.sql │ ├── query93.sql │ ├── query94.sql │ ├── query95.sql │ ├── query96.sql │ ├── query97.sql │ ├── query98.sql │ └── query99.sql ├── sample-queries-tpch/ │ ├── README.md │ ├── testbench-withATS.settings │ ├── testbench.settings │ ├── tpch_query1.sql │ ├── tpch_query10.sql │ ├── tpch_query11.sql │ ├── tpch_query12.sql │ ├── tpch_query13.sql │ ├── tpch_query14.sql │ ├── tpch_query15.sql │ ├── tpch_query16.sql │ ├── tpch_query17.sql │ ├── tpch_query18.sql │ ├── tpch_query19.sql │ ├── tpch_query2.sql │ ├── tpch_query20.sql │ ├── tpch_query21.sql │ ├── tpch_query22.sql │ ├── tpch_query3.sql │ ├── tpch_query4.sql │ ├── tpch_query5.sql │ ├── tpch_query6.sql │ ├── tpch_query7.sql │ ├── tpch_query8.sql │ └── tpch_query9.sql ├── settings/ │ ├── init.sql │ ├── load-flat.sql │ └── load-partitioned.sql ├── spark-queries-tpcds/ │ ├── LICENSE │ ├── README.md │ ├── q1.sql │ ├── q10.sql │ ├── q11.sql │ ├── q12.sql │ ├── q13.sql │ ├── q14a.sql │ ├── q14b.sql │ ├── q15.sql │ ├── q16.sql │ ├── q17.sql │ ├── q18.sql │ ├── q19.sql │ ├── q2.sql │ ├── q20.sql │ ├── q21.sql │ ├── q22.sql │ ├── q23a.sql │ ├── q23b.sql │ ├── q24a.sql │ ├── q24b.sql │ ├── q25.sql │ ├── q26.sql │ ├── q27.sql │ ├── q28.sql │ ├── q29.sql │ ├── q3.sql │ ├── q30.sql │ ├── q31.sql │ ├── q32.sql │ ├── q33.sql │ ├── q34.sql │ ├── q35.sql │ ├── q36.sql │ ├── q37.sql │ ├── q38.sql │ ├── q39a.sql │ ├── q39b.sql │ ├── q4.sql │ ├── q40.sql │ ├── q41.sql │ ├── q42.sql │ ├── q43.sql │ ├── q44.sql │ ├── q45.sql │ ├── q46.sql │ ├── q47.sql │ ├── q48.sql │ ├── q49.sql │ ├── q5.sql │ ├── q50.sql │ ├── q51.sql │ ├── q52.sql │ ├── q53.sql │ ├── q54.sql │ ├── q55.sql │ ├── q56.sql │ ├── q57.sql │ ├── q58.sql │ ├── q59.sql │ ├── q6.sql │ ├── q60.sql │ ├── q61.sql │ ├── q62.sql │ ├── q63.sql │ ├── q64.sql │ ├── q65.sql │ ├── q66.sql │ ├── q67.sql │ ├── q68.sql │ ├── q69.sql │ ├── q7.sql │ ├── q70.sql │ ├── q71.sql │ ├── q72.sql │ ├── q73.sql │ ├── q74.sql │ ├── q75.sql │ ├── q76.sql │ ├── q77.sql │ ├── q78.sql │ ├── q79.sql │ ├── q8.sql │ ├── q80.sql │ ├── q81.sql │ ├── q82.sql │ ├── q83.sql │ ├── q84.sql │ ├── q85.sql │ ├── q86.sql │ ├── q87.sql │ ├── q88.sql │ ├── q89.sql │ ├── q9.sql │ ├── q90.sql │ ├── q91.sql │ ├── q92.sql │ ├── q93.sql │ ├── q94.sql │ ├── q95.sql │ ├── q96.sql │ ├── q97.sql │ ├── q98.sql │ └── q99.sql ├── tpcds-build.sh ├── tpcds-gen/ │ ├── Makefile │ ├── README.md │ ├── patches/ │ │ ├── Darwin/ │ │ │ └── macosx.patch │ │ └── all/ │ │ ├── tpcds-buffered.patch │ │ ├── tpcds-strcpy.patch │ │ └── tpcds_misspelled_header_guard.patch │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── org/ │ └── notmysock/ │ └── tpcds/ │ └── GenTable.java ├── tpcds-setup.sh ├── tpch-build.sh ├── tpch-gen/ │ ├── Makefile │ ├── README.md │ ├── ddl/ │ │ ├── orc.sql │ │ └── text.sql │ ├── patches/ │ │ └── Darwin/ │ │ └── macosx.patch │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── org/ │ └── notmysock/ │ └── tpch/ │ └── GenTable.java └── tpch-setup.sh
SYMBOL INDEX (95 symbols across 26 files)
FILE: ddl-tpcds/bin_partitioned/catalog_returns.sql
type catalog_returns (line 6) | create table catalog_returns
FILE: ddl-tpcds/bin_partitioned/catalog_sales.sql
type catalog_sales (line 6) | create table catalog_sales
FILE: ddl-tpcds/bin_partitioned/store_returns.sql
type store_returns (line 6) | create table store_returns
FILE: ddl-tpcds/bin_partitioned/store_sales.sql
type store_sales (line 6) | create table store_sales
FILE: ddl-tpcds/bin_partitioned/web_returns.sql
type web_returns (line 6) | create table web_returns
FILE: ddl-tpcds/bin_partitioned/web_sales.sql
type web_sales (line 6) | create table web_sales
FILE: ddl-tpcds/text/alltables.sql
type store_sales (line 6) | create external table if not exists store_sales(
type store_returns (line 38) | create external table if not exists store_returns(
type catalog_sales (line 67) | create external table if not exists catalog_sales(
type catalog_returns (line 110) | create external table if not exists catalog_returns(
type web_sales (line 146) | create external table if not exists web_sales(
type web_returns (line 189) | create external table if not exists web_returns(
type inventory (line 222) | create external table if not exists inventory(
type store (line 234) | create external table if not exists store(
type call_center (line 272) | create external table if not exists call_center(
type catalog_page (line 312) | create external table if not exists catalog_page(
type web_site (line 330) | create external table if not exists web_site(
type web_page (line 365) | create external table if not exists web_page(
type warehouse (line 388) | create external table if not exists warehouse(
type customer (line 411) | create external table if not exists customer(
type customer_address (line 438) | create external table if not exists customer_address(
type customer_demographics (line 460) | create external table if not exists customer_demographics(
type date_dim (line 478) | create external table if not exists date_dim(
type household_demographics (line 515) | create external table if not exists household_demographics(
type item (line 529) | create external table if not exists item(
type income_band (line 560) | create external table if not exists income_band(
type promotion (line 571) | create external table if not exists promotion(
type reason (line 599) | create external table if not exists reason(
type ship_mode (line 611) | create external table if not exists ship_mode(
type time_dim (line 626) | create external table if not exists time_dim(
FILE: ddl-tpch/bin_flat/alltables.sql
type lineitem (line 5) | create external table lineitem
type part (line 26) | create external table part (P_PARTKEY BIGINT,
type supplier (line 39) | create external table supplier (S_SUPPKEY BIGINT,
type partsupp (line 50) | create external table partsupp (PS_PARTKEY BIGINT,
type nation (line 59) | create external table nation (N_NATIONKEY BIGINT,
type region (line 67) | create external table region (R_REGIONKEY BIGINT,
type customer (line 74) | create external table customer (C_CUSTKEY BIGINT,
type orders (line 86) | create external table orders (O_ORDERKEY BIGINT,
FILE: ddl-tpch/bin_partitioned/customer.sql
type customer (line 6) | create table customer
FILE: ddl-tpch/bin_partitioned/lineitem.sql
type lineitem (line 6) | create table lineitem
FILE: ddl-tpch/bin_partitioned/nation.sql
type nation (line 6) | create table nation
FILE: ddl-tpch/bin_partitioned/orders.sql
type orders (line 6) | create table orders (O_ORDERKEY BIGINT,
FILE: ddl-tpch/bin_partitioned/part.sql
type part (line 6) | create table part
FILE: ddl-tpch/bin_partitioned/partsupp.sql
type partsupp (line 6) | create table partsupp
FILE: ddl-tpch/bin_partitioned/region.sql
type region (line 6) | create table region
FILE: ddl-tpch/bin_partitioned/supplier.sql
type supplier (line 6) | create table supplier
FILE: sample-queries-tpch/tpch_query11.sql
type q11_part_tmp_cached (line 4) | create view q11_part_tmp_cached as
type q11_sum_tmp_cached (line 18) | create view q11_sum_tmp_cached as
FILE: sample-queries-tpch/tpch_query15.sql
type revenue_cached (line 4) | create view revenue_cached as
type max_revenue_cached (line 15) | create view max_revenue_cached as
FILE: sample-queries-tpch/tpch_query18.sql
type q18_tmp_cached (line 4) | create view q18_tmp_cached as
type q18_large_volume_customer_cached (line 15) | create table q18_large_volume_customer_cached as
FILE: sample-queries-tpch/tpch_query2.sql
type q2_min_ps_supplycost (line 2) | create view q2_min_ps_supplycost as
FILE: sample-queries-tpch/tpch_query21.sql
type l3 (line 3) | create temporary table l3 stored as orc as
FILE: sample-queries-tpch/tpch_query22.sql
type q22_customer_tmp_cached (line 5) | create view if not exists q22_customer_tmp_cached as
type q22_customer_tmp1_cached (line 21) | create view if not exists q22_customer_tmp1_cached as
type q22_orders_tmp_cached (line 29) | create view if not exists q22_orders_tmp_cached as
FILE: tpcds-gen/src/main/java/org/notmysock/tpcds/GenTable.java
class GenTable (line 25) | public class GenTable extends Configured implements Tool {
method main (line 26) | public static void main(String[] args) throws Exception {
method run (line 32) | @Override
method copyJar (line 113) | public Path copyJar(File jar) throws Exception {
method genInput (line 132) | public Path genInput(String table, int scale, int parallel) throws Exc...
method readToString (line 149) | static String readToString(InputStream in) throws IOException {
class DSDGen (line 163) | static final class DSDGen extends Mapper<LongWritable,Text, Text, Text> {
method setup (line 165) | protected void setup(Context context) throws IOException {
method cleanup (line 168) | protected void cleanup(Context context) throws IOException, Interrup...
method map (line 171) | protected void map(LongWritable offset, Text command, Mapper.Context...
FILE: tpch-gen/ddl/orc.sql
type lineitem (line 4) | create table if not exists lineitem
type part (line 24) | create table if not exists part (P_PARTKEY INT,
type supplier (line 36) | create table if not exists supplier (S_SUPPKEY BIGINT,
type partsupp (line 46) | create table if not exists partsupp (PS_PARTKEY BIGINT,
type nation (line 54) | create table if not exists nation (N_NATIONKEY INT,
type region (line 61) | create table if not exists region (R_REGIONKEY INT,
type customer (line 67) | create table if not exists customer (C_CUSTKEY BIGINT,
type orders (line 78) | create table if not exists orders (O_ORDERKEY BIGINT,
FILE: tpch-gen/ddl/text.sql
type lineitem (line 1) | create external table lineitem
type part (line 21) | create external table part (P_PARTKEY BIGINT,
type supplier (line 33) | create external table supplier (S_SUPPKEY BIGINT,
type partsupp (line 43) | create external table partsupp (PS_PARTKEY BIGINT,
type nation (line 51) | create external table nation (N_NATIONKEY INT,
type region (line 58) | create external table region (R_REGIONKEY INT,
type customer (line 64) | create external table customer (C_CUSTKEY BIGINT,
type orders (line 75) | create external table orders (O_ORDERKEY BIGINT,
FILE: tpch-gen/src/main/java/org/notmysock/tpch/GenTable.java
class GenTable (line 26) | public class GenTable extends Configured implements Tool {
type TableMappings (line 28) | private static enum TableMappings {
method TableMappings (line 47) | TableMappings(String option) {
method main (line 52) | public static void main(String[] args) throws Exception {
method run (line 58) | @Override
method copyJar (line 148) | public Path copyJar(File jar) throws Exception {
method genInput (line 167) | public Path genInput(String table, int scale, int parallel) throws Exc...
method readToString (line 184) | static String readToString(InputStream in) throws IOException {
class dbgen (line 198) | static final class dbgen extends Mapper<LongWritable,Text, Text, Text> {
method setup (line 200) | protected void setup(Context context) throws IOException {
method cleanup (line 203) | protected void cleanup(Context context) throws IOException, Interrup...
method map (line 206) | protected void map(LongWritable offset, Text command, Mapper.Context...
Condensed preview — 302 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (519K chars).
[
{
"path": ".gitignore",
"chars": 55,
"preview": "target/\ntpcds_kit.zip\ntpch_kit.zip\n*.sql.log\nderby.log\n"
},
{
"path": "README.md",
"chars": 4550,
"preview": "hive-testbench\n==============\n\nA testbench for experimenting with Apache Hive at any data scale.\n\nOverview\n========\n\nThe"
},
{
"path": "ddl-tpcds/bin_partitioned/add_constraints.sql",
"chars": 20349,
"preview": "-- set hivevar:DB=tpcds_bin_partitioned_orc_10000\n\nalter table customer_address add constraint ${DB}_pk_ca primary key ("
},
{
"path": "ddl-tpcds/bin_partitioned/analyze.sql",
"chars": 1383,
"preview": "analyze table call_center compute statistics for columns;\nanalyze table catalog_page compute statistics for columns;\nana"
},
{
"path": "ddl-tpcds/bin_partitioned/call_center.sql",
"chars": 167,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists call_center;\n\ncreate table call_center\nstored as $"
},
{
"path": "ddl-tpcds/bin_partitioned/catalog_page.sql",
"chars": 170,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists catalog_page;\n\ncreate table catalog_page\nstored as"
},
{
"path": "ddl-tpcds/bin_partitioned/catalog_returns.sql",
"chars": 2981,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists catalog_returns;\n\ncreate table catalog_returns\n(\n "
},
{
"path": "ddl-tpcds/bin_partitioned/catalog_sales.sql",
"chars": 3497,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists catalog_sales;\n\ncreate table catalog_sales\n(\n "
},
{
"path": "ddl-tpcds/bin_partitioned/customer.sql",
"chars": 184,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists customer;\n\ncreate table customer\nstored as ${FILE}"
},
{
"path": "ddl-tpcds/bin_partitioned/customer_address.sql",
"chars": 209,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists customer_address;\n\ncreate table customer_address\ns"
},
{
"path": "ddl-tpcds/bin_partitioned/customer_demographics.sql",
"chars": 197,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists customer_demographics;\n\ncreate table customer_demo"
},
{
"path": "ddl-tpcds/bin_partitioned/date_dim.sql",
"chars": 158,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists date_dim;\n\ncreate table date_dim\nstored as ${FILE}"
},
{
"path": "ddl-tpcds/bin_partitioned/household_demographics.sql",
"chars": 200,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists household_demographics;\n\ncreate table household_de"
},
{
"path": "ddl-tpcds/bin_partitioned/income_band.sql",
"chars": 167,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists income_band;\n\ncreate table income_band\nstored as $"
},
{
"path": "ddl-tpcds/bin_partitioned/inventory.sql",
"chars": 185,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists inventory;\n\ncreate table inventory\nstored as ${FIL"
},
{
"path": "ddl-tpcds/bin_partitioned/item.sql",
"chars": 168,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists item;\n\ncreate table item\nstored as ${FILE}\nas sele"
},
{
"path": "ddl-tpcds/bin_partitioned/promotion.sql",
"chars": 161,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists promotion;\n\ncreate table promotion\nstored as ${FIL"
},
{
"path": "ddl-tpcds/bin_partitioned/reason.sql",
"chars": 152,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists reason;\n\ncreate table reason\nstored as ${FILE}\nas "
},
{
"path": "ddl-tpcds/bin_partitioned/ship_mode.sql",
"chars": 161,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists ship_mode;\n\ncreate table ship_mode\nstored as ${FIL"
},
{
"path": "ddl-tpcds/bin_partitioned/store.sql",
"chars": 172,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists store;\n\ncreate table store\nstored as ${FILE}\nas se"
},
{
"path": "ddl-tpcds/bin_partitioned/store_returns.sql",
"chars": 2159,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists store_returns;\n\ncreate table store_returns\n(\n "
},
{
"path": "ddl-tpcds/bin_partitioned/store_sales.sql",
"chars": 2386,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists store_sales;\n\ncreate table store_sales\n(\n ss_"
},
{
"path": "ddl-tpcds/bin_partitioned/time_dim.sql",
"chars": 158,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists time_dim;\n\ncreate table time_dim\nstored as ${FILE}"
},
{
"path": "ddl-tpcds/bin_partitioned/warehouse.sql",
"chars": 161,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists warehouse;\n\ncreate table warehouse\nstored as ${FIL"
},
{
"path": "ddl-tpcds/bin_partitioned/web_page.sql",
"chars": 158,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists web_page;\n\ncreate table web_page\nstored as ${FILE}"
},
{
"path": "ddl-tpcds/bin_partitioned/web_returns.sql",
"chars": 2688,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists web_returns;\n\ncreate table web_returns\n(\n wr_"
},
{
"path": "ddl-tpcds/bin_partitioned/web_sales.sql",
"chars": 3744,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists web_sales;\n\ncreate table web_sales\n(\n ws_sold_t"
},
{
"path": "ddl-tpcds/bin_partitioned/web_site.sql",
"chars": 158,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists web_site;\n\ncreate table web_site\nstored as ${FILE}"
},
{
"path": "ddl-tpcds/text/alltables.sql",
"chars": 18240,
"preview": "create database if not exists ${DB};\nuse ${DB};\n-- Table<store_sales (23 cols) partition=ss_sold_date_sk>\n\ndrop table i"
},
{
"path": "ddl-tpcds/text/analyze_everything.sql",
"chars": 1383,
"preview": "analyze table call_center compute statistics for columns;\nanalyze table catalog_page compute statistics for columns;\nana"
},
{
"path": "ddl-tpch/bin_flat/alltables.sql",
"chars": 2505,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists lineitem;\ncreate external table lineitem \n(L_ORDER"
},
{
"path": "ddl-tpch/bin_flat/analyze.sql",
"chars": 430,
"preview": "analyze table nation compute statistics for columns;\nanalyze table region compute statistics for columns;\nanalyze table "
},
{
"path": "ddl-tpch/bin_flat/customer.sql",
"chars": 183,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists customer;\n\ncreate table customer\nstored as ${FILE}"
},
{
"path": "ddl-tpch/bin_flat/lineitem.sql",
"chars": 182,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists lineitem;\n\ncreate table lineitem\nstored as ${FILE}"
},
{
"path": "ddl-tpch/bin_flat/nation.sql",
"chars": 161,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists nation;\n\ncreate table nation\nstored as ${FILE}\nas "
},
{
"path": "ddl-tpch/bin_flat/orders.sql",
"chars": 176,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists orders;\n\ncreate table orders\nstored as ${FILE}\nas "
},
{
"path": "ddl-tpch/bin_flat/part.sql",
"chars": 166,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists part;\n\ncreate table part\nstored as ${FILE}\nas sele"
},
{
"path": "ddl-tpch/bin_flat/partsupp.sql",
"chars": 181,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists partsupp;\n\ncreate table partsupp\nstored as ${FILE}"
},
{
"path": "ddl-tpch/bin_flat/region.sql",
"chars": 161,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists region;\n\ncreate table region\nstored as ${FILE}\nas "
},
{
"path": "ddl-tpch/bin_flat/supplier.sql",
"chars": 193,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists supplier;\n\ncreate table supplier\nstored as ${FILE}"
},
{
"path": "ddl-tpch/bin_partitioned/analyze.sql",
"chars": 430,
"preview": "analyze table nation compute statistics for columns;\nanalyze table region compute statistics for columns;\nanalyze table "
},
{
"path": "ddl-tpch/bin_partitioned/customer.sql",
"chars": 252,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists customer;\n\ncreate table customer\nstored as ${FILE}"
},
{
"path": "ddl-tpch/bin_partitioned/lineitem.sql",
"chars": 888,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists lineitem;\n\ncreate table lineitem \n(L_ORDERKEY BIGI"
},
{
"path": "ddl-tpch/bin_partitioned/nation.sql",
"chars": 229,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists nation;\n\ncreate table nation\nstored as ${FILE}\nTBL"
},
{
"path": "ddl-tpch/bin_partitioned/orders.sql",
"chars": 637,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists orders;\n\ncreate table orders (O_ORDERKEY BIGINT,\n "
},
{
"path": "ddl-tpch/bin_partitioned/part.sql",
"chars": 234,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists part;\n\ncreate table part\nstored as ${FILE}\nTBLPROP"
},
{
"path": "ddl-tpch/bin_partitioned/partsupp.sql",
"chars": 250,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists partsupp;\n\ncreate table partsupp\nstored as ${FILE}"
},
{
"path": "ddl-tpch/bin_partitioned/region.sql",
"chars": 229,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists region;\n\ncreate table region\nstored as ${FILE}\nTBL"
},
{
"path": "ddl-tpch/bin_partitioned/supplier.sql",
"chars": 261,
"preview": "create database if not exists ${DB};\nuse ${DB};\n\ndrop table if exists supplier;\n\ncreate table supplier\nstored as ${FILE}"
},
{
"path": "runSuite.pl",
"chars": 1887,
"preview": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse File::Basename;\n\n# PROTOTYPES\nsub dieWithUsage(;$);\n\n# GLOBALS\nmy $SCRIPT"
},
{
"path": "sample-queries-tpcds/README.md",
"chars": 182,
"preview": "Sample TPC-DS Queries\n=====================\n\nThis directory contains sample TPC-DS queries you can run once you have gen"
},
{
"path": "sample-queries-tpcds/query1.sql",
"chars": 727,
"preview": "-- start query 1 in stream 0 using template query1.tpl and seed 2031708268\nwith customer_total_return as\n(select sr_cust"
},
{
"path": "sample-queries-tpcds/query10.sql",
"chars": 1874,
"preview": "-- start query 1 in stream 0 using template query10.tpl and seed 797269820\nselect \n cd_gender,\n cd_marital_status,\n "
},
{
"path": "sample-queries-tpcds/query11.sql",
"chars": 2947,
"preview": "-- start query 1 in stream 0 using template query11.tpl and seed 1819994127\nwith year_total as (\n select c_customer_id c"
},
{
"path": "sample-queries-tpcds/query12.sql",
"chars": 869,
"preview": "-- start query 1 in stream 0 using template query12.tpl and seed 345591136\nselect i_item_id\n ,i_item_desc \n ,"
},
{
"path": "sample-queries-tpcds/query13.sql",
"chars": 1567,
"preview": "-- start query 1 in stream 0 using template query13.tpl and seed 622697896\nselect avg(ss_quantity)\n ,avg(ss_ext_sa"
},
{
"path": "sample-queries-tpcds/query14.sql",
"chars": 7501,
"preview": "-- start query 1 in stream 0 using template query14.tpl and seed 1819994127\nwith cross_items as\n (select i_item_sk ss_i"
},
{
"path": "sample-queries-tpcds/query15.sql",
"chars": 662,
"preview": "-- start query 1 in stream 0 using template query15.tpl and seed 1819994127\nselect ca_zip\n ,sum(cs_sales_price)\n "
},
{
"path": "sample-queries-tpcds/query16.sql",
"chars": 1070,
"preview": "-- start query 1 in stream 0 using template query16.tpl and seed 171719422\nselect \n count(distinct cs_order_number) a"
},
{
"path": "sample-queries-tpcds/query17.sql",
"chars": 1754,
"preview": "-- start query 1 in stream 0 using template query17.tpl and seed 1819994127\nselect i_item_id\n ,i_item_desc\n "
},
{
"path": "sample-queries-tpcds/query18.sql",
"chars": 1356,
"preview": "-- start query 1 in stream 0 using template query18.tpl and seed 1978355063\nselect i_item_id,\n ca_country,\n "
},
{
"path": "sample-queries-tpcds/query19.sql",
"chars": 784,
"preview": "-- start query 1 in stream 0 using template query19.tpl and seed 1930872976\nselect i_brand_id brand_id, i_brand brand, "
},
{
"path": "sample-queries-tpcds/query2.sql",
"chars": 2237,
"preview": "-- start query 1 in stream 0 using template query2.tpl and seed 1819994127\nwith wscs as\n (select sold_date_sk\n ,s"
},
{
"path": "sample-queries-tpcds/query20.sql",
"chars": 888,
"preview": "-- start query 1 in stream 0 using template query20.tpl and seed 345591136\nselect i_item_id\n ,i_item_desc \n "
},
{
"path": "sample-queries-tpcds/query21.sql",
"chars": 1154,
"preview": "-- start query 1 in stream 0 using template query21.tpl and seed 1819994127\nselect *\n from(select w_warehouse_name\n "
},
{
"path": "sample-queries-tpcds/query22.sql",
"chars": 667,
"preview": "-- start query 1 in stream 0 using template query22.tpl and seed 1819994127\nselect i_product_name\n ,i_brand"
},
{
"path": "sample-queries-tpcds/query23.sql",
"chars": 3913,
"preview": "-- start query 1 in stream 0 using template query23.tpl and seed 2031708268\nwith frequent_ss_items as \n (select substr(i"
},
{
"path": "sample-queries-tpcds/query24.sql",
"chars": 2444,
"preview": "-- start query 1 in stream 0 using template query24.tpl and seed 1220860970\nwith ssales as\n(select c_last_name\n ,c_"
},
{
"path": "sample-queries-tpcds/query25.sql",
"chars": 1122,
"preview": "-- start query 1 in stream 0 using template query25.tpl and seed 1819994127\nselect \n i_item_id\n ,i_item_desc\n ,s_store_"
},
{
"path": "sample-queries-tpcds/query26.sql",
"chars": 742,
"preview": "-- start query 1 in stream 0 using template query26.tpl and seed 1930872976\nselect i_item_id, \n avg(cs_quantity)"
},
{
"path": "sample-queries-tpcds/query27.sql",
"chars": 809,
"preview": "-- start query 1 in stream 0 using template query27.tpl and seed 2017787633\nselect i_item_id,\n s_state, grouping"
},
{
"path": "sample-queries-tpcds/query28.sql",
"chars": 2292,
"preview": "-- start query 1 in stream 0 using template query28.tpl and seed 444293455\nselect *\nfrom (select avg(ss_list_price) B1_"
},
{
"path": "sample-queries-tpcds/query29.sql",
"chars": 1368,
"preview": "-- start query 1 in stream 0 using template query29.tpl and seed 2031708268\nselect \n i_item_id\n ,i_item_desc\n "
},
{
"path": "sample-queries-tpcds/query3.sql",
"chars": 581,
"preview": "-- start query 1 in stream 0 using template query3.tpl and seed 2031708268\nselect dt.d_year \n ,item.i_brand_id br"
},
{
"path": "sample-queries-tpcds/query30.sql",
"chars": 1328,
"preview": "-- start query 1 in stream 0 using template query30.tpl and seed 1819994127\nwith customer_total_return as\n (select wr_re"
},
{
"path": "sample-queries-tpcds/query31.sql",
"chars": 1809,
"preview": "-- start query 1 in stream 0 using template query31.tpl and seed 1819994127\nwith ss as\n (select ca_county,d_qoy, d_year,"
},
{
"path": "sample-queries-tpcds/query32.sql",
"chars": 802,
"preview": "-- start query 1 in stream 0 using template query32.tpl and seed 2031708268\nselect sum(cs_ext_discount_amt) as `excess"
},
{
"path": "sample-queries-tpcds/query33.sql",
"chars": 1981,
"preview": "-- start query 1 in stream 0 using template query33.tpl and seed 1930872976\nwith ss as (\n select\n i_manufact_id"
},
{
"path": "sample-queries-tpcds/query34.sql",
"chars": 1475,
"preview": "-- start query 1 in stream 0 using template query34.tpl and seed 1971067816\nselect c_last_name\n ,c_first_name\n "
},
{
"path": "sample-queries-tpcds/query35.sql",
"chars": 1743,
"preview": "-- start query 1 in stream 0 using template query35.tpl and seed 1930872976\nselect \n ca_state,\n cd_gender,\n cd_mari"
},
{
"path": "sample-queries-tpcds/query36.sql",
"chars": 916,
"preview": "-- start query 1 in stream 0 using template query36.tpl and seed 1544728811\nselect \n sum(ss_net_profit)/sum(ss_ext_s"
},
{
"path": "sample-queries-tpcds/query37.sql",
"chars": 626,
"preview": "-- start query 1 in stream 0 using template query37.tpl and seed 301843662\nselect i_item_id\n ,i_item_desc\n "
},
{
"path": "sample-queries-tpcds/query38.sql",
"chars": 1024,
"preview": "-- start query 1 in stream 0 using template query38.tpl and seed 1819994127\nselect count(*) from (\n select distinct "
},
{
"path": "sample-queries-tpcds/query39.sql",
"chars": 2238,
"preview": "-- start query 1 in stream 0 using template query39.tpl and seed 1327317894\nwith inv as\n(select w_warehouse_name,w_wareh"
},
{
"path": "sample-queries-tpcds/query4.sql",
"chars": 4335,
"preview": "-- start query 1 in stream 0 using template query4.tpl and seed 1819994127\nwith year_total as (\n select c_customer_id cu"
},
{
"path": "sample-queries-tpcds/query40.sql",
"chars": 999,
"preview": "-- start query 1 in stream 0 using template query40.tpl and seed 1819994127\nselect \n w_state\n ,i_item_id\n ,sum(case"
},
{
"path": "sample-queries-tpcds/query41.sql",
"chars": 2021,
"preview": "-- start query 1 in stream 0 using template query41.tpl and seed 1581015815\nselect distinct(i_product_name)\n from item "
},
{
"path": "sample-queries-tpcds/query42.sql",
"chars": 599,
"preview": "-- start query 1 in stream 0 using template query42.tpl and seed 1819994127\nselect dt.d_year\n \t,item.i_category_id\n \t,i"
},
{
"path": "sample-queries-tpcds/query43.sql",
"chars": 1116,
"preview": "-- start query 1 in stream 0 using template query43.tpl and seed 1819994127\nselect s_store_name, s_store_id,\n su"
},
{
"path": "sample-queries-tpcds/query44.sql",
"chars": 1748,
"preview": "-- start query 1 in stream 0 using template query44.tpl and seed 1819994127\nselect asceding.rnk, i1.i_product_name best"
},
{
"path": "sample-queries-tpcds/query45.sql",
"chars": 811,
"preview": "-- start query 1 in stream 0 using template query45.tpl and seed 2031708268\nselect ca_zip, ca_county, sum(ws_sales_pric"
},
{
"path": "sample-queries-tpcds/query46.sql",
"chars": 1398,
"preview": "-- start query 1 in stream 0 using template query46.tpl and seed 803547492\nselect c_last_name\n ,c_first_name\n "
},
{
"path": "sample-queries-tpcds/query47.sql",
"chars": 1873,
"preview": "-- start query 1 in stream 0 using template query47.tpl and seed 2031708268\nwith v1 as(\n select i_category, i_brand,\n "
},
{
"path": "sample-queries-tpcds/query48.sql",
"chars": 1316,
"preview": "-- start query 1 in stream 0 using template query48.tpl and seed 622697896\nselect sum (ss_quantity)\n from store_sales, s"
},
{
"path": "sample-queries-tpcds/query49.sql",
"chars": 4036,
"preview": "-- start query 1 in stream 0 using template query49.tpl and seed 1819994127\nselect channel, item, return_ratio, return_"
},
{
"path": "sample-queries-tpcds/query5.sql",
"chars": 4030,
"preview": "-- start query 1 in stream 0 using template query5.tpl and seed 1819994127\nwith ssr as\n (select s_store_id,\n sum("
},
{
"path": "sample-queries-tpcds/query50.sql",
"chars": 1688,
"preview": "-- start query 1 in stream 0 using template query50.tpl and seed 1819994127\nselect \n s_store_name\n ,s_company_id\n ,"
},
{
"path": "sample-queries-tpcds/query51.sql",
"chars": 1767,
"preview": "-- start query 1 in stream 0 using template query51.tpl and seed 1819994127\nWITH web_v1 as (\nselect\n ws_item_sk item_sk"
},
{
"path": "sample-queries-tpcds/query52.sql",
"chars": 571,
"preview": "-- start query 1 in stream 0 using template query52.tpl and seed 1819994127\nselect dt.d_year\n \t,item.i_brand_id brand_i"
},
{
"path": "sample-queries-tpcds/query53.sql",
"chars": 1185,
"preview": "-- start query 1 in stream 0 using template query53.tpl and seed 1819994127\nselect * from \n(select i_manufact_id,\nsum(s"
},
{
"path": "sample-queries-tpcds/query54.sql",
"chars": 1820,
"preview": "-- start query 1 in stream 0 using template query54.tpl and seed 1930872976\nwith my_customers as (\n select distinct c_cu"
},
{
"path": "sample-queries-tpcds/query55.sql",
"chars": 443,
"preview": "-- start query 1 in stream 0 using template query55.tpl and seed 2031708268\nselect i_brand_id brand_id, i_brand brand,\n"
},
{
"path": "sample-queries-tpcds/query56.sql",
"chars": 1953,
"preview": "-- start query 1 in stream 0 using template query56.tpl and seed 1951559352\nwith ss as (\n select i_item_id,sum(ss_ext_sa"
},
{
"path": "sample-queries-tpcds/query57.sql",
"chars": 1691,
"preview": "-- start query 1 in stream 0 using template query57.tpl and seed 2031708268\nwith v1 as(\n select i_category, i_brand,\n "
},
{
"path": "sample-queries-tpcds/query58.sql",
"chars": 2450,
"preview": "-- start query 1 in stream 0 using template query58.tpl and seed 1819994127\nwith ss_items as\n (select i_item_id item_id\n"
},
{
"path": "sample-queries-tpcds/query59.sql",
"chars": 2137,
"preview": "-- start query 1 in stream 0 using template query59.tpl and seed 1819994127\nwith wss as \n (select d_week_seq,\n ss"
},
{
"path": "sample-queries-tpcds/query6.sql",
"chars": 790,
"preview": "-- start query 1 in stream 0 using template query6.tpl and seed 1819994127\nselect a.ca_state state, count(*) cnt\n from "
},
{
"path": "sample-queries-tpcds/query60.sql",
"chars": 1962,
"preview": "-- start query 1 in stream 0 using template query60.tpl and seed 1930872976\nwith ss as (\n select\n i_item_id,sum"
},
{
"path": "sample-queries-tpcds/query61.sql",
"chars": 1371,
"preview": "-- start query 1 in stream 0 using template query61.tpl and seed 1930872976\nselect promotions,total,cast(promotions as "
},
{
"path": "sample-queries-tpcds/query62.sql",
"chars": 1280,
"preview": "-- start query 1 in stream 0 using template query62.tpl and seed 1819994127\nselect \n substr(w_warehouse_name,1,20)\n "
},
{
"path": "sample-queries-tpcds/query63.sql",
"chars": 1389,
"preview": "-- start query 1 in stream 0 using template query63.tpl and seed 1819994127\nselect * \nfrom (select i_manager_id\n "
},
{
"path": "sample-queries-tpcds/query64.sql",
"chars": 3639,
"preview": "-- start query 1 in stream 0 using template query64.tpl and seed 1220860970\nwith cs_ui as\n (select cs_item_sk\n ,s"
},
{
"path": "sample-queries-tpcds/query65.sql",
"chars": 971,
"preview": "-- start query 1 in stream 0 using template query65.tpl and seed 1819994127\nselect \n\ts_store_name,\n\ti_item_desc,\n\tsc.rev"
},
{
"path": "sample-queries-tpcds/query66.sql",
"chars": 7721,
"preview": "-- start query 1 in stream 0 using template query66.tpl and seed 2042478054\nselect \n w_warehouse_name\n \t,w_war"
},
{
"path": "sample-queries-tpcds/query67.sql",
"chars": 1290,
"preview": "-- start query 1 in stream 0 using template query67.tpl and seed 1819994127\nselect *\nfrom (select i_category\n "
},
{
"path": "sample-queries-tpcds/query68.sql",
"chars": 1548,
"preview": "-- start query 1 in stream 0 using template query68.tpl and seed 803547492\nselect c_last_name\n ,c_first_name\n "
},
{
"path": "sample-queries-tpcds/query69.sql",
"chars": 1516,
"preview": "-- start query 1 in stream 0 using template query69.tpl and seed 797269820\nselect \n cd_gender,\n cd_marital_status,\n "
},
{
"path": "sample-queries-tpcds/query7.sql",
"chars": 733,
"preview": "-- start query 1 in stream 0 using template query7.tpl and seed 1930872976\nselect i_item_id, \n avg(ss_quantity) "
},
{
"path": "sample-queries-tpcds/query70.sql",
"chars": 1261,
"preview": "-- start query 1 in stream 0 using template query70.tpl and seed 1819994127\nselect \n sum(ss_net_profit) as total_sum"
},
{
"path": "sample-queries-tpcds/query71.sql",
"chars": 1667,
"preview": "-- start query 1 in stream 0 using template query71.tpl and seed 2031708268\nselect i_brand_id brand_id, i_brand brand,t_"
},
{
"path": "sample-queries-tpcds/query72.sql",
"chars": 1291,
"preview": "-- start query 1 in stream 0 using template query72.tpl and seed 2031708268\nselect i_item_desc\n ,w_warehouse_name\n"
},
{
"path": "sample-queries-tpcds/query73.sql",
"chars": 1287,
"preview": "-- start query 1 in stream 0 using template query73.tpl and seed 1971067816\nselect c_last_name\n ,c_first_name\n "
},
{
"path": "sample-queries-tpcds/query74.sql",
"chars": 2138,
"preview": "-- start query 1 in stream 0 using template query74.tpl and seed 1556717815\nwith year_total as (\n select c_customer_id c"
},
{
"path": "sample-queries-tpcds/query75.sql",
"chars": 3211,
"preview": "-- start query 1 in stream 0 using template query75.tpl and seed 1819994127\nWITH all_sales AS (\n SELECT d_year\n ,i"
},
{
"path": "sample-queries-tpcds/query76.sql",
"chars": 1250,
"preview": "-- start query 1 in stream 0 using template query76.tpl and seed 2031708268\nselect channel, col_name, d_year, d_qoy, i_"
},
{
"path": "sample-queries-tpcds/query77.sql",
"chars": 3220,
"preview": "-- start query 1 in stream 0 using template query77.tpl and seed 1819994127\nwith ss as\n (select s_store_sk,\n sum"
},
{
"path": "sample-queries-tpcds/query78.sql",
"chars": 2195,
"preview": "-- start query 1 in stream 0 using template query78.tpl and seed 1819994127\nwith ws as\n (select d_year AS ws_sold_year,"
},
{
"path": "sample-queries-tpcds/query79.sql",
"chars": 1032,
"preview": "-- start query 1 in stream 0 using template query79.tpl and seed 2031708268\nselect \n c_last_name,c_first_name,substr(s_"
},
{
"path": "sample-queries-tpcds/query8.sql",
"chars": 6233,
"preview": "-- start query 1 in stream 0 using template query8.tpl and seed 1766988859\nselect s_store_name\n ,sum(ss_net_profit"
},
{
"path": "sample-queries-tpcds/query80.sql",
"chars": 3021,
"preview": "-- start query 1 in stream 0 using template query80.tpl and seed 1819994127\nwith ssr as\n (select s_store_id as store_id"
},
{
"path": "sample-queries-tpcds/query81.sql",
"chars": 1398,
"preview": "-- start query 1 in stream 0 using template query81.tpl and seed 1819994127\nwith customer_total_return as\n (select cr_re"
},
{
"path": "sample-queries-tpcds/query82.sql",
"chars": 619,
"preview": "-- start query 1 in stream 0 using template query82.tpl and seed 55585014\nselect i_item_id\n ,i_item_desc\n ,"
},
{
"path": "sample-queries-tpcds/query83.sql",
"chars": 1889,
"preview": "-- start query 1 in stream 0 using template query83.tpl and seed 1930872976\nwith sr_items as\n (select i_item_id item_id,"
},
{
"path": "sample-queries-tpcds/query84.sql",
"chars": 733,
"preview": "-- start query 1 in stream 0 using template query84.tpl and seed 1819994127\nselect c_customer_id as customer_id\n "
},
{
"path": "sample-queries-tpcds/query85.sql",
"chars": 2153,
"preview": "-- start query 1 in stream 0 using template query85.tpl and seed 622697896\nselect substr(r_reason_desc,1,20)\n ,av"
},
{
"path": "sample-queries-tpcds/query86.sql",
"chars": 766,
"preview": "-- start query 1 in stream 0 using template query86.tpl and seed 1819994127\nselect \n sum(ws_net_paid) as total_sum\n"
},
{
"path": "sample-queries-tpcds/query87.sql",
"chars": 1037,
"preview": "-- start query 1 in stream 0 using template query87.tpl and seed 1819994127\nselect count(*) \nfrom ((select distinct c_la"
},
{
"path": "sample-queries-tpcds/query88.sql",
"chars": 5266,
"preview": "-- start query 1 in stream 0 using template query88.tpl and seed 318176889\nselect *\nfrom\n (select count(*) h8_30_to_9\n "
},
{
"path": "sample-queries-tpcds/query89.sql",
"chars": 1111,
"preview": "-- start query 1 in stream 0 using template query89.tpl and seed 1719819282\nselect *\nfrom(\nselect i_category, i_class, "
},
{
"path": "sample-queries-tpcds/query9.sql",
"chars": 2282,
"preview": "-- start query 1 in stream 0 using template query9.tpl and seed 1490436826\nselect case when (select count(*) \n "
},
{
"path": "sample-queries-tpcds/query90.sql",
"chars": 1096,
"preview": "-- start query 1 in stream 0 using template query90.tpl and seed 2031708268\nselect cast(amc as decimal(15,4))/cast(pmc "
},
{
"path": "sample-queries-tpcds/query91.sql",
"chars": 1206,
"preview": "-- start query 1 in stream 0 using template query91.tpl and seed 1930872976\nselect \n cc_call_center_id Call_Cent"
},
{
"path": "sample-queries-tpcds/query92.sql",
"chars": 834,
"preview": "-- start query 1 in stream 0 using template query92.tpl and seed 2031708268\nselect \n sum(ws_ext_discount_amt) as `Ex"
},
{
"path": "sample-queries-tpcds/query93.sql",
"chars": 902,
"preview": "-- start query 1 in stream 0 using template query93.tpl and seed 1200409435\nselect ss_customer_sk\n ,sum(act_"
},
{
"path": "sample-queries-tpcds/query94.sql",
"chars": 955,
"preview": "-- start query 1 in stream 0 using template query94.tpl and seed 2031708268\nselect \n count(distinct ws_order_number) "
},
{
"path": "sample-queries-tpcds/query95.sql",
"chars": 1150,
"preview": "-- start query 1 in stream 0 using template query95.tpl and seed 2031708268\nwith ws_wh as\n(select ws1.ws_order_number,ws"
},
{
"path": "sample-queries-tpcds/query96.sql",
"chars": 525,
"preview": "-- start query 1 in stream 0 using template query96.tpl and seed 1819994127\nselect count(*) \nfrom store_sales\n ,hous"
},
{
"path": "sample-queries-tpcds/query97.sql",
"chars": 1075,
"preview": "-- start query 1 in stream 0 using template query97.tpl and seed 1819994127\nwith ssci as (\nselect ss_customer_sk custome"
},
{
"path": "sample-queries-tpcds/query98.sql",
"chars": 852,
"preview": "-- start query 1 in stream 0 using template query98.tpl and seed 345591136\nselect i_item_id\n ,i_item_desc \n ,i"
},
{
"path": "sample-queries-tpcds/query99.sql",
"chars": 1291,
"preview": "-- start query 1 in stream 0 using template query99.tpl and seed 1819994127\nselect \n substr(w_warehouse_name,1,20)\n "
},
{
"path": "sample-queries-tpch/README.md",
"chars": 186,
"preview": "Sample TPC-H Queries\n====================\n\nThis directory contains sample TPC-H queries you can run once you have genera"
},
{
"path": "sample-queries-tpch/testbench-withATS.settings",
"chars": 2587,
"preview": "set ambari.hive.db.schema.name=hive;\nset fs.file.impl.disable.cache=true;\nset fs.hdfs.impl.disable.cache=true;\nset hive."
},
{
"path": "sample-queries-tpch/testbench.settings",
"chars": 2387,
"preview": "set ambari.hive.db.schema.name=hive;\nset fs.file.impl.disable.cache=true;\nset fs.hdfs.impl.disable.cache=true;\nset hive."
},
{
"path": "sample-queries-tpch/tpch_query1.sql",
"chars": 483,
"preview": "select\n\tl_returnflag,\n\tl_linestatus,\n\tsum(l_quantity) as sum_qty,\n\tsum(l_extendedprice) as sum_base_price,\n\tsum(l_extend"
},
{
"path": "sample-queries-tpch/tpch_query10.sql",
"chars": 474,
"preview": "select\n\tc_custkey,\n\tc_name,\n\tsum(l_extendedprice * (1 - l_discount)) as revenue,\n\tc_acctbal,\n\tn_name,\n\tc_address,\n\tc_pho"
},
{
"path": "sample-queries-tpch/tpch_query11.sql",
"chars": 624,
"preview": "drop view q11_part_tmp_cached;\ndrop view q11_sum_tmp_cached;\n\ncreate view q11_part_tmp_cached as\nselect\n\tps_partkey,\n\tsu"
},
{
"path": "sample-queries-tpch/tpch_query12.sql",
"chars": 540,
"preview": "select\n\tl_shipmode,\n\tsum(case\n\t\twhen o_orderpriority = '1-URGENT'\n\t\t\tor o_orderpriority = '2-HIGH'\n\t\t\tthen 1\n\t\telse 0\n\te"
},
{
"path": "sample-queries-tpch/tpch_query13.sql",
"chars": 315,
"preview": "select\n\tc_count,\n\tcount(*) as custdist\nfrom\n\t(\n\t\tselect\n\t\t\tc_custkey,\n\t\t\tcount(o_orderkey) as c_count\n\t\tfrom\n\t\t\tcustomer"
},
{
"path": "sample-queries-tpch/tpch_query14.sql",
"chars": 286,
"preview": "select\n\t100.00 * sum(case\n\t\twhen p_type like 'PROMO%'\n\t\t\tthen l_extendedprice * (1 - l_discount)\n\t\telse 0\n\tend) / sum(l_"
},
{
"path": "sample-queries-tpch/tpch_query15.sql",
"chars": 582,
"preview": "drop view revenue_cached;\ndrop view max_revenue_cached;\n\ncreate view revenue_cached as\nselect\n\tl_suppkey as supplier_no,"
},
{
"path": "sample-queries-tpch/tpch_query16.sql",
"chars": 467,
"preview": "select\n\tp_brand,\n\tp_type,\n\tp_size,\n\tcount(distinct ps_suppkey) as supplier_cnt\nfrom\n\tpartsupp,\n\tpart\nwhere\n\tp_partkey = "
},
{
"path": "sample-queries-tpch/tpch_query17.sql",
"chars": 595,
"preview": "with q17_part as (\n select p_partkey from part where \n p_brand = 'Brand#23'\n and p_container = 'MED BOX'\n),\nq17_avg "
},
{
"path": "sample-queries-tpch/tpch_query18.sql",
"chars": 719,
"preview": "drop view q18_tmp_cached;\ndrop table q18_large_volume_customer_cached;\n\ncreate view q18_tmp_cached as\nselect\n\tl_orderkey"
},
{
"path": "sample-queries-tpch/tpch_query19.sql",
"chars": 941,
"preview": "select\n\tsum(l_extendedprice* (1 - l_discount)) as revenue\nfrom\n\tlineitem,\n\tpart\nwhere\n\t(\n\t\tp_partkey = l_partkey\n\t\tand p"
},
{
"path": "sample-queries-tpch/tpch_query2.sql",
"chars": 849,
"preview": "drop view q2_min_ps_supplycost;\ncreate view q2_min_ps_supplycost as\nselect\n\tp_partkey as min_p_partkey,\n\tmin(ps_supplyco"
},
{
"path": "sample-queries-tpch/tpch_query20.sql",
"chars": 887,
"preview": "-- explain formatted \nwith tmp1 as (\n select p_partkey from part where p_name like 'forest%'\n),\ntmp2 as (\n select "
},
{
"path": "sample-queries-tpch/tpch_query21.sql",
"chars": 943,
"preview": "-- explain\n\ncreate temporary table l3 stored as orc as \nselect l_orderkey, count(distinct l_suppkey) as cntSupp\nfrom lin"
},
{
"path": "sample-queries-tpch/tpch_query22.sql",
"chars": 1173,
"preview": "drop view q22_customer_tmp_cached;\ndrop view q22_customer_tmp1_cached;\ndrop view q22_orders_tmp_cached;\n\ncreate view if "
},
{
"path": "sample-queries-tpch/tpch_query3.sql",
"chars": 389,
"preview": "select\n\tl_orderkey,\n\tsum(l_extendedprice * (1 - l_discount)) as revenue,\n\to_orderdate,\n\to_shippriority\nfrom\n\tcustomer,\n\t"
},
{
"path": "sample-queries-tpch/tpch_query4.sql",
"chars": 311,
"preview": "select\n\to_orderpriority,\n\tcount(*) as order_count\nfrom\n\torders as o\nwhere\n\to_orderdate >= '1996-05-01'\n\tand o_orderdate "
},
{
"path": "sample-queries-tpch/tpch_query5.sql",
"chars": 439,
"preview": "select\n\tn_name,\n\tsum(l_extendedprice * (1 - l_discount)) as revenue\nfrom\n\tcustomer,\n\torders,\n\tlineitem,\n\tsupplier,\n\tnati"
},
{
"path": "sample-queries-tpch/tpch_query6.sql",
"chars": 207,
"preview": "select\n\tsum(l_extendedprice * l_discount) as revenue\nfrom\n\tlineitem\nwhere\n\tl_shipdate >= '1993-01-01'\n\tand l_shipdate < "
},
{
"path": "sample-queries-tpch/tpch_query7.sql",
"chars": 748,
"preview": "select\n\tsupp_nation,\n\tcust_nation,\n\tl_year,\n\tsum(volume) as revenue\nfrom\n\t(\n\t\tselect\n\t\t\tn1.n_name as supp_nation,\n\t\t\tn2."
},
{
"path": "sample-queries-tpch/tpch_query8.sql",
"chars": 737,
"preview": "select\n\to_year,\n\tsum(case\n\t\twhen nation = 'PERU' then volume\n\t\telse 0\n\tend) / sum(volume) as mkt_share\nfrom\n\t(\n\t\tselect\n"
},
{
"path": "sample-queries-tpch/tpch_query9.sql",
"chars": 560,
"preview": "select\n\tnation,\n\to_year,\n\tsum(amount) as sum_profit\nfrom\n\t(\n\t\tselect\n\t\t\tn_name as nation,\n\t\t\tyear(o_orderdate) as o_year"
},
{
"path": "settings/init.sql",
"chars": 1068,
"preview": "set hive.map.aggr=true;\nset mapreduce.reduce.speculative=false;\nset hive.auto.convert.join=true;\nset hive.optimize.reduc"
},
{
"path": "settings/load-flat.sql",
"chars": 764,
"preview": "--set hive.enforce.bucketing=true;\n--set hive.enforce.sorting=true;\nset hive.exec.dynamic.partition.mode=nonstrict;\nset "
},
{
"path": "settings/load-partitioned.sql",
"chars": 1448,
"preview": "-- set hive.enforce.bucketing=true;\n-- set hive.enforce.sorting=true;\nset hive.exec.dynamic.partition.mode=nonstrict;\nse"
},
{
"path": "spark-queries-tpcds/LICENSE",
"chars": 17881,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "spark-queries-tpcds/README.md",
"chars": 141,
"preview": "These are the full 99 TPC-DS queries from Apache Spark 2.2.\n\n- https://github.com/apache/spark/tree/master/sql/core/src/"
},
{
"path": "spark-queries-tpcds/q1.sql",
"chars": 636,
"preview": "WITH customer_total_return AS\n( SELECT\n sr_customer_sk AS ctr_customer_sk,\n sr_store_sk AS ctr_store_sk,\n sum(s"
},
{
"path": "spark-queries-tpcds/q10.sql",
"chars": 1632,
"preview": "SELECT\n cd_gender,\n cd_marital_status,\n cd_education_status,\n count(*) cnt1,\n cd_purchase_estimate,\n count(*) cnt2"
},
{
"path": "spark-queries-tpcds/q11.sql",
"chars": 2322,
"preview": "WITH year_total AS (\n SELECT\n c_customer_id customer_id,\n c_first_name customer_first_name,\n c_last_name custo"
},
{
"path": "spark-queries-tpcds/q12.sql",
"chars": 624,
"preview": "SELECT\n i_item_desc,\n i_category,\n i_class,\n i_current_price,\n sum(ws_ext_sales_price) AS itemrevenue,\n sum(ws_ext"
},
{
"path": "spark-queries-tpcds/q13.sql",
"chars": 1413,
"preview": "SELECT\n avg(ss_quantity),\n avg(ss_ext_sales_price),\n avg(ss_ext_wholesale_cost),\n sum(ss_ext_wholesale_cost)\nFROM st"
},
{
"path": "spark-queries-tpcds/q14a.sql",
"chars": 3717,
"preview": "WITH cross_items AS\n(SELECT i_item_sk ss_item_sk\n FROM item,\n (SELECT\n iss.i_brand_id brand_id,\n iss.i_cla"
},
{
"path": "spark-queries-tpcds/q14b.sql",
"chars": 3077,
"preview": "WITH cross_items AS\n(SELECT i_item_sk ss_item_sk\n FROM item,\n (SELECT\n iss.i_brand_id brand_id,\n iss.i_cla"
},
{
"path": "spark-queries-tpcds/q15.sql",
"chars": 496,
"preview": "SELECT\n ca_zip,\n sum(cs_sales_price)\nFROM catalog_sales, customer, customer_address, date_dim\nWHERE cs_bill_customer_s"
},
{
"path": "spark-queries-tpcds/q16.sql",
"chars": 979,
"preview": "SELECT\n count(DISTINCT cs_order_number) AS `order count `,\n sum(cs_ext_ship_cost) AS `total shipping cost `,\n sum(cs_"
},
{
"path": "spark-queries-tpcds/q17.sql",
"chars": 1502,
"preview": "SELECT\n i_item_id,\n i_item_desc,\n s_state,\n count(ss_quantity) AS store_sales_quantitycount,\n avg(ss_quantity) AS s"
},
{
"path": "spark-queries-tpcds/q18.sql",
"chars": 1077,
"preview": "SELECT\n i_item_id,\n ca_country,\n ca_state,\n ca_county,\n avg(cast(cs_quantity AS DECIMAL(12, 2))) agg1,\n avg(cast(c"
},
{
"path": "spark-queries-tpcds/q19.sql",
"chars": 597,
"preview": "SELECT\n i_brand_id brand_id,\n i_brand brand,\n i_manufact_id,\n i_manufact,\n sum(ss_ext_sales_price) ext_price\nFROM d"
},
{
"path": "spark-queries-tpcds/q2.sql",
"chars": 2108,
"preview": "WITH wscs AS\n( SELECT\n sold_date_sk,\n sales_price\n FROM (SELECT\n ws_sold_date_sk sold_date_sk,\n ws_ext_sale"
},
{
"path": "spark-queries-tpcds/q20.sql",
"chars": 612,
"preview": "SELECT\n i_item_desc,\n i_category,\n i_class,\n i_current_price,\n sum(cs_ext_sales_price) AS itemrevenue,\n sum(cs_ext"
},
{
"path": "spark-queries-tpcds/q21.sql",
"chars": 953,
"preview": "SELECT *\nFROM (\n SELECT\n w_warehouse_name,\n i_item_id,\n sum(CASE WHEN (cast(d_date AS DATE"
},
{
"path": "spark-queries-tpcds/q22.sql",
"chars": 412,
"preview": "SELECT\n i_product_name,\n i_brand,\n i_class,\n i_category,\n avg(inv_quantity_on_hand) qoh\nFROM inventory, date_dim, i"
},
{
"path": "spark-queries-tpcds/q23a.sql",
"chars": 1655,
"preview": "WITH frequent_ss_items AS\n(SELECT\n substr(i_item_desc, 1, 30) itemdesc,\n i_item_sk item_sk,\n d_date solddate,\n "
},
{
"path": "spark-queries-tpcds/q23b.sql",
"chars": 2010,
"preview": "WITH frequent_ss_items AS\n(SELECT\n substr(i_item_desc, 1, 30) itemdesc,\n i_item_sk item_sk,\n d_date solddate,\n "
},
{
"path": "spark-queries-tpcds/q24a.sql",
"chars": 907,
"preview": "WITH ssales AS\n(SELECT\n c_last_name,\n c_first_name,\n s_store_name,\n ca_state,\n s_state,\n i_color,\n "
},
{
"path": "spark-queries-tpcds/q24b.sql",
"chars": 910,
"preview": "WITH ssales AS\n(SELECT\n c_last_name,\n c_first_name,\n s_store_name,\n ca_state,\n s_state,\n i_color,\n "
}
]
// ... and 102 more files (download for full content)
About this extraction
This page contains the full source code of the hortonworks/hive-testbench GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 302 files (473.3 KB), approximately 144.9k tokens, and a symbol index with 95 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.