Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static Map<String, String> getNativeWorkerSystemProperties()

/**
* Creates all tables for local testing, except for bench tables.
*
* @param queryRunner
*/
public static void createAllTables(QueryRunner queryRunner)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.nativeworker;

import com.facebook.presto.testing.ExpectedQueryRunner;
import com.facebook.presto.testing.QueryRunner;

public class TestPrestoNativeTpcdsQueriesParquetUsingThrift
extends AbstractTestNativeTpcdsQueries
{
@Override
protected QueryRunner createQueryRunner()
throws Exception
{
return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(true, "PARQUET");
}

@Override
protected ExpectedQueryRunner createExpectedQueryRunner()
throws Exception
{
this.storageFormat = "PARQUET";
return PrestoNativeQueryRunnerUtils.createJavaQueryRunner("PARQUET");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
WITH
customer_total_return AS (
SELECT
"sr_customer_sk" "ctr_customer_sk"
, "sr_store_sk" "ctr_store_sk"
, "sum"("sr_return_amt") "ctr_total_return"
FROM
${database}.${schema}.store_returns
, ${database}.${schema}.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
, ${database}.${schema}.store
, ${database}.${schema}.customer
WHERE ("ctr1"."ctr_total_return" > (
SELECT ("avg"("ctr_total_return") * DECIMAL '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" ASC
LIMIT 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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
${database}.${schema}.web_sales
)
UNION ALL (
SELECT
"cs_sold_date_sk" "sold_date_sk"
, "cs_ext_sales_price" "sales_price"
FROM
${database}.${schema}.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
, ${database}.${schema}.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
, ${database}.${schema}.date_dim
WHERE ("date_dim"."d_week_seq" = "wswscs"."d_week_seq")
AND ("d_year" = 2001)
) 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
, ${database}.${schema}.date_dim
WHERE ("date_dim"."d_week_seq" = "wswscs"."d_week_seq")
AND ("d_year" = (2001 + 1))
) z
WHERE ("d_week_seq1" = ("d_week_seq2" - 53))
ORDER BY "d_week_seq1" ASC
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SELECT
"dt"."d_year"
, "item"."i_brand_id" "brand_id"
, "item"."i_brand" "brand"
, "sum"("ss_ext_sales_price") "sum_agg"
FROM
${database}.${schema}.date_dim dt
, ${database}.${schema}.store_sales
, ${database}.${schema}.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" = 128)
AND ("dt"."d_moy" = 11)
GROUP BY "dt"."d_year", "item"."i_brand", "item"."i_brand_id"
ORDER BY "dt"."d_year" ASC, "sum_agg" DESC, "brand_id" ASC
LIMIT 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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
${database}.${schema}.customer
, ${database}.${schema}.store_sales
, ${database}.${schema}.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
${database}.${schema}.customer
, ${database}.${schema}.catalog_sales
, ${database}.${schema}.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
${database}.${schema}.customer
, ${database}.${schema}.web_sales
, ${database}.${schema}.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_preferred_cust_flag"
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" = 2001)
AND ("t_s_secyear"."dyear" = (2001 + 1))
AND ("t_c_firstyear"."dyear" = 2001)
AND ("t_c_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_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" ASC, "t_s_secyear"."customer_first_name" ASC, "t_s_secyear"."customer_last_name" ASC, "t_s_secyear"."customer_preferred_cust_flag" ASC
LIMIT 100
Loading