Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
[NSE-108] Add end-to-end test suite against TPC-DS (#109)
Browse files Browse the repository at this point in the history
Close #108
  • Loading branch information
zhztheplayer authored Feb 18, 2021
1 parent 2576a03 commit 2df91d6
Show file tree
Hide file tree
Showing 136 changed files with 5,926 additions and 350 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/report_ram_log.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Run Maven tests
run: |
cd core/
mvn test -B -DmembersOnlySuites=com.intel.oap.tpch -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DtagsToInclude=com.intel.oap.tags.CommentOnContextPR -Dexec.skip=true
mvn test -B -DmembersOnlySuites=com.intel.oap.tpc.h -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DtagsToInclude=com.intel.oap.tags.CommentOnContextPR -Dexec.skip=true
env:
MAVEN_OPTS: "-Xmx2048m"
COMMENT_CONTENT_PATH: "/tmp/comment.md"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/tpch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Run Maven tests - BHJ
run: |
cd core/
mvn test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DmembersOnlySuites=com.intel.oap.tpch -DtagsToInclude=com.intel.oap.tags.BroadcastHashJoinMode -DargLine="-Xmx1G -XX:MaxDirectMemorySize=500M -Dio.netty.allocator.numDirectArena=1"
mvn test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DmembersOnlySuites=com.intel.oap.tpc.h -DtagsToInclude=com.intel.oap.tags.BroadcastHashJoinMode -DargLine="-Xmx1G -XX:MaxDirectMemorySize=500M -Dio.netty.allocator.numDirectArena=1"
env:
MALLOC_ARENA_MAX: "4"
MAVEN_OPTS: "-Xmx1G"
Expand All @@ -66,7 +66,7 @@ jobs:
- name: Run Maven tests - SMJ
run: |
cd core/
mvn test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DmembersOnlySuites=com.intel.oap.tpch -DtagsToInclude=com.intel.oap.tags.SortMergeJoinMode -DargLine="-Xmx1G -XX:MaxDirectMemorySize=500M -Dio.netty.allocator.numDirectArena=1"
mvn test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -DmembersOnlySuites=com.intel.oap.tpc.h -DtagsToInclude=com.intel.oap.tags.SortMergeJoinMode -DargLine="-Xmx1G -XX:MaxDirectMemorySize=500M -Dio.netty.allocator.numDirectArena=1"
env:
MALLOC_ARENA_MAX: "4"
MAVEN_OPTS: "-Xmx1G"
Expand All @@ -86,3 +86,4 @@ jobs:
with:
name: pr_event
path: ${{steps.output-envs.outputs.event_path}}

10 changes: 8 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,15 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.prestosql.tpch</groupId>
<groupId>io.trino.tpch</groupId>
<artifactId>tpch</artifactId>
<version>1.0</version>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.trino.tpcds</groupId>
<artifactId>tpcds</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.oap.tpch;
package com.intel.oap.tpc;

import com.intel.oap.vectorized.JniUtils;

Expand All @@ -35,10 +35,10 @@ public class MallocUtils {
* Visible for testing: Try turning back allocated native memory to OS. This might have no effect
* when using Jemalloc.
*/
static native void mallocTrim();
public static native void mallocTrim();

/**
* Visible for testing: Print malloc statistics.
*/
static native void mallocStats();
public static native void mallocStats();
}
19 changes: 19 additions & 0 deletions core/src/test/resources/tpcds-queries-double/q1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
WITH customer_total_return AS
( SELECT
sr_customer_sk AS ctr_customer_sk,
sr_store_sk AS ctr_store_sk,
sum(sr_return_amt) 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 = 'TN'
AND ctr1.ctr_customer_sk = c_customer_sk
ORDER BY c_customer_id
LIMIT 100
57 changes: 57 additions & 0 deletions core/src/test/resources/tpcds-queries-double/q10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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 ('Rush County', 'Toole County', 'Jefferson County',
'Dona Ana County', 'La Porte 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 = 2002 AND
d_moy BETWEEN 1 AND 1 + 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 = 2002 AND
d_moy BETWEEN 1 AND 1 + 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 = 2002 AND
d_moy BETWEEN 1 AND 1 + 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
68 changes: 68 additions & 0 deletions core/src/test/resources/tpcds-queries-double/q11.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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
, d_year
, 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_preferred_cust_flag
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 = 2001
AND t_s_secyear.dyear = 2001 + 1
AND t_w_firstyear.dyear = 2001
AND t_w_secyear.dyear = 2001 + 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 NULL END
> CASE WHEN t_s_firstyear.year_total > 0
THEN t_s_secyear.year_total / t_s_firstyear.year_total
ELSE NULL END
ORDER BY t_s_secyear.customer_preferred_cust_flag
LIMIT 100
22 changes: 22 additions & 0 deletions core/src/test/resources/tpcds-queries-double/q12.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SELECT
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 ('Sports', 'Books', 'Home')
AND ws_sold_date_sk = d_date_sk
AND d_date BETWEEN cast('1999-02-22' AS DATE)
AND (cast('1999-02-22' AS DATE) + INTERVAL 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
49 changes: 49 additions & 0 deletions core/src/test/resources/tpcds-queries-double/q13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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 = 'M'
AND cd_education_status = 'Advanced Degree'
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 = 'S'
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 = 'W'
AND cd_education_status = '2 yr Degree'
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', 'OH', 'TX')
AND ss_net_profit BETWEEN 100 AND 200
) OR
(ss_addr_sk = ca_address_sk
AND ca_country = 'United States'
AND ca_state IN ('OR', 'NM', 'KY')
AND ss_net_profit BETWEEN 150 AND 300
) OR
(ss_addr_sk = ca_address_sk
AND ca_country = 'United States'
AND ca_state IN ('VA', 'TX', 'MS')
AND ss_net_profit BETWEEN 50 AND 250
))
Loading

0 comments on commit 2df91d6

Please sign in to comment.