[enhance](Tools) update tpch tools (#24291)
update tpch tools: 1) extend data scale to sf1/sf100/sf1000/sf10000 2) add table schema, sql, opt config for all different scale. 3) refine result output
This commit is contained in:
@ -37,7 +37,7 @@ follow the steps below:
|
||||
|
||||
### 4. create tpc-ds tables. modify `conf/doris-cluster.conf` to specify doris info, then run script below.
|
||||
|
||||
./bin/create-tpcds-tables.sh
|
||||
./bin/create-tpcds-tables.sh -s 1
|
||||
|
||||
### 5. load tpc-ds data. use -h for help.
|
||||
|
||||
@ -45,4 +45,4 @@ follow the steps below:
|
||||
|
||||
### 6. run tpc-ds queries.
|
||||
|
||||
./bin/run-tpcds-queries.sh
|
||||
./bin/run-tpcds-queries.sh -s 1
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
# under the License.
|
||||
|
||||
##############################################################
|
||||
# This script is used to run TPC-DS 103 queries
|
||||
# This script is used to run TPC-DS 99 queries
|
||||
##############################################################
|
||||
|
||||
set -eo pipefail
|
||||
@ -131,33 +131,39 @@ run_sql "show variables;"
|
||||
echo '============================================'
|
||||
run_sql "show table status;"
|
||||
echo '============================================'
|
||||
start=$(date +%s)
|
||||
run_sql "analyze database ${DB} with sync;"
|
||||
end=$(date +%s)
|
||||
totalTime=$((end - start))
|
||||
echo "analyze database ${DB} with sync total time: ${totalTime} s"
|
||||
echo '============================================'
|
||||
echo "Time Unit: ms"
|
||||
|
||||
RESULT_DIR="${CURDIR}/result"
|
||||
rm "${RESULT_DIR}"
|
||||
mkdir -p "${RESULT_DIR}"
|
||||
touch result.csv
|
||||
cold_run_sum=0
|
||||
best_hot_run_sum=0
|
||||
i=1
|
||||
for i in {1..99}; do
|
||||
cold=0
|
||||
hot1=0
|
||||
hot2=0
|
||||
echo -ne "query${i}\t" | tee -a result.csv
|
||||
start=$(date +%s%3N)
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCDS_QUERIES_DIR}"/query"${i}".sql >/dev/null
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCDS_QUERIES_DIR}"/query"${i}".sql >"${RESULT_DIR}"/result"${i}".out 2>"${RESULT_DIR}"/result"${i}".log
|
||||
end=$(date +%s%3N)
|
||||
cold=$((end - start))
|
||||
echo -ne "${cold}\t" | tee -a result.csv
|
||||
|
||||
start=$(date +%s%3N)
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCDS_QUERIES_DIR}"/query"${i}".sql >/dev/null
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCDS_QUERIES_DIR}"/query"${i}".sql >"${RESULT_DIR}"/result"${i}".out 2>"${RESULT_DIR}"/result"${i}".log
|
||||
end=$(date +%s%3N)
|
||||
hot1=$((end - start))
|
||||
echo -ne "${hot1}\t" | tee -a result.csv
|
||||
|
||||
start=$(date +%s%3N)
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCDS_QUERIES_DIR}"/query"${i}".sql >/dev/null
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCDS_QUERIES_DIR}"/query"${i}".sql >"${RESULT_DIR}"/result"${i}".out 2>"${RESULT_DIR}"/result"${i}".log
|
||||
end=$(date +%s%3N)
|
||||
hot2=$((end - start))
|
||||
echo -ne "${hot2}\t" | tee -a result.csv
|
||||
|
||||
@ -32,7 +32,7 @@ follow the steps below:
|
||||
|
||||
### 3. create tpc-h tables. modify `conf/doris-cluster.conf` to specify doris info, then run script below.
|
||||
|
||||
./bin/create-tpch-tables.sh
|
||||
./bin/create-tpch-tables.sh -s 1
|
||||
|
||||
### 4. load tpc-h data. use -h for help.
|
||||
|
||||
@ -40,8 +40,10 @@ follow the steps below:
|
||||
|
||||
### 5. run tpc-h queries.
|
||||
|
||||
./bin/run-tpch-queries.sh
|
||||
./bin/run-tpch-queries.sh -s 1
|
||||
|
||||
NOTICE: At present, Doris's query optimizer and statistical information functions are not complete, so we rewrite some queries in TPC-H to adapt to Doris' execution framework, but it does not affect the correctness of the results. The rewritten SQL is marked with "Modified" in the corresponding .sql file.
|
||||
|
||||
A new query optimizer will be released in subsequent releases.
|
||||
|
||||
Currently, differnt scales use the same suite of query sqls.
|
||||
|
||||
@ -42,10 +42,12 @@ Usage: $0
|
||||
OPTS=$(getopt \
|
||||
-n "$0" \
|
||||
-o '' \
|
||||
-o 'hs:' \
|
||||
-- "$@")
|
||||
|
||||
eval set -- "${OPTS}"
|
||||
HELP=0
|
||||
SCALE_FACTOR=1
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
usage
|
||||
@ -57,6 +59,10 @@ while true; do
|
||||
HELP=1
|
||||
shift
|
||||
;;
|
||||
-s)
|
||||
SCALE_FACTOR=$2
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -72,6 +78,11 @@ if [[ "${HELP}" -eq 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [[ ${SCALE_FACTOR} -ne 1 ]] && [[ ${SCALE_FACTOR} -ne 100 ]] && [[ ${SCALE_FACTOR} -ne 1000 ]] && [[ ${SCALE_FACTOR} -ne 10000 ]]; then
|
||||
echo "${SCALE_FACTOR} scale is not supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
check_prerequest() {
|
||||
local CMD=$1
|
||||
local NAME=$2
|
||||
@ -93,7 +104,20 @@ echo "DB: ${DB}"
|
||||
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -e "CREATE DATABASE IF NOT EXISTS ${DB}"
|
||||
|
||||
echo "Run SQLs from ${CURDIR}/create-tpch-tables.sql"
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" <"${CURDIR}"/../ddl/create-tpch-tables.sql
|
||||
if [[ ${SCALE_FACTOR} -eq 1 ]]; then
|
||||
echo "Run SQLs from ${CURDIR}/../ddl/create-tpch-tables.sql"
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" <"${CURDIR}"/../ddl/create-tpch-tables.sql
|
||||
elif [[ ${SCALE_FACTOR} -eq 100 ]]; then
|
||||
echo "Run SQLs from ${CURDIR}/../ddl/create-tpch-tables-sf100.sql"
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" <"${CURDIR}"/../ddl/create-tpch-tables-sf100.sql
|
||||
elif [[ ${SCALE_FACTOR} -eq 1000 ]]; then
|
||||
echo "Run SQLs from ${CURDIR}/../ddl/create-tpch-tables-sf1000.sql"
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" <"${CURDIR}"/../ddl/create-tpch-tables-sf1000.sql
|
||||
elif [[ ${SCALE_FACTOR} -eq 10000 ]]; then
|
||||
echo "Run SQLs from ${CURDIR}/../ddl/create-tpch-tables-sf10000.sql"
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" <"${CURDIR}"/../ddl/create-tpch-tables-sf10000.sql
|
||||
else
|
||||
echo "${SCALE_FACTOR} scale is NOT supported currently"
|
||||
fi
|
||||
|
||||
echo "tpch tables has been created"
|
||||
|
||||
@ -108,6 +108,7 @@ check_prerequest "curl --version" "curl"
|
||||
source "${CURDIR}/../conf/doris-cluster.conf"
|
||||
export MYSQL_PWD=${PASSWORD}
|
||||
|
||||
echo "Parallelism: ${PARALLEL}"
|
||||
echo "FE_HOST: ${FE_HOST}"
|
||||
echo "FE_HTTP_PORT: ${FE_HTTP_PORT}"
|
||||
echo "USER: ${USER}"
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
# under the License.
|
||||
|
||||
##############################################################
|
||||
# This script is used to create TPC-H tables
|
||||
# This script is used to run TPC-H 22 queries
|
||||
##############################################################
|
||||
|
||||
set -eo pipefail
|
||||
@ -29,7 +29,6 @@ ROOT=$(
|
||||
)
|
||||
|
||||
CURDIR="${ROOT}"
|
||||
QUERIES_DIR="${CURDIR}/../queries"
|
||||
|
||||
usage() {
|
||||
echo "
|
||||
@ -43,10 +42,12 @@ Usage: $0
|
||||
OPTS=$(getopt \
|
||||
-n "$0" \
|
||||
-o '' \
|
||||
-o 'hs:' \
|
||||
-- "$@")
|
||||
|
||||
eval set -- "${OPTS}"
|
||||
HELP=0
|
||||
SCALE_FACTOR=1
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
usage
|
||||
@ -58,6 +59,10 @@ while true; do
|
||||
HELP=1
|
||||
shift
|
||||
;;
|
||||
-s)
|
||||
SCALE_FACTOR=$2
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -73,6 +78,27 @@ if [[ "${HELP}" -eq 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [[ ${SCALE_FACTOR} -eq 1 ]]; then
|
||||
echo "Running tpch sf 1 queries"
|
||||
TPCH_QUERIES_DIR="${CURDIR}/../queries/sf1"
|
||||
TPCH_OPT_CONF="${CURDIR}/../conf/opt/opt_sf1.sql"
|
||||
elif [[ ${SCALE_FACTOR} -eq 100 ]]; then
|
||||
echo "Running tpch sf 100 queries"
|
||||
TPCH_QUERIES_DIR="${CURDIR}/../queries/sf100"
|
||||
TPCH_OPT_CONF="${CURDIR}/../conf/opt/opt_sf100.sql"
|
||||
elif [[ ${SCALE_FACTOR} -eq 1000 ]]; then
|
||||
echo "Running tpch sf 1000 queries"
|
||||
TPCH_QUERIES_DIR="${CURDIR}/../queries/sf1000"
|
||||
TPCH_OPT_CONF="${CURDIR}/../conf/opt/opt_sf1000.sql"
|
||||
elif [[ ${SCALE_FACTOR} -eq 10000 ]]; then
|
||||
echo "Running tpch sf 10000 queries"
|
||||
TPCH_QUERIES_DIR="${CURDIR}/../queries/sf10000"
|
||||
TPCH_OPT_CONF="${CURDIR}/../conf/opt/opt_sf10000.sql"
|
||||
else
|
||||
echo "${SCALE_FACTOR} scale is NOT support currently."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
check_prerequest() {
|
||||
local CMD=$1
|
||||
local NAME=$2
|
||||
@ -85,73 +111,72 @@ check_prerequest() {
|
||||
check_prerequest "mysql --version" "mysql"
|
||||
|
||||
source "${CURDIR}/../conf/doris-cluster.conf"
|
||||
export MYSQL_PWD=${PASSWORD}
|
||||
export MYSQL_PWD=${PASSWORD:-}
|
||||
|
||||
echo "FE_HOST: ${FE_HOST}"
|
||||
echo "FE_QUERY_PORT: ${FE_QUERY_PORT}"
|
||||
echo "USER: ${USER}"
|
||||
echo "DB: ${DB}"
|
||||
echo "FE_HOST: ${FE_HOST:='127.0.0.1'}"
|
||||
echo "FE_QUERY_PORT: ${FE_QUERY_PORT:='9030'}"
|
||||
echo "USER: ${USER:='root'}"
|
||||
echo "DB: ${DB:='tpch'}"
|
||||
echo "Time Unit: ms"
|
||||
|
||||
run_sql() {
|
||||
echo "$*"
|
||||
mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e "$*"
|
||||
}
|
||||
run_sql "set global query_timeout=900;"
|
||||
|
||||
echo '============================================'
|
||||
run_sql "source ${TPCH_OPT_CONF};"
|
||||
echo '============================================'
|
||||
run_sql "show variables;"
|
||||
echo '============================================'
|
||||
run_sql "show table status;"
|
||||
echo '============================================'
|
||||
start=$(date +%s)
|
||||
run_sql "analyze table lineitem with sync;"
|
||||
run_sql "analyze table orders with sync;"
|
||||
run_sql "analyze table partsupp with sync;"
|
||||
run_sql "analyze table part with sync;"
|
||||
run_sql "analyze table customer with sync;"
|
||||
run_sql "analyze table supplier with sync;"
|
||||
run_sql "analyze table nation with sync;"
|
||||
run_sql "analyze table region with sync;"
|
||||
run_sql "analyze database ${DB} with sync;"
|
||||
end=$(date +%s)
|
||||
totalTime=$((end - start))
|
||||
echo "analyze database ${DB} with sync total time: ${totalTime} s"
|
||||
echo '============================================'
|
||||
echo "Time Unit: ms"
|
||||
|
||||
RESULT_DIR="${CURDIR}/result"
|
||||
rm "${RESULT_DIR}"
|
||||
mkdir -p "${RESULT_DIR}"
|
||||
touch result.csv
|
||||
cold_run_sum=0
|
||||
best_hot_run_sum=0
|
||||
for i in $(seq 1 22); do
|
||||
for i in {1..22}; do
|
||||
cold=0
|
||||
hot1=0
|
||||
hot2=0
|
||||
|
||||
echo -ne "q${i}\t" | tee -a result.csv
|
||||
|
||||
start=$(date +%s%3N)
|
||||
mysql -h"${FE_HOST}" -u "${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${QUERIES_DIR}/q${i}.sql" >/dev/null
|
||||
mysql -h"${FE_HOST}" -u "${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCH_QUERIES_DIR}"/q"${i}".sql >"${RESULT_DIR}"/result"${i}".out 2>"${RESULT_DIR}"/result"${i}".log
|
||||
end=$(date +%s%3N)
|
||||
cold=$((end - start))
|
||||
echo -ne "${cold}\t" | tee -a result.csv
|
||||
|
||||
start=$(date +%s%3N)
|
||||
mysql -h"${FE_HOST}" -u "${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${QUERIES_DIR}/q${i}.sql" >/dev/null
|
||||
mysql -h"${FE_HOST}" -u "${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCH_QUERIES_DIR}"/q"${i}".sql >"${RESULT_DIR}"/result"${i}".out 2>"${RESULT_DIR}"/result"${i}".log
|
||||
end=$(date +%s%3N)
|
||||
hot1=$((end - start))
|
||||
echo -ne "${hot1}\t" | tee -a result.csv
|
||||
|
||||
start=$(date +%s%3N)
|
||||
mysql -h"${FE_HOST}" -u "${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${QUERIES_DIR}/q${i}.sql" >/dev/null
|
||||
mysql -h"${FE_HOST}" -u "${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" --comments <"${TPCH_QUERIES_DIR}"/q"${i}".sql >"${RESULT_DIR}"/result"${i}".out 2>"${RESULT_DIR}"/result"${i}".log
|
||||
end=$(date +%s%3N)
|
||||
hot2=$((end - start))
|
||||
echo -ne "${hot2}" | tee -a result.csv
|
||||
|
||||
echo "" | tee -a result.csv
|
||||
echo -ne "${hot2}\t" | tee -a result.csv
|
||||
|
||||
cold_run_sum=$((cold_run_sum + cold))
|
||||
if [[ ${hot1} -lt ${hot2} ]]; then
|
||||
best_hot_run_sum=$((best_hot_run_sum + hot1))
|
||||
echo -ne "${hot1}" | tee -a result.csv
|
||||
echo "" | tee -a result.csv
|
||||
else
|
||||
best_hot_run_sum=$((best_hot_run_sum + hot2))
|
||||
echo -ne "${hot2}" | tee -a result.csv
|
||||
echo "" | tee -a result.csv
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
6
tools/tpch-tools/conf/opt/opt_sf1.sql
Normal file
6
tools/tpch-tools/conf/opt/opt_sf1.sql
Normal file
@ -0,0 +1,6 @@
|
||||
set global experimental_enable_nereids_planner=true;
|
||||
set global experimental_enable_pipeline_engine=true;
|
||||
set global enable_runtime_filter_prune=false;
|
||||
set global runtime_filter_wait_time_ms=1000;
|
||||
set global enable_fallback_to_original_planner=false;
|
||||
set global forbid_unknown_col_stats=true;
|
||||
7
tools/tpch-tools/conf/opt/opt_sf100.sql
Normal file
7
tools/tpch-tools/conf/opt/opt_sf100.sql
Normal file
@ -0,0 +1,7 @@
|
||||
set global experimental_enable_nereids_planner=true;
|
||||
set global experimental_enable_pipeline_engine=true;
|
||||
set global enable_runtime_filter_prune=false;
|
||||
set global runtime_filter_wait_time_ms=10000;
|
||||
set global enable_fallback_to_original_planner=false;
|
||||
set global forbid_unknown_col_stats=true;
|
||||
set global query_timeout=1000;
|
||||
7
tools/tpch-tools/conf/opt/opt_sf1000.sql
Normal file
7
tools/tpch-tools/conf/opt/opt_sf1000.sql
Normal file
@ -0,0 +1,7 @@
|
||||
set global experimental_enable_nereids_planner=true;
|
||||
set global experimental_enable_pipeline_engine=true;
|
||||
set global enable_runtime_filter_prune=false;
|
||||
set global runtime_filter_wait_time_ms=10000;
|
||||
set global enable_fallback_to_original_planner=false;
|
||||
set global forbid_unknown_col_stats=true;
|
||||
set global query_timeout=1000;
|
||||
7
tools/tpch-tools/conf/opt/opt_sf10000.sql
Normal file
7
tools/tpch-tools/conf/opt/opt_sf10000.sql
Normal file
@ -0,0 +1,7 @@
|
||||
set global experimental_enable_nereids_planner=true;
|
||||
set global experimental_enable_pipeline_engine=true;
|
||||
set global enable_runtime_filter_prune=false;
|
||||
set global runtime_filter_wait_time_ms=100000;
|
||||
set global enable_fallback_to_original_planner=false;
|
||||
set global forbid_unknown_col_stats=true;
|
||||
set global query_timeout=1000;
|
||||
174
tools/tpch-tools/ddl/create-tpch-tables-sf100.sql
Normal file
174
tools/tpch-tools/ddl/create-tpch-tables-sf100.sql
Normal file
@ -0,0 +1,174 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
drop table if exists lineitem;
|
||||
CREATE TABLE lineitem (
|
||||
l_shipdate DATE NOT NULL,
|
||||
l_orderkey bigint NOT NULL,
|
||||
l_linenumber int not null,
|
||||
l_partkey int NOT NULL,
|
||||
l_suppkey int not null,
|
||||
l_quantity decimal(15, 2) NOT NULL,
|
||||
l_extendedprice decimal(15, 2) NOT NULL,
|
||||
l_discount decimal(15, 2) NOT NULL,
|
||||
l_tax decimal(15, 2) NOT NULL,
|
||||
l_returnflag VARCHAR(1) NOT NULL,
|
||||
l_linestatus VARCHAR(1) NOT NULL,
|
||||
l_commitdate DATE NOT NULL,
|
||||
l_receiptdate DATE NOT NULL,
|
||||
l_shipinstruct VARCHAR(25) NOT NULL,
|
||||
l_shipmode VARCHAR(10) NOT NULL,
|
||||
l_comment VARCHAR(44) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`l_shipdate`, `l_orderkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 96
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists orders;
|
||||
CREATE TABLE orders (
|
||||
o_orderkey bigint NOT NULL,
|
||||
o_orderdate DATE NOT NULL,
|
||||
o_custkey int NOT NULL,
|
||||
o_orderstatus VARCHAR(1) NOT NULL,
|
||||
o_totalprice decimal(15, 2) NOT NULL,
|
||||
o_orderpriority VARCHAR(15) NOT NULL,
|
||||
o_clerk VARCHAR(15) NOT NULL,
|
||||
o_shippriority int NOT NULL,
|
||||
o_comment VARCHAR(79) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`o_orderkey`, `o_orderdate`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 96
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists partsupp;
|
||||
CREATE TABLE partsupp (
|
||||
ps_partkey int NOT NULL,
|
||||
ps_suppkey int NOT NULL,
|
||||
ps_availqty int NOT NULL,
|
||||
ps_supplycost decimal(15, 2) NOT NULL,
|
||||
ps_comment VARCHAR(199) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`ps_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`ps_partkey`) BUCKETS 24
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists part;
|
||||
CREATE TABLE part (
|
||||
p_partkey int NOT NULL,
|
||||
p_name VARCHAR(55) NOT NULL,
|
||||
p_mfgr VARCHAR(25) NOT NULL,
|
||||
p_brand VARCHAR(10) NOT NULL,
|
||||
p_type VARCHAR(25) NOT NULL,
|
||||
p_size int NOT NULL,
|
||||
p_container VARCHAR(10) NOT NULL,
|
||||
p_retailprice decimal(15, 2) NOT NULL,
|
||||
p_comment VARCHAR(23) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`p_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 24
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists customer;
|
||||
CREATE TABLE customer (
|
||||
c_custkey int NOT NULL,
|
||||
c_name VARCHAR(25) NOT NULL,
|
||||
c_address VARCHAR(40) NOT NULL,
|
||||
c_nationkey int NOT NULL,
|
||||
c_phone VARCHAR(15) NOT NULL,
|
||||
c_acctbal decimal(15, 2) NOT NULL,
|
||||
c_mktsegment VARCHAR(10) NOT NULL,
|
||||
c_comment VARCHAR(117) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`c_custkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 24
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists supplier;
|
||||
CREATE TABLE supplier (
|
||||
s_suppkey int NOT NULL,
|
||||
s_name VARCHAR(25) NOT NULL,
|
||||
s_address VARCHAR(40) NOT NULL,
|
||||
s_nationkey int NOT NULL,
|
||||
s_phone VARCHAR(15) NOT NULL,
|
||||
s_acctbal decimal(15, 2) NOT NULL,
|
||||
s_comment VARCHAR(101) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`s_suppkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 12
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists nation;
|
||||
CREATE TABLE `nation` (
|
||||
`n_nationkey` int(11) NOT NULL,
|
||||
`n_name` varchar(25) NOT NULL,
|
||||
`n_regionkey` int(11) NOT NULL,
|
||||
`n_comment` varchar(152) NULL
|
||||
) ENGINE=OLAP
|
||||
DUPLICATE KEY(`N_NATIONKEY`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`N_NATIONKEY`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists region;
|
||||
CREATE TABLE region (
|
||||
r_regionkey int NOT NULL,
|
||||
r_name VARCHAR(25) NOT NULL,
|
||||
r_comment VARCHAR(152)
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`r_regionkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`r_regionkey`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop view if exists revenue0;
|
||||
create view revenue0 (supplier_no, total_revenue) as
|
||||
select
|
||||
l_suppkey,
|
||||
sum(l_extendedprice * (1 - l_discount))
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate >= date '1996-01-01'
|
||||
and l_shipdate < date '1996-01-01' + interval '3' month
|
||||
group by
|
||||
l_suppkey;
|
||||
174
tools/tpch-tools/ddl/create-tpch-tables-sf1000.sql
Normal file
174
tools/tpch-tools/ddl/create-tpch-tables-sf1000.sql
Normal file
@ -0,0 +1,174 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
drop table if exists lineitem;
|
||||
CREATE TABLE lineitem (
|
||||
l_shipdate DATE NOT NULL,
|
||||
l_orderkey bigint NOT NULL,
|
||||
l_linenumber int not null,
|
||||
l_partkey int NOT NULL,
|
||||
l_suppkey int not null,
|
||||
l_quantity decimal(15, 2) NOT NULL,
|
||||
l_extendedprice decimal(15, 2) NOT NULL,
|
||||
l_discount decimal(15, 2) NOT NULL,
|
||||
l_tax decimal(15, 2) NOT NULL,
|
||||
l_returnflag VARCHAR(1) NOT NULL,
|
||||
l_linestatus VARCHAR(1) NOT NULL,
|
||||
l_commitdate DATE NOT NULL,
|
||||
l_receiptdate DATE NOT NULL,
|
||||
l_shipinstruct VARCHAR(25) NOT NULL,
|
||||
l_shipmode VARCHAR(10) NOT NULL,
|
||||
l_comment VARCHAR(44) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`l_shipdate`, `l_orderkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 768
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists orders;
|
||||
CREATE TABLE orders (
|
||||
o_orderkey bigint NOT NULL,
|
||||
o_orderdate DATE NOT NULL,
|
||||
o_custkey int NOT NULL,
|
||||
o_orderstatus VARCHAR(1) NOT NULL,
|
||||
o_totalprice decimal(15, 2) NOT NULL,
|
||||
o_orderpriority VARCHAR(15) NOT NULL,
|
||||
o_clerk VARCHAR(15) NOT NULL,
|
||||
o_shippriority int NOT NULL,
|
||||
o_comment VARCHAR(79) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`o_orderkey`, `o_orderdate`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 768
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists partsupp;
|
||||
CREATE TABLE partsupp (
|
||||
ps_partkey int NOT NULL,
|
||||
ps_suppkey int NOT NULL,
|
||||
ps_availqty int NOT NULL,
|
||||
ps_supplycost decimal(15, 2) NOT NULL,
|
||||
ps_comment VARCHAR(199) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`ps_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`ps_partkey`) BUCKETS 192
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists part;
|
||||
CREATE TABLE part (
|
||||
p_partkey int NOT NULL,
|
||||
p_name VARCHAR(55) NOT NULL,
|
||||
p_mfgr VARCHAR(25) NOT NULL,
|
||||
p_brand VARCHAR(10) NOT NULL,
|
||||
p_type VARCHAR(25) NOT NULL,
|
||||
p_size int NOT NULL,
|
||||
p_container VARCHAR(10) NOT NULL,
|
||||
p_retailprice decimal(15, 2) NOT NULL,
|
||||
p_comment VARCHAR(23) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`p_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 192
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists customer;
|
||||
CREATE TABLE customer (
|
||||
c_custkey int NOT NULL,
|
||||
c_name VARCHAR(25) NOT NULL,
|
||||
c_address VARCHAR(40) NOT NULL,
|
||||
c_nationkey int NOT NULL,
|
||||
c_phone VARCHAR(15) NOT NULL,
|
||||
c_acctbal decimal(15, 2) NOT NULL,
|
||||
c_mktsegment VARCHAR(10) NOT NULL,
|
||||
c_comment VARCHAR(117) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`c_custkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 192
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists supplier;
|
||||
CREATE TABLE supplier (
|
||||
s_suppkey int NOT NULL,
|
||||
s_name VARCHAR(25) NOT NULL,
|
||||
s_address VARCHAR(40) NOT NULL,
|
||||
s_nationkey int NOT NULL,
|
||||
s_phone VARCHAR(15) NOT NULL,
|
||||
s_acctbal decimal(15, 2) NOT NULL,
|
||||
s_comment VARCHAR(101) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`s_suppkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 24
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists nation;
|
||||
CREATE TABLE `nation` (
|
||||
`n_nationkey` int(11) NOT NULL,
|
||||
`n_name` varchar(25) NOT NULL,
|
||||
`n_regionkey` int(11) NOT NULL,
|
||||
`n_comment` varchar(152) NULL
|
||||
) ENGINE=OLAP
|
||||
DUPLICATE KEY(`N_NATIONKEY`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`N_NATIONKEY`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists region;
|
||||
CREATE TABLE region (
|
||||
r_regionkey int NOT NULL,
|
||||
r_name VARCHAR(25) NOT NULL,
|
||||
r_comment VARCHAR(152)
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`r_regionkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`r_regionkey`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop view if exists revenue0;
|
||||
create view revenue0 (supplier_no, total_revenue) as
|
||||
select
|
||||
l_suppkey,
|
||||
sum(l_extendedprice * (1 - l_discount))
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate >= date '1996-01-01'
|
||||
and l_shipdate < date '1996-01-01' + interval '3' month
|
||||
group by
|
||||
l_suppkey;
|
||||
174
tools/tpch-tools/ddl/create-tpch-tables-sf10000.sql
Normal file
174
tools/tpch-tools/ddl/create-tpch-tables-sf10000.sql
Normal file
@ -0,0 +1,174 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
drop table if exists lineitem;
|
||||
CREATE TABLE lineitem (
|
||||
l_shipdate DATE NOT NULL,
|
||||
l_orderkey bigint NOT NULL,
|
||||
l_linenumber int not null,
|
||||
l_partkey int NOT NULL,
|
||||
l_suppkey int not null,
|
||||
l_quantity decimal(15, 2) NOT NULL,
|
||||
l_extendedprice decimal(15, 2) NOT NULL,
|
||||
l_discount decimal(15, 2) NOT NULL,
|
||||
l_tax decimal(15, 2) NOT NULL,
|
||||
l_returnflag VARCHAR(1) NOT NULL,
|
||||
l_linestatus VARCHAR(1) NOT NULL,
|
||||
l_commitdate DATE NOT NULL,
|
||||
l_receiptdate DATE NOT NULL,
|
||||
l_shipinstruct VARCHAR(25) NOT NULL,
|
||||
l_shipmode VARCHAR(10) NOT NULL,
|
||||
l_comment VARCHAR(44) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`l_shipdate`, `l_orderkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 6144
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists orders;
|
||||
CREATE TABLE orders (
|
||||
o_orderkey bigint NOT NULL,
|
||||
o_orderdate DATE NOT NULL,
|
||||
o_custkey int NOT NULL,
|
||||
o_orderstatus VARCHAR(1) NOT NULL,
|
||||
o_totalprice decimal(15, 2) NOT NULL,
|
||||
o_orderpriority VARCHAR(15) NOT NULL,
|
||||
o_clerk VARCHAR(15) NOT NULL,
|
||||
o_shippriority int NOT NULL,
|
||||
o_comment VARCHAR(79) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`o_orderkey`, `o_orderdate`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 6144
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists partsupp;
|
||||
CREATE TABLE partsupp (
|
||||
ps_partkey int NOT NULL,
|
||||
ps_suppkey int NOT NULL,
|
||||
ps_availqty int NOT NULL,
|
||||
ps_supplycost decimal(15, 2) NOT NULL,
|
||||
ps_comment VARCHAR(199) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`ps_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`ps_partkey`) BUCKETS 1536
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists part;
|
||||
CREATE TABLE part (
|
||||
p_partkey int NOT NULL,
|
||||
p_name VARCHAR(55) NOT NULL,
|
||||
p_mfgr VARCHAR(25) NOT NULL,
|
||||
p_brand VARCHAR(10) NOT NULL,
|
||||
p_type VARCHAR(25) NOT NULL,
|
||||
p_size int NOT NULL,
|
||||
p_container VARCHAR(10) NOT NULL,
|
||||
p_retailprice decimal(15, 2) NOT NULL,
|
||||
p_comment VARCHAR(23) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`p_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 1536
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists customer;
|
||||
CREATE TABLE customer (
|
||||
c_custkey int NOT NULL,
|
||||
c_name VARCHAR(25) NOT NULL,
|
||||
c_address VARCHAR(40) NOT NULL,
|
||||
c_nationkey int NOT NULL,
|
||||
c_phone VARCHAR(15) NOT NULL,
|
||||
c_acctbal decimal(15, 2) NOT NULL,
|
||||
c_mktsegment VARCHAR(10) NOT NULL,
|
||||
c_comment VARCHAR(117) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`c_custkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1536
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists supplier;
|
||||
CREATE TABLE supplier (
|
||||
s_suppkey int NOT NULL,
|
||||
s_name VARCHAR(25) NOT NULL,
|
||||
s_address VARCHAR(40) NOT NULL,
|
||||
s_nationkey int NOT NULL,
|
||||
s_phone VARCHAR(15) NOT NULL,
|
||||
s_acctbal decimal(15, 2) NOT NULL,
|
||||
s_comment VARCHAR(101) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`s_suppkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 96
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists nation;
|
||||
CREATE TABLE `nation` (
|
||||
`n_nationkey` int(11) NOT NULL,
|
||||
`n_name` varchar(25) NOT NULL,
|
||||
`n_regionkey` int(11) NOT NULL,
|
||||
`n_comment` varchar(152) NULL
|
||||
) ENGINE=OLAP
|
||||
DUPLICATE KEY(`N_NATIONKEY`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`N_NATIONKEY`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists region;
|
||||
CREATE TABLE region (
|
||||
r_regionkey int NOT NULL,
|
||||
r_name VARCHAR(25) NOT NULL,
|
||||
r_comment VARCHAR(152)
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`r_regionkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`r_regionkey`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop view if exists revenue0;
|
||||
create view revenue0 (supplier_no, total_revenue) as
|
||||
select
|
||||
l_suppkey,
|
||||
sum(l_extendedprice * (1 - l_discount))
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate >= date '1996-01-01'
|
||||
and l_shipdate < date '1996-01-01' + interval '3' month
|
||||
group by
|
||||
l_suppkey;
|
||||
174
tools/tpch-tools/ddl/create-tpch-tables-sf2000.sql
Normal file
174
tools/tpch-tools/ddl/create-tpch-tables-sf2000.sql
Normal file
@ -0,0 +1,174 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
drop table if exists lineitem;
|
||||
CREATE TABLE lineitem (
|
||||
l_shipdate DATE NOT NULL,
|
||||
l_orderkey bigint NOT NULL,
|
||||
l_linenumber int not null,
|
||||
l_partkey int NOT NULL,
|
||||
l_suppkey int not null,
|
||||
l_quantity decimal(15, 2) NOT NULL,
|
||||
l_extendedprice decimal(15, 2) NOT NULL,
|
||||
l_discount decimal(15, 2) NOT NULL,
|
||||
l_tax decimal(15, 2) NOT NULL,
|
||||
l_returnflag VARCHAR(1) NOT NULL,
|
||||
l_linestatus VARCHAR(1) NOT NULL,
|
||||
l_commitdate DATE NOT NULL,
|
||||
l_receiptdate DATE NOT NULL,
|
||||
l_shipinstruct VARCHAR(25) NOT NULL,
|
||||
l_shipmode VARCHAR(10) NOT NULL,
|
||||
l_comment VARCHAR(44) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`l_shipdate`, `l_orderkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 1536
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists orders;
|
||||
CREATE TABLE orders (
|
||||
o_orderkey bigint NOT NULL,
|
||||
o_orderdate DATE NOT NULL,
|
||||
o_custkey int NOT NULL,
|
||||
o_orderstatus VARCHAR(1) NOT NULL,
|
||||
o_totalprice decimal(15, 2) NOT NULL,
|
||||
o_orderpriority VARCHAR(15) NOT NULL,
|
||||
o_clerk VARCHAR(15) NOT NULL,
|
||||
o_shippriority int NOT NULL,
|
||||
o_comment VARCHAR(79) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`o_orderkey`, `o_orderdate`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 1536
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
);
|
||||
|
||||
drop table if exists partsupp;
|
||||
CREATE TABLE partsupp (
|
||||
ps_partkey int NOT NULL,
|
||||
ps_suppkey int NOT NULL,
|
||||
ps_availqty int NOT NULL,
|
||||
ps_supplycost decimal(15, 2) NOT NULL,
|
||||
ps_comment VARCHAR(199) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`ps_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`ps_partkey`) BUCKETS 384
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists part;
|
||||
CREATE TABLE part (
|
||||
p_partkey int NOT NULL,
|
||||
p_name VARCHAR(55) NOT NULL,
|
||||
p_mfgr VARCHAR(25) NOT NULL,
|
||||
p_brand VARCHAR(10) NOT NULL,
|
||||
p_type VARCHAR(25) NOT NULL,
|
||||
p_size int NOT NULL,
|
||||
p_container VARCHAR(10) NOT NULL,
|
||||
p_retailprice decimal(15, 2) NOT NULL,
|
||||
p_comment VARCHAR(23) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`p_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 384
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
);
|
||||
|
||||
drop table if exists customer;
|
||||
CREATE TABLE customer (
|
||||
c_custkey int NOT NULL,
|
||||
c_name VARCHAR(25) NOT NULL,
|
||||
c_address VARCHAR(40) NOT NULL,
|
||||
c_nationkey int NOT NULL,
|
||||
c_phone VARCHAR(15) NOT NULL,
|
||||
c_acctbal decimal(15, 2) NOT NULL,
|
||||
c_mktsegment VARCHAR(10) NOT NULL,
|
||||
c_comment VARCHAR(117) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`c_custkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 384
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists supplier;
|
||||
CREATE TABLE supplier (
|
||||
s_suppkey int NOT NULL,
|
||||
s_name VARCHAR(25) NOT NULL,
|
||||
s_address VARCHAR(40) NOT NULL,
|
||||
s_nationkey int NOT NULL,
|
||||
s_phone VARCHAR(15) NOT NULL,
|
||||
s_acctbal decimal(15, 2) NOT NULL,
|
||||
s_comment VARCHAR(101) NOT NULL
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`s_suppkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 48
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists nation;
|
||||
CREATE TABLE `nation` (
|
||||
`n_nationkey` int(11) NOT NULL,
|
||||
`n_name` varchar(25) NOT NULL,
|
||||
`n_regionkey` int(11) NOT NULL,
|
||||
`n_comment` varchar(152) NULL
|
||||
) ENGINE=OLAP
|
||||
DUPLICATE KEY(`N_NATIONKEY`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`N_NATIONKEY`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop table if exists region;
|
||||
CREATE TABLE region (
|
||||
r_regionkey int NOT NULL,
|
||||
r_name VARCHAR(25) NOT NULL,
|
||||
r_comment VARCHAR(152)
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`r_regionkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`r_regionkey`) BUCKETS 1
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
drop view if exists revenue0;
|
||||
create view revenue0 (supplier_no, total_revenue) as
|
||||
select
|
||||
l_suppkey,
|
||||
sum(l_extendedprice * (1 - l_discount))
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate >= date '1996-01-01'
|
||||
and l_shipdate < date '1996-01-01' + interval '3' month
|
||||
group by
|
||||
l_suppkey;
|
||||
@ -36,7 +36,7 @@ CREATE TABLE lineitem (
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`l_shipdate`, `l_orderkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 96
|
||||
DISTRIBUTED BY HASH(`l_orderkey`) BUCKETS 32
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
@ -56,7 +56,7 @@ CREATE TABLE orders (
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`o_orderkey`, `o_orderdate`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 96
|
||||
DISTRIBUTED BY HASH(`o_orderkey`) BUCKETS 32
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "lineitem_orders"
|
||||
@ -72,7 +72,7 @@ CREATE TABLE partsupp (
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`ps_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`ps_partkey`) BUCKETS 24
|
||||
DISTRIBUTED BY HASH(`ps_partkey`) BUCKETS 12
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
@ -92,7 +92,7 @@ CREATE TABLE part (
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`p_partkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 24
|
||||
DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 12
|
||||
PROPERTIES (
|
||||
"replication_num" = "1",
|
||||
"colocate_with" = "part_partsupp"
|
||||
@ -111,7 +111,7 @@ CREATE TABLE customer (
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`c_custkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 24
|
||||
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 12
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
@ -128,7 +128,7 @@ CREATE TABLE supplier (
|
||||
)ENGINE=OLAP
|
||||
DUPLICATE KEY(`s_suppkey`)
|
||||
COMMENT "OLAP"
|
||||
DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 12
|
||||
DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 6
|
||||
PROPERTIES (
|
||||
"replication_num" = "1"
|
||||
);
|
||||
|
||||
38
tools/tpch-tools/queries/sf100/q1.sql
Normal file
38
tools/tpch-tools/queries/sf100/q1.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_returnflag,
|
||||
l_linestatus,
|
||||
sum(l_quantity) as sum_qty,
|
||||
sum(l_extendedprice) as sum_base_price,
|
||||
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
|
||||
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
|
||||
avg(l_quantity) as avg_qty,
|
||||
avg(l_extendedprice) as avg_price,
|
||||
avg(l_discount) as avg_disc,
|
||||
count(*) as count_order
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate <= date '1998-12-01' - interval '90' day
|
||||
group by
|
||||
l_returnflag,
|
||||
l_linestatus
|
||||
order by
|
||||
l_returnflag,
|
||||
l_linestatus;
|
||||
50
tools/tpch-tools/queries/sf100/q10.sql
Normal file
50
tools/tpch-tools/queries/sf100/q10.sql
Normal file
@ -0,0 +1,50 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_custkey,
|
||||
c_name,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue,
|
||||
c_acctbal,
|
||||
n_name,
|
||||
c_address,
|
||||
c_phone,
|
||||
c_comment
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem,
|
||||
nation
|
||||
where
|
||||
c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_orderdate >= date '1993-10-01'
|
||||
and o_orderdate < date '1993-10-01' + interval '3' month
|
||||
and l_returnflag = 'R'
|
||||
and c_nationkey = n_nationkey
|
||||
group by
|
||||
c_custkey,
|
||||
c_name,
|
||||
c_acctbal,
|
||||
c_phone,
|
||||
n_name,
|
||||
c_address,
|
||||
c_comment
|
||||
order by
|
||||
revenue desc
|
||||
limit 20;
|
||||
|
||||
44
tools/tpch-tools/queries/sf100/q11.sql
Normal file
44
tools/tpch-tools/queries/sf100/q11.sql
Normal file
@ -0,0 +1,44 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
ps_partkey,
|
||||
sum(ps_supplycost * ps_availqty) as value
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
ps_suppkey = s_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'GERMANY'
|
||||
group by
|
||||
ps_partkey having
|
||||
sum(ps_supplycost * ps_availqty) > (
|
||||
select
|
||||
sum(ps_supplycost * ps_availqty) * 0.000002
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
ps_suppkey = s_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'GERMANY'
|
||||
)
|
||||
order by
|
||||
value desc;
|
||||
45
tools/tpch-tools/queries/sf100/q12.sql
Normal file
45
tools/tpch-tools/queries/sf100/q12.sql
Normal file
@ -0,0 +1,45 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_shipmode,
|
||||
sum(case
|
||||
when o_orderpriority = '1-URGENT'
|
||||
or o_orderpriority = '2-HIGH'
|
||||
then 1
|
||||
else 0
|
||||
end) as high_line_count,
|
||||
sum(case
|
||||
when o_orderpriority <> '1-URGENT'
|
||||
and o_orderpriority <> '2-HIGH'
|
||||
then 1
|
||||
else 0
|
||||
end) as low_line_count
|
||||
from
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
o_orderkey = l_orderkey
|
||||
and l_shipmode in ('MAIL', 'SHIP')
|
||||
and l_commitdate < l_receiptdate
|
||||
and l_shipdate < l_commitdate
|
||||
and l_receiptdate >= date '1994-01-01'
|
||||
and l_receiptdate < date '1994-01-01' + interval '1' year
|
||||
group by
|
||||
l_shipmode
|
||||
order by
|
||||
l_shipmode;
|
||||
37
tools/tpch-tools/queries/sf100/q13.sql
Normal file
37
tools/tpch-tools/queries/sf100/q13.sql
Normal file
@ -0,0 +1,37 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_count,
|
||||
count(*) as custdist
|
||||
from
|
||||
(
|
||||
select
|
||||
c_custkey,
|
||||
count(o_orderkey) as c_count
|
||||
from
|
||||
customer left outer join orders on
|
||||
c_custkey = o_custkey
|
||||
and o_comment not like '%special%requests%'
|
||||
group by
|
||||
c_custkey
|
||||
) as c_orders
|
||||
group by
|
||||
c_count
|
||||
order by
|
||||
custdist desc,
|
||||
c_count desc;
|
||||
30
tools/tpch-tools/queries/sf100/q14.sql
Normal file
30
tools/tpch-tools/queries/sf100/q14.sql
Normal file
@ -0,0 +1,30 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
100.00 * sum(case
|
||||
when p_type like 'PROMO%'
|
||||
then l_extendedprice * (1 - l_discount)
|
||||
else 0
|
||||
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
l_partkey = p_partkey
|
||||
and l_shipdate >= date '1995-09-01'
|
||||
and l_shipdate < date '1995-09-01' + interval '1' month;
|
||||
36
tools/tpch-tools/queries/sf100/q15.sql
Normal file
36
tools/tpch-tools/queries/sf100/q15.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_suppkey,
|
||||
s_name,
|
||||
s_address,
|
||||
s_phone,
|
||||
total_revenue
|
||||
from
|
||||
supplier,
|
||||
revenue0
|
||||
where
|
||||
s_suppkey = supplier_no
|
||||
and total_revenue = (
|
||||
select
|
||||
max(total_revenue)
|
||||
from
|
||||
revenue0
|
||||
)
|
||||
order by
|
||||
s_suppkey;
|
||||
47
tools/tpch-tools/queries/sf100/q16.sql
Normal file
47
tools/tpch-tools/queries/sf100/q16.sql
Normal file
@ -0,0 +1,47 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size,
|
||||
count(distinct ps_suppkey) as supplier_cnt
|
||||
from
|
||||
partsupp,
|
||||
part
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and p_brand <> 'Brand#45'
|
||||
and p_type not like 'MEDIUM POLISHED%'
|
||||
and p_size in (49, 14, 23, 45, 19, 3, 36, 9)
|
||||
and ps_suppkey not in (
|
||||
select
|
||||
s_suppkey
|
||||
from
|
||||
supplier
|
||||
where
|
||||
s_comment like '%Customer%Complaints%'
|
||||
)
|
||||
group by
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size
|
||||
order by
|
||||
supplier_cnt desc,
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size;
|
||||
36
tools/tpch-tools/queries/sf100/q17.sql
Normal file
36
tools/tpch-tools/queries/sf100/q17.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
-- Modified
|
||||
|
||||
select
|
||||
sum(l_extendedprice) / 7.0 as avg_yearly
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#23'
|
||||
and p_container = 'MED BOX'
|
||||
and l_quantity < (
|
||||
select
|
||||
0.2 * avg(l_quantity)
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_partkey = p_partkey
|
||||
);
|
||||
51
tools/tpch-tools/queries/sf100/q18.sql
Normal file
51
tools/tpch-tools/queries/sf100/q18.sql
Normal file
@ -0,0 +1,51 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_name,
|
||||
c_custkey,
|
||||
o_orderkey,
|
||||
o_orderdate,
|
||||
o_totalprice,
|
||||
sum(l_quantity)
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
o_orderkey in (
|
||||
select
|
||||
l_orderkey
|
||||
from
|
||||
lineitem
|
||||
group by
|
||||
l_orderkey having
|
||||
sum(l_quantity) > 300
|
||||
)
|
||||
and c_custkey = o_custkey
|
||||
and o_orderkey = l_orderkey
|
||||
group by
|
||||
c_name,
|
||||
c_custkey,
|
||||
o_orderkey,
|
||||
o_orderdate,
|
||||
o_totalprice
|
||||
order by
|
||||
o_totalprice desc,
|
||||
o_orderdate
|
||||
limit 100;
|
||||
|
||||
52
tools/tpch-tools/queries/sf100/q19.sql
Normal file
52
tools/tpch-tools/queries/sf100/q19.sql
Normal file
@ -0,0 +1,52 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
sum(l_extendedprice* (1 - l_discount)) as revenue
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#12'
|
||||
and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
|
||||
and l_quantity >= 1 and l_quantity <= 1 + 10
|
||||
and p_size between 1 and 5
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
)
|
||||
or
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#23'
|
||||
and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
|
||||
and l_quantity >= 10 and l_quantity <= 10 + 10
|
||||
and p_size between 1 and 10
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
)
|
||||
or
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#34'
|
||||
and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
|
||||
and l_quantity >= 20 and l_quantity <= 20 + 10
|
||||
and p_size between 1 and 15
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
);
|
||||
61
tools/tpch-tools/queries/sf100/q2.sql
Normal file
61
tools/tpch-tools/queries/sf100/q2.sql
Normal file
@ -0,0 +1,61 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_acctbal,
|
||||
s_name,
|
||||
n_name,
|
||||
p_partkey,
|
||||
p_mfgr,
|
||||
s_address,
|
||||
s_phone,
|
||||
s_comment
|
||||
from
|
||||
part,
|
||||
supplier,
|
||||
partsupp,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and s_suppkey = ps_suppkey
|
||||
and p_size = 15
|
||||
and p_type like '%BRASS'
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'EUROPE'
|
||||
and ps_supplycost = (
|
||||
select
|
||||
min(ps_supplycost)
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and s_suppkey = ps_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'EUROPE'
|
||||
)
|
||||
order by
|
||||
s_acctbal desc,
|
||||
n_name,
|
||||
s_name,
|
||||
p_partkey
|
||||
limit 100;
|
||||
54
tools/tpch-tools/queries/sf100/q20.sql
Normal file
54
tools/tpch-tools/queries/sf100/q20.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_name,
|
||||
s_address
|
||||
from
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
s_suppkey in (
|
||||
select
|
||||
ps_suppkey
|
||||
from
|
||||
partsupp
|
||||
where
|
||||
ps_partkey in (
|
||||
select
|
||||
p_partkey
|
||||
from
|
||||
part
|
||||
where
|
||||
p_name like 'forest%'
|
||||
)
|
||||
and ps_availqty > (
|
||||
select
|
||||
0.5 * sum(l_quantity)
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_partkey = ps_partkey
|
||||
and l_suppkey = ps_suppkey
|
||||
and l_shipdate >= date '1994-01-01'
|
||||
and l_shipdate < date '1994-01-01' + interval '1' year
|
||||
)
|
||||
)
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'CANADA'
|
||||
order by
|
||||
s_name;
|
||||
57
tools/tpch-tools/queries/sf100/q21.sql
Normal file
57
tools/tpch-tools/queries/sf100/q21.sql
Normal file
@ -0,0 +1,57 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_name,
|
||||
count(*) as numwait
|
||||
from
|
||||
supplier,
|
||||
lineitem l1,
|
||||
orders,
|
||||
nation
|
||||
where
|
||||
s_suppkey = l1.l_suppkey
|
||||
and o_orderkey = l1.l_orderkey
|
||||
and o_orderstatus = 'F'
|
||||
and l1.l_receiptdate > l1.l_commitdate
|
||||
and exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
)
|
||||
and not exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem l3
|
||||
where
|
||||
l3.l_orderkey = l1.l_orderkey
|
||||
and l3.l_suppkey <> l1.l_suppkey
|
||||
and l3.l_receiptdate > l3.l_commitdate
|
||||
)
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'SAUDI ARABIA'
|
||||
group by
|
||||
s_name
|
||||
order by
|
||||
numwait desc,
|
||||
s_name
|
||||
limit 100;
|
||||
54
tools/tpch-tools/queries/sf100/q22.sql
Normal file
54
tools/tpch-tools/queries/sf100/q22.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
cntrycode,
|
||||
count(*) as numcust,
|
||||
sum(c_acctbal) as totacctbal
|
||||
from
|
||||
(
|
||||
select
|
||||
substring(c_phone, 1, 2) as cntrycode,
|
||||
c_acctbal
|
||||
from
|
||||
customer
|
||||
where
|
||||
substring(c_phone, 1, 2) in
|
||||
('13', '31', '23', '29', '30', '18', '17')
|
||||
and c_acctbal > (
|
||||
select
|
||||
avg(c_acctbal)
|
||||
from
|
||||
customer
|
||||
where
|
||||
c_acctbal > 0.00
|
||||
and substring(c_phone, 1, 2) in
|
||||
('13', '31', '23', '29', '30', '18', '17')
|
||||
)
|
||||
and not exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
orders
|
||||
where
|
||||
o_custkey = c_custkey
|
||||
)
|
||||
) as custsale
|
||||
group by
|
||||
cntrycode
|
||||
order by
|
||||
cntrycode;
|
||||
40
tools/tpch-tools/queries/sf100/q3.sql
Normal file
40
tools/tpch-tools/queries/sf100/q3.sql
Normal file
@ -0,0 +1,40 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_orderkey,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue,
|
||||
o_orderdate,
|
||||
o_shippriority
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
c_mktsegment = 'BUILDING'
|
||||
and c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_orderdate < date '1995-03-15'
|
||||
and l_shipdate > date '1995-03-15'
|
||||
group by
|
||||
l_orderkey,
|
||||
o_orderdate,
|
||||
o_shippriority
|
||||
order by
|
||||
revenue desc,
|
||||
o_orderdate
|
||||
limit 10;
|
||||
38
tools/tpch-tools/queries/sf100/q4.sql
Normal file
38
tools/tpch-tools/queries/sf100/q4.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
o_orderpriority,
|
||||
count(*) as order_count
|
||||
from
|
||||
orders
|
||||
where
|
||||
o_orderdate >= date '1993-07-01'
|
||||
and o_orderdate < date '1993-07-01' + interval '3' month
|
||||
and exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_orderkey = o_orderkey
|
||||
and l_commitdate < l_receiptdate
|
||||
)
|
||||
group by
|
||||
o_orderpriority
|
||||
order by
|
||||
o_orderpriority;
|
||||
41
tools/tpch-tools/queries/sf100/q5.sql
Normal file
41
tools/tpch-tools/queries/sf100/q5.sql
Normal file
@ -0,0 +1,41 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
n_name,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem,
|
||||
supplier,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and l_suppkey = s_suppkey
|
||||
and c_nationkey = s_nationkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'ASIA'
|
||||
and o_orderdate >= date '1994-01-01'
|
||||
and o_orderdate < date '1994-01-01' + interval '1' year
|
||||
group by
|
||||
n_name
|
||||
order by
|
||||
revenue desc;
|
||||
26
tools/tpch-tools/queries/sf100/q6.sql
Normal file
26
tools/tpch-tools/queries/sf100/q6.sql
Normal file
@ -0,0 +1,26 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
sum(l_extendedprice * l_discount) as revenue
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate >= date '1994-01-01'
|
||||
and l_shipdate < date '1994-01-01' + interval '1' year
|
||||
and l_discount between .06 - 0.01 and .06 + 0.01
|
||||
and l_quantity < 24;
|
||||
56
tools/tpch-tools/queries/sf100/q7.sql
Normal file
56
tools/tpch-tools/queries/sf100/q7.sql
Normal file
@ -0,0 +1,56 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
supp_nation,
|
||||
cust_nation,
|
||||
l_year,
|
||||
sum(volume) as revenue
|
||||
from
|
||||
(
|
||||
select
|
||||
n1.n_name as supp_nation,
|
||||
n2.n_name as cust_nation,
|
||||
extract(year from l_shipdate) as l_year,
|
||||
l_extendedprice * (1 - l_discount) as volume
|
||||
from
|
||||
supplier,
|
||||
lineitem,
|
||||
orders,
|
||||
customer,
|
||||
nation n1,
|
||||
nation n2
|
||||
where
|
||||
s_suppkey = l_suppkey
|
||||
and o_orderkey = l_orderkey
|
||||
and c_custkey = o_custkey
|
||||
and s_nationkey = n1.n_nationkey
|
||||
and c_nationkey = n2.n_nationkey
|
||||
and (
|
||||
(n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY')
|
||||
or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')
|
||||
)
|
||||
and l_shipdate between date '1995-01-01' and date '1996-12-31'
|
||||
) as shipping
|
||||
group by
|
||||
supp_nation,
|
||||
cust_nation,
|
||||
l_year
|
||||
order by
|
||||
supp_nation,
|
||||
cust_nation,
|
||||
l_year;
|
||||
54
tools/tpch-tools/queries/sf100/q8.sql
Normal file
54
tools/tpch-tools/queries/sf100/q8.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
o_year,
|
||||
sum(case
|
||||
when nation = 'BRAZIL' then volume
|
||||
else 0
|
||||
end) / sum(volume) as mkt_share
|
||||
from
|
||||
(
|
||||
select
|
||||
extract(year from o_orderdate) as o_year,
|
||||
l_extendedprice * (1 - l_discount) as volume,
|
||||
n2.n_name as nation
|
||||
from
|
||||
part,
|
||||
supplier,
|
||||
lineitem,
|
||||
orders,
|
||||
customer,
|
||||
nation n1,
|
||||
nation n2,
|
||||
region
|
||||
where
|
||||
p_partkey = l_partkey
|
||||
and s_suppkey = l_suppkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_custkey = c_custkey
|
||||
and c_nationkey = n1.n_nationkey
|
||||
and n1.n_regionkey = r_regionkey
|
||||
and r_name = 'AMERICA'
|
||||
and s_nationkey = n2.n_nationkey
|
||||
and o_orderdate between date '1995-01-01' and date '1996-12-31'
|
||||
and p_type = 'ECONOMY ANODIZED STEEL'
|
||||
) as all_nations
|
||||
group by
|
||||
o_year
|
||||
order by
|
||||
o_year;
|
||||
49
tools/tpch-tools/queries/sf100/q9.sql
Normal file
49
tools/tpch-tools/queries/sf100/q9.sql
Normal file
@ -0,0 +1,49 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
nation,
|
||||
o_year,
|
||||
sum(amount) as sum_profit
|
||||
from
|
||||
(
|
||||
select
|
||||
n_name as nation,
|
||||
extract(year from o_orderdate) as o_year,
|
||||
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
|
||||
from
|
||||
part,
|
||||
supplier,
|
||||
lineitem,
|
||||
partsupp,
|
||||
orders,
|
||||
nation
|
||||
where
|
||||
s_suppkey = l_suppkey
|
||||
and ps_suppkey = l_suppkey
|
||||
and ps_partkey = l_partkey
|
||||
and p_partkey = l_partkey
|
||||
and o_orderkey = l_orderkey
|
||||
and s_nationkey = n_nationkey
|
||||
and p_name like '%green%'
|
||||
) as profit
|
||||
group by
|
||||
nation,
|
||||
o_year
|
||||
order by
|
||||
nation,
|
||||
o_year desc;
|
||||
38
tools/tpch-tools/queries/sf1000/q1.sql
Normal file
38
tools/tpch-tools/queries/sf1000/q1.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_returnflag,
|
||||
l_linestatus,
|
||||
sum(l_quantity) as sum_qty,
|
||||
sum(l_extendedprice) as sum_base_price,
|
||||
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
|
||||
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
|
||||
avg(l_quantity) as avg_qty,
|
||||
avg(l_extendedprice) as avg_price,
|
||||
avg(l_discount) as avg_disc,
|
||||
count(*) as count_order
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate <= date '1998-12-01' - interval '90' day
|
||||
group by
|
||||
l_returnflag,
|
||||
l_linestatus
|
||||
order by
|
||||
l_returnflag,
|
||||
l_linestatus;
|
||||
50
tools/tpch-tools/queries/sf1000/q10.sql
Normal file
50
tools/tpch-tools/queries/sf1000/q10.sql
Normal file
@ -0,0 +1,50 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_custkey,
|
||||
c_name,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue,
|
||||
c_acctbal,
|
||||
n_name,
|
||||
c_address,
|
||||
c_phone,
|
||||
c_comment
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem,
|
||||
nation
|
||||
where
|
||||
c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_orderdate >= date '1993-10-01'
|
||||
and o_orderdate < date '1993-10-01' + interval '3' month
|
||||
and l_returnflag = 'R'
|
||||
and c_nationkey = n_nationkey
|
||||
group by
|
||||
c_custkey,
|
||||
c_name,
|
||||
c_acctbal,
|
||||
c_phone,
|
||||
n_name,
|
||||
c_address,
|
||||
c_comment
|
||||
order by
|
||||
revenue desc
|
||||
limit 20;
|
||||
|
||||
44
tools/tpch-tools/queries/sf1000/q11.sql
Normal file
44
tools/tpch-tools/queries/sf1000/q11.sql
Normal file
@ -0,0 +1,44 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
ps_partkey,
|
||||
sum(ps_supplycost * ps_availqty) as value
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
ps_suppkey = s_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'GERMANY'
|
||||
group by
|
||||
ps_partkey having
|
||||
sum(ps_supplycost * ps_availqty) > (
|
||||
select
|
||||
sum(ps_supplycost * ps_availqty) * 0.000002
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
ps_suppkey = s_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'GERMANY'
|
||||
)
|
||||
order by
|
||||
value desc;
|
||||
45
tools/tpch-tools/queries/sf1000/q12.sql
Normal file
45
tools/tpch-tools/queries/sf1000/q12.sql
Normal file
@ -0,0 +1,45 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_shipmode,
|
||||
sum(case
|
||||
when o_orderpriority = '1-URGENT'
|
||||
or o_orderpriority = '2-HIGH'
|
||||
then 1
|
||||
else 0
|
||||
end) as high_line_count,
|
||||
sum(case
|
||||
when o_orderpriority <> '1-URGENT'
|
||||
and o_orderpriority <> '2-HIGH'
|
||||
then 1
|
||||
else 0
|
||||
end) as low_line_count
|
||||
from
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
o_orderkey = l_orderkey
|
||||
and l_shipmode in ('MAIL', 'SHIP')
|
||||
and l_commitdate < l_receiptdate
|
||||
and l_shipdate < l_commitdate
|
||||
and l_receiptdate >= date '1994-01-01'
|
||||
and l_receiptdate < date '1994-01-01' + interval '1' year
|
||||
group by
|
||||
l_shipmode
|
||||
order by
|
||||
l_shipmode;
|
||||
37
tools/tpch-tools/queries/sf1000/q13.sql
Normal file
37
tools/tpch-tools/queries/sf1000/q13.sql
Normal file
@ -0,0 +1,37 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_count,
|
||||
count(*) as custdist
|
||||
from
|
||||
(
|
||||
select
|
||||
c_custkey,
|
||||
count(o_orderkey) as c_count
|
||||
from
|
||||
customer left outer join orders on
|
||||
c_custkey = o_custkey
|
||||
and o_comment not like '%special%requests%'
|
||||
group by
|
||||
c_custkey
|
||||
) as c_orders
|
||||
group by
|
||||
c_count
|
||||
order by
|
||||
custdist desc,
|
||||
c_count desc;
|
||||
30
tools/tpch-tools/queries/sf1000/q14.sql
Normal file
30
tools/tpch-tools/queries/sf1000/q14.sql
Normal file
@ -0,0 +1,30 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
100.00 * sum(case
|
||||
when p_type like 'PROMO%'
|
||||
then l_extendedprice * (1 - l_discount)
|
||||
else 0
|
||||
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
l_partkey = p_partkey
|
||||
and l_shipdate >= date '1995-09-01'
|
||||
and l_shipdate < date '1995-09-01' + interval '1' month;
|
||||
36
tools/tpch-tools/queries/sf1000/q15.sql
Normal file
36
tools/tpch-tools/queries/sf1000/q15.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_suppkey,
|
||||
s_name,
|
||||
s_address,
|
||||
s_phone,
|
||||
total_revenue
|
||||
from
|
||||
supplier,
|
||||
revenue0
|
||||
where
|
||||
s_suppkey = supplier_no
|
||||
and total_revenue = (
|
||||
select
|
||||
max(total_revenue)
|
||||
from
|
||||
revenue0
|
||||
)
|
||||
order by
|
||||
s_suppkey;
|
||||
47
tools/tpch-tools/queries/sf1000/q16.sql
Normal file
47
tools/tpch-tools/queries/sf1000/q16.sql
Normal file
@ -0,0 +1,47 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size,
|
||||
count(distinct ps_suppkey) as supplier_cnt
|
||||
from
|
||||
partsupp,
|
||||
part
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and p_brand <> 'Brand#45'
|
||||
and p_type not like 'MEDIUM POLISHED%'
|
||||
and p_size in (49, 14, 23, 45, 19, 3, 36, 9)
|
||||
and ps_suppkey not in (
|
||||
select
|
||||
s_suppkey
|
||||
from
|
||||
supplier
|
||||
where
|
||||
s_comment like '%Customer%Complaints%'
|
||||
)
|
||||
group by
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size
|
||||
order by
|
||||
supplier_cnt desc,
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size;
|
||||
36
tools/tpch-tools/queries/sf1000/q17.sql
Normal file
36
tools/tpch-tools/queries/sf1000/q17.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
-- Modified
|
||||
|
||||
select
|
||||
sum(l_extendedprice) / 7.0 as avg_yearly
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#23'
|
||||
and p_container = 'MED BOX'
|
||||
and l_quantity < (
|
||||
select
|
||||
0.2 * avg(l_quantity)
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_partkey = p_partkey
|
||||
);
|
||||
51
tools/tpch-tools/queries/sf1000/q18.sql
Normal file
51
tools/tpch-tools/queries/sf1000/q18.sql
Normal file
@ -0,0 +1,51 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_name,
|
||||
c_custkey,
|
||||
o_orderkey,
|
||||
o_orderdate,
|
||||
o_totalprice,
|
||||
sum(l_quantity)
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
o_orderkey in (
|
||||
select
|
||||
l_orderkey
|
||||
from
|
||||
lineitem
|
||||
group by
|
||||
l_orderkey having
|
||||
sum(l_quantity) > 300
|
||||
)
|
||||
and c_custkey = o_custkey
|
||||
and o_orderkey = l_orderkey
|
||||
group by
|
||||
c_name,
|
||||
c_custkey,
|
||||
o_orderkey,
|
||||
o_orderdate,
|
||||
o_totalprice
|
||||
order by
|
||||
o_totalprice desc,
|
||||
o_orderdate
|
||||
limit 100;
|
||||
|
||||
52
tools/tpch-tools/queries/sf1000/q19.sql
Normal file
52
tools/tpch-tools/queries/sf1000/q19.sql
Normal file
@ -0,0 +1,52 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
sum(l_extendedprice* (1 - l_discount)) as revenue
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#12'
|
||||
and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
|
||||
and l_quantity >= 1 and l_quantity <= 1 + 10
|
||||
and p_size between 1 and 5
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
)
|
||||
or
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#23'
|
||||
and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
|
||||
and l_quantity >= 10 and l_quantity <= 10 + 10
|
||||
and p_size between 1 and 10
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
)
|
||||
or
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#34'
|
||||
and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
|
||||
and l_quantity >= 20 and l_quantity <= 20 + 10
|
||||
and p_size between 1 and 15
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
);
|
||||
61
tools/tpch-tools/queries/sf1000/q2.sql
Normal file
61
tools/tpch-tools/queries/sf1000/q2.sql
Normal file
@ -0,0 +1,61 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_acctbal,
|
||||
s_name,
|
||||
n_name,
|
||||
p_partkey,
|
||||
p_mfgr,
|
||||
s_address,
|
||||
s_phone,
|
||||
s_comment
|
||||
from
|
||||
part,
|
||||
supplier,
|
||||
partsupp,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and s_suppkey = ps_suppkey
|
||||
and p_size = 15
|
||||
and p_type like '%BRASS'
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'EUROPE'
|
||||
and ps_supplycost = (
|
||||
select
|
||||
min(ps_supplycost)
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and s_suppkey = ps_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'EUROPE'
|
||||
)
|
||||
order by
|
||||
s_acctbal desc,
|
||||
n_name,
|
||||
s_name,
|
||||
p_partkey
|
||||
limit 100;
|
||||
54
tools/tpch-tools/queries/sf1000/q20.sql
Normal file
54
tools/tpch-tools/queries/sf1000/q20.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_name,
|
||||
s_address
|
||||
from
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
s_suppkey in (
|
||||
select
|
||||
ps_suppkey
|
||||
from
|
||||
partsupp
|
||||
where
|
||||
ps_partkey in (
|
||||
select
|
||||
p_partkey
|
||||
from
|
||||
part
|
||||
where
|
||||
p_name like 'forest%'
|
||||
)
|
||||
and ps_availqty > (
|
||||
select
|
||||
0.5 * sum(l_quantity)
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_partkey = ps_partkey
|
||||
and l_suppkey = ps_suppkey
|
||||
and l_shipdate >= date '1994-01-01'
|
||||
and l_shipdate < date '1994-01-01' + interval '1' year
|
||||
)
|
||||
)
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'CANADA'
|
||||
order by
|
||||
s_name;
|
||||
57
tools/tpch-tools/queries/sf1000/q21.sql
Normal file
57
tools/tpch-tools/queries/sf1000/q21.sql
Normal file
@ -0,0 +1,57 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_name,
|
||||
count(*) as numwait
|
||||
from
|
||||
supplier,
|
||||
lineitem l1,
|
||||
orders,
|
||||
nation
|
||||
where
|
||||
s_suppkey = l1.l_suppkey
|
||||
and o_orderkey = l1.l_orderkey
|
||||
and o_orderstatus = 'F'
|
||||
and l1.l_receiptdate > l1.l_commitdate
|
||||
and exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
)
|
||||
and not exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem l3
|
||||
where
|
||||
l3.l_orderkey = l1.l_orderkey
|
||||
and l3.l_suppkey <> l1.l_suppkey
|
||||
and l3.l_receiptdate > l3.l_commitdate
|
||||
)
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'SAUDI ARABIA'
|
||||
group by
|
||||
s_name
|
||||
order by
|
||||
numwait desc,
|
||||
s_name
|
||||
limit 100;
|
||||
54
tools/tpch-tools/queries/sf1000/q22.sql
Normal file
54
tools/tpch-tools/queries/sf1000/q22.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
cntrycode,
|
||||
count(*) as numcust,
|
||||
sum(c_acctbal) as totacctbal
|
||||
from
|
||||
(
|
||||
select
|
||||
substring(c_phone, 1, 2) as cntrycode,
|
||||
c_acctbal
|
||||
from
|
||||
customer
|
||||
where
|
||||
substring(c_phone, 1, 2) in
|
||||
('13', '31', '23', '29', '30', '18', '17')
|
||||
and c_acctbal > (
|
||||
select
|
||||
avg(c_acctbal)
|
||||
from
|
||||
customer
|
||||
where
|
||||
c_acctbal > 0.00
|
||||
and substring(c_phone, 1, 2) in
|
||||
('13', '31', '23', '29', '30', '18', '17')
|
||||
)
|
||||
and not exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
orders
|
||||
where
|
||||
o_custkey = c_custkey
|
||||
)
|
||||
) as custsale
|
||||
group by
|
||||
cntrycode
|
||||
order by
|
||||
cntrycode;
|
||||
40
tools/tpch-tools/queries/sf1000/q3.sql
Normal file
40
tools/tpch-tools/queries/sf1000/q3.sql
Normal file
@ -0,0 +1,40 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_orderkey,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue,
|
||||
o_orderdate,
|
||||
o_shippriority
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
c_mktsegment = 'BUILDING'
|
||||
and c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_orderdate < date '1995-03-15'
|
||||
and l_shipdate > date '1995-03-15'
|
||||
group by
|
||||
l_orderkey,
|
||||
o_orderdate,
|
||||
o_shippriority
|
||||
order by
|
||||
revenue desc,
|
||||
o_orderdate
|
||||
limit 10;
|
||||
38
tools/tpch-tools/queries/sf1000/q4.sql
Normal file
38
tools/tpch-tools/queries/sf1000/q4.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
o_orderpriority,
|
||||
count(*) as order_count
|
||||
from
|
||||
orders
|
||||
where
|
||||
o_orderdate >= date '1993-07-01'
|
||||
and o_orderdate < date '1993-07-01' + interval '3' month
|
||||
and exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_orderkey = o_orderkey
|
||||
and l_commitdate < l_receiptdate
|
||||
)
|
||||
group by
|
||||
o_orderpriority
|
||||
order by
|
||||
o_orderpriority;
|
||||
41
tools/tpch-tools/queries/sf1000/q5.sql
Normal file
41
tools/tpch-tools/queries/sf1000/q5.sql
Normal file
@ -0,0 +1,41 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
n_name,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem,
|
||||
supplier,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and l_suppkey = s_suppkey
|
||||
and c_nationkey = s_nationkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'ASIA'
|
||||
and o_orderdate >= date '1994-01-01'
|
||||
and o_orderdate < date '1994-01-01' + interval '1' year
|
||||
group by
|
||||
n_name
|
||||
order by
|
||||
revenue desc;
|
||||
26
tools/tpch-tools/queries/sf1000/q6.sql
Normal file
26
tools/tpch-tools/queries/sf1000/q6.sql
Normal file
@ -0,0 +1,26 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
sum(l_extendedprice * l_discount) as revenue
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate >= date '1994-01-01'
|
||||
and l_shipdate < date '1994-01-01' + interval '1' year
|
||||
and l_discount between .06 - 0.01 and .06 + 0.01
|
||||
and l_quantity < 24;
|
||||
56
tools/tpch-tools/queries/sf1000/q7.sql
Normal file
56
tools/tpch-tools/queries/sf1000/q7.sql
Normal file
@ -0,0 +1,56 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
supp_nation,
|
||||
cust_nation,
|
||||
l_year,
|
||||
sum(volume) as revenue
|
||||
from
|
||||
(
|
||||
select
|
||||
n1.n_name as supp_nation,
|
||||
n2.n_name as cust_nation,
|
||||
extract(year from l_shipdate) as l_year,
|
||||
l_extendedprice * (1 - l_discount) as volume
|
||||
from
|
||||
supplier,
|
||||
lineitem,
|
||||
orders,
|
||||
customer,
|
||||
nation n1,
|
||||
nation n2
|
||||
where
|
||||
s_suppkey = l_suppkey
|
||||
and o_orderkey = l_orderkey
|
||||
and c_custkey = o_custkey
|
||||
and s_nationkey = n1.n_nationkey
|
||||
and c_nationkey = n2.n_nationkey
|
||||
and (
|
||||
(n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY')
|
||||
or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')
|
||||
)
|
||||
and l_shipdate between date '1995-01-01' and date '1996-12-31'
|
||||
) as shipping
|
||||
group by
|
||||
supp_nation,
|
||||
cust_nation,
|
||||
l_year
|
||||
order by
|
||||
supp_nation,
|
||||
cust_nation,
|
||||
l_year;
|
||||
54
tools/tpch-tools/queries/sf1000/q8.sql
Normal file
54
tools/tpch-tools/queries/sf1000/q8.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
o_year,
|
||||
sum(case
|
||||
when nation = 'BRAZIL' then volume
|
||||
else 0
|
||||
end) / sum(volume) as mkt_share
|
||||
from
|
||||
(
|
||||
select
|
||||
extract(year from o_orderdate) as o_year,
|
||||
l_extendedprice * (1 - l_discount) as volume,
|
||||
n2.n_name as nation
|
||||
from
|
||||
part,
|
||||
supplier,
|
||||
lineitem,
|
||||
orders,
|
||||
customer,
|
||||
nation n1,
|
||||
nation n2,
|
||||
region
|
||||
where
|
||||
p_partkey = l_partkey
|
||||
and s_suppkey = l_suppkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_custkey = c_custkey
|
||||
and c_nationkey = n1.n_nationkey
|
||||
and n1.n_regionkey = r_regionkey
|
||||
and r_name = 'AMERICA'
|
||||
and s_nationkey = n2.n_nationkey
|
||||
and o_orderdate between date '1995-01-01' and date '1996-12-31'
|
||||
and p_type = 'ECONOMY ANODIZED STEEL'
|
||||
) as all_nations
|
||||
group by
|
||||
o_year
|
||||
order by
|
||||
o_year;
|
||||
49
tools/tpch-tools/queries/sf1000/q9.sql
Normal file
49
tools/tpch-tools/queries/sf1000/q9.sql
Normal file
@ -0,0 +1,49 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
nation,
|
||||
o_year,
|
||||
sum(amount) as sum_profit
|
||||
from
|
||||
(
|
||||
select
|
||||
n_name as nation,
|
||||
extract(year from o_orderdate) as o_year,
|
||||
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
|
||||
from
|
||||
part,
|
||||
supplier,
|
||||
lineitem,
|
||||
partsupp,
|
||||
orders,
|
||||
nation
|
||||
where
|
||||
s_suppkey = l_suppkey
|
||||
and ps_suppkey = l_suppkey
|
||||
and ps_partkey = l_partkey
|
||||
and p_partkey = l_partkey
|
||||
and o_orderkey = l_orderkey
|
||||
and s_nationkey = n_nationkey
|
||||
and p_name like '%green%'
|
||||
) as profit
|
||||
group by
|
||||
nation,
|
||||
o_year
|
||||
order by
|
||||
nation,
|
||||
o_year desc;
|
||||
38
tools/tpch-tools/queries/sf10000/q1.sql
Normal file
38
tools/tpch-tools/queries/sf10000/q1.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_returnflag,
|
||||
l_linestatus,
|
||||
sum(l_quantity) as sum_qty,
|
||||
sum(l_extendedprice) as sum_base_price,
|
||||
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
|
||||
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
|
||||
avg(l_quantity) as avg_qty,
|
||||
avg(l_extendedprice) as avg_price,
|
||||
avg(l_discount) as avg_disc,
|
||||
count(*) as count_order
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate <= date '1998-12-01' - interval '90' day
|
||||
group by
|
||||
l_returnflag,
|
||||
l_linestatus
|
||||
order by
|
||||
l_returnflag,
|
||||
l_linestatus;
|
||||
50
tools/tpch-tools/queries/sf10000/q10.sql
Normal file
50
tools/tpch-tools/queries/sf10000/q10.sql
Normal file
@ -0,0 +1,50 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_custkey,
|
||||
c_name,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue,
|
||||
c_acctbal,
|
||||
n_name,
|
||||
c_address,
|
||||
c_phone,
|
||||
c_comment
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem,
|
||||
nation
|
||||
where
|
||||
c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_orderdate >= date '1993-10-01'
|
||||
and o_orderdate < date '1993-10-01' + interval '3' month
|
||||
and l_returnflag = 'R'
|
||||
and c_nationkey = n_nationkey
|
||||
group by
|
||||
c_custkey,
|
||||
c_name,
|
||||
c_acctbal,
|
||||
c_phone,
|
||||
n_name,
|
||||
c_address,
|
||||
c_comment
|
||||
order by
|
||||
revenue desc
|
||||
limit 20;
|
||||
|
||||
44
tools/tpch-tools/queries/sf10000/q11.sql
Normal file
44
tools/tpch-tools/queries/sf10000/q11.sql
Normal file
@ -0,0 +1,44 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
ps_partkey,
|
||||
sum(ps_supplycost * ps_availqty) as value
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
ps_suppkey = s_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'GERMANY'
|
||||
group by
|
||||
ps_partkey having
|
||||
sum(ps_supplycost * ps_availqty) > (
|
||||
select
|
||||
sum(ps_supplycost * ps_availqty) * 0.000002
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
ps_suppkey = s_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'GERMANY'
|
||||
)
|
||||
order by
|
||||
value desc;
|
||||
45
tools/tpch-tools/queries/sf10000/q12.sql
Normal file
45
tools/tpch-tools/queries/sf10000/q12.sql
Normal file
@ -0,0 +1,45 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_shipmode,
|
||||
sum(case
|
||||
when o_orderpriority = '1-URGENT'
|
||||
or o_orderpriority = '2-HIGH'
|
||||
then 1
|
||||
else 0
|
||||
end) as high_line_count,
|
||||
sum(case
|
||||
when o_orderpriority <> '1-URGENT'
|
||||
and o_orderpriority <> '2-HIGH'
|
||||
then 1
|
||||
else 0
|
||||
end) as low_line_count
|
||||
from
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
o_orderkey = l_orderkey
|
||||
and l_shipmode in ('MAIL', 'SHIP')
|
||||
and l_commitdate < l_receiptdate
|
||||
and l_shipdate < l_commitdate
|
||||
and l_receiptdate >= date '1994-01-01'
|
||||
and l_receiptdate < date '1994-01-01' + interval '1' year
|
||||
group by
|
||||
l_shipmode
|
||||
order by
|
||||
l_shipmode;
|
||||
37
tools/tpch-tools/queries/sf10000/q13.sql
Normal file
37
tools/tpch-tools/queries/sf10000/q13.sql
Normal file
@ -0,0 +1,37 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_count,
|
||||
count(*) as custdist
|
||||
from
|
||||
(
|
||||
select
|
||||
c_custkey,
|
||||
count(o_orderkey) as c_count
|
||||
from
|
||||
customer left outer join orders on
|
||||
c_custkey = o_custkey
|
||||
and o_comment not like '%special%requests%'
|
||||
group by
|
||||
c_custkey
|
||||
) as c_orders
|
||||
group by
|
||||
c_count
|
||||
order by
|
||||
custdist desc,
|
||||
c_count desc;
|
||||
30
tools/tpch-tools/queries/sf10000/q14.sql
Normal file
30
tools/tpch-tools/queries/sf10000/q14.sql
Normal file
@ -0,0 +1,30 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
100.00 * sum(case
|
||||
when p_type like 'PROMO%'
|
||||
then l_extendedprice * (1 - l_discount)
|
||||
else 0
|
||||
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
l_partkey = p_partkey
|
||||
and l_shipdate >= date '1995-09-01'
|
||||
and l_shipdate < date '1995-09-01' + interval '1' month;
|
||||
36
tools/tpch-tools/queries/sf10000/q15.sql
Normal file
36
tools/tpch-tools/queries/sf10000/q15.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_suppkey,
|
||||
s_name,
|
||||
s_address,
|
||||
s_phone,
|
||||
total_revenue
|
||||
from
|
||||
supplier,
|
||||
revenue0
|
||||
where
|
||||
s_suppkey = supplier_no
|
||||
and total_revenue = (
|
||||
select
|
||||
max(total_revenue)
|
||||
from
|
||||
revenue0
|
||||
)
|
||||
order by
|
||||
s_suppkey;
|
||||
47
tools/tpch-tools/queries/sf10000/q16.sql
Normal file
47
tools/tpch-tools/queries/sf10000/q16.sql
Normal file
@ -0,0 +1,47 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size,
|
||||
count(distinct ps_suppkey) as supplier_cnt
|
||||
from
|
||||
partsupp,
|
||||
part
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and p_brand <> 'Brand#45'
|
||||
and p_type not like 'MEDIUM POLISHED%'
|
||||
and p_size in (49, 14, 23, 45, 19, 3, 36, 9)
|
||||
and ps_suppkey not in (
|
||||
select
|
||||
s_suppkey
|
||||
from
|
||||
supplier
|
||||
where
|
||||
s_comment like '%Customer%Complaints%'
|
||||
)
|
||||
group by
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size
|
||||
order by
|
||||
supplier_cnt desc,
|
||||
p_brand,
|
||||
p_type,
|
||||
p_size;
|
||||
36
tools/tpch-tools/queries/sf10000/q17.sql
Normal file
36
tools/tpch-tools/queries/sf10000/q17.sql
Normal file
@ -0,0 +1,36 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
-- Modified
|
||||
|
||||
select
|
||||
sum(l_extendedprice) / 7.0 as avg_yearly
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#23'
|
||||
and p_container = 'MED BOX'
|
||||
and l_quantity < (
|
||||
select
|
||||
0.2 * avg(l_quantity)
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_partkey = p_partkey
|
||||
);
|
||||
51
tools/tpch-tools/queries/sf10000/q18.sql
Normal file
51
tools/tpch-tools/queries/sf10000/q18.sql
Normal file
@ -0,0 +1,51 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
c_name,
|
||||
c_custkey,
|
||||
o_orderkey,
|
||||
o_orderdate,
|
||||
o_totalprice,
|
||||
sum(l_quantity)
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
o_orderkey in (
|
||||
select
|
||||
l_orderkey
|
||||
from
|
||||
lineitem
|
||||
group by
|
||||
l_orderkey having
|
||||
sum(l_quantity) > 300
|
||||
)
|
||||
and c_custkey = o_custkey
|
||||
and o_orderkey = l_orderkey
|
||||
group by
|
||||
c_name,
|
||||
c_custkey,
|
||||
o_orderkey,
|
||||
o_orderdate,
|
||||
o_totalprice
|
||||
order by
|
||||
o_totalprice desc,
|
||||
o_orderdate
|
||||
limit 100;
|
||||
|
||||
52
tools/tpch-tools/queries/sf10000/q19.sql
Normal file
52
tools/tpch-tools/queries/sf10000/q19.sql
Normal file
@ -0,0 +1,52 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
sum(l_extendedprice* (1 - l_discount)) as revenue
|
||||
from
|
||||
lineitem,
|
||||
part
|
||||
where
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#12'
|
||||
and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
|
||||
and l_quantity >= 1 and l_quantity <= 1 + 10
|
||||
and p_size between 1 and 5
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
)
|
||||
or
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#23'
|
||||
and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
|
||||
and l_quantity >= 10 and l_quantity <= 10 + 10
|
||||
and p_size between 1 and 10
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
)
|
||||
or
|
||||
(
|
||||
p_partkey = l_partkey
|
||||
and p_brand = 'Brand#34'
|
||||
and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
|
||||
and l_quantity >= 20 and l_quantity <= 20 + 10
|
||||
and p_size between 1 and 15
|
||||
and l_shipmode in ('AIR', 'AIR REG')
|
||||
and l_shipinstruct = 'DELIVER IN PERSON'
|
||||
);
|
||||
61
tools/tpch-tools/queries/sf10000/q2.sql
Normal file
61
tools/tpch-tools/queries/sf10000/q2.sql
Normal file
@ -0,0 +1,61 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_acctbal,
|
||||
s_name,
|
||||
n_name,
|
||||
p_partkey,
|
||||
p_mfgr,
|
||||
s_address,
|
||||
s_phone,
|
||||
s_comment
|
||||
from
|
||||
part,
|
||||
supplier,
|
||||
partsupp,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and s_suppkey = ps_suppkey
|
||||
and p_size = 15
|
||||
and p_type like '%BRASS'
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'EUROPE'
|
||||
and ps_supplycost = (
|
||||
select
|
||||
min(ps_supplycost)
|
||||
from
|
||||
partsupp,
|
||||
supplier,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
p_partkey = ps_partkey
|
||||
and s_suppkey = ps_suppkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'EUROPE'
|
||||
)
|
||||
order by
|
||||
s_acctbal desc,
|
||||
n_name,
|
||||
s_name,
|
||||
p_partkey
|
||||
limit 100;
|
||||
54
tools/tpch-tools/queries/sf10000/q20.sql
Normal file
54
tools/tpch-tools/queries/sf10000/q20.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_name,
|
||||
s_address
|
||||
from
|
||||
supplier,
|
||||
nation
|
||||
where
|
||||
s_suppkey in (
|
||||
select
|
||||
ps_suppkey
|
||||
from
|
||||
partsupp
|
||||
where
|
||||
ps_partkey in (
|
||||
select
|
||||
p_partkey
|
||||
from
|
||||
part
|
||||
where
|
||||
p_name like 'forest%'
|
||||
)
|
||||
and ps_availqty > (
|
||||
select
|
||||
0.5 * sum(l_quantity)
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_partkey = ps_partkey
|
||||
and l_suppkey = ps_suppkey
|
||||
and l_shipdate >= date '1994-01-01'
|
||||
and l_shipdate < date '1994-01-01' + interval '1' year
|
||||
)
|
||||
)
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'CANADA'
|
||||
order by
|
||||
s_name;
|
||||
57
tools/tpch-tools/queries/sf10000/q21.sql
Normal file
57
tools/tpch-tools/queries/sf10000/q21.sql
Normal file
@ -0,0 +1,57 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
s_name,
|
||||
count(*) as numwait
|
||||
from
|
||||
supplier,
|
||||
lineitem l1,
|
||||
orders,
|
||||
nation
|
||||
where
|
||||
s_suppkey = l1.l_suppkey
|
||||
and o_orderkey = l1.l_orderkey
|
||||
and o_orderstatus = 'F'
|
||||
and l1.l_receiptdate > l1.l_commitdate
|
||||
and exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
)
|
||||
and not exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem l3
|
||||
where
|
||||
l3.l_orderkey = l1.l_orderkey
|
||||
and l3.l_suppkey <> l1.l_suppkey
|
||||
and l3.l_receiptdate > l3.l_commitdate
|
||||
)
|
||||
and s_nationkey = n_nationkey
|
||||
and n_name = 'SAUDI ARABIA'
|
||||
group by
|
||||
s_name
|
||||
order by
|
||||
numwait desc,
|
||||
s_name
|
||||
limit 100;
|
||||
54
tools/tpch-tools/queries/sf10000/q22.sql
Normal file
54
tools/tpch-tools/queries/sf10000/q22.sql
Normal file
@ -0,0 +1,54 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
cntrycode,
|
||||
count(*) as numcust,
|
||||
sum(c_acctbal) as totacctbal
|
||||
from
|
||||
(
|
||||
select
|
||||
substring(c_phone, 1, 2) as cntrycode,
|
||||
c_acctbal
|
||||
from
|
||||
customer
|
||||
where
|
||||
substring(c_phone, 1, 2) in
|
||||
('13', '31', '23', '29', '30', '18', '17')
|
||||
and c_acctbal > (
|
||||
select
|
||||
avg(c_acctbal)
|
||||
from
|
||||
customer
|
||||
where
|
||||
c_acctbal > 0.00
|
||||
and substring(c_phone, 1, 2) in
|
||||
('13', '31', '23', '29', '30', '18', '17')
|
||||
)
|
||||
and not exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
orders
|
||||
where
|
||||
o_custkey = c_custkey
|
||||
)
|
||||
) as custsale
|
||||
group by
|
||||
cntrycode
|
||||
order by
|
||||
cntrycode;
|
||||
40
tools/tpch-tools/queries/sf10000/q3.sql
Normal file
40
tools/tpch-tools/queries/sf10000/q3.sql
Normal file
@ -0,0 +1,40 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
l_orderkey,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue,
|
||||
o_orderdate,
|
||||
o_shippriority
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem
|
||||
where
|
||||
c_mktsegment = 'BUILDING'
|
||||
and c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and o_orderdate < date '1995-03-15'
|
||||
and l_shipdate > date '1995-03-15'
|
||||
group by
|
||||
l_orderkey,
|
||||
o_orderdate,
|
||||
o_shippriority
|
||||
order by
|
||||
revenue desc,
|
||||
o_orderdate
|
||||
limit 10;
|
||||
38
tools/tpch-tools/queries/sf10000/q4.sql
Normal file
38
tools/tpch-tools/queries/sf10000/q4.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
o_orderpriority,
|
||||
count(*) as order_count
|
||||
from
|
||||
orders
|
||||
where
|
||||
o_orderdate >= date '1993-07-01'
|
||||
and o_orderdate < date '1993-07-01' + interval '3' month
|
||||
and exists (
|
||||
select
|
||||
*
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_orderkey = o_orderkey
|
||||
and l_commitdate < l_receiptdate
|
||||
)
|
||||
group by
|
||||
o_orderpriority
|
||||
order by
|
||||
o_orderpriority;
|
||||
41
tools/tpch-tools/queries/sf10000/q5.sql
Normal file
41
tools/tpch-tools/queries/sf10000/q5.sql
Normal file
@ -0,0 +1,41 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
n_name,
|
||||
sum(l_extendedprice * (1 - l_discount)) as revenue
|
||||
from
|
||||
customer,
|
||||
orders,
|
||||
lineitem,
|
||||
supplier,
|
||||
nation,
|
||||
region
|
||||
where
|
||||
c_custkey = o_custkey
|
||||
and l_orderkey = o_orderkey
|
||||
and l_suppkey = s_suppkey
|
||||
and c_nationkey = s_nationkey
|
||||
and s_nationkey = n_nationkey
|
||||
and n_regionkey = r_regionkey
|
||||
and r_name = 'ASIA'
|
||||
and o_orderdate >= date '1994-01-01'
|
||||
and o_orderdate < date '1994-01-01' + interval '1' year
|
||||
group by
|
||||
n_name
|
||||
order by
|
||||
revenue desc;
|
||||
26
tools/tpch-tools/queries/sf10000/q6.sql
Normal file
26
tools/tpch-tools/queries/sf10000/q6.sql
Normal file
@ -0,0 +1,26 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you 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.
|
||||
|
||||
select
|
||||
sum(l_extendedprice * l_discount) as revenue
|
||||
from
|
||||
lineitem
|
||||
where
|
||||
l_shipdate >= date '1994-01-01'
|
||||
and l_shipdate < date '1994-01-01' + interval '1' year
|
||||
and l_discount between .06 - 0.01 and .06 + 0.01
|
||||
and l_quantity < 24;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user