From abc27fdee7ec7db848702b291abf249caee46fe7 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Thu, 2 May 2024 17:06:42 +0530 Subject: [PATCH] test: add all the tpch and derived table queries to e2e test Signed-off-by: Manan Gupta --- .../endtoend/vtgate/queries/tpch/tpch_test.go | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/go/test/endtoend/vtgate/queries/tpch/tpch_test.go b/go/test/endtoend/vtgate/queries/tpch/tpch_test.go index 255b961e15b..230047ae0c9 100644 --- a/go/test/endtoend/vtgate/queries/tpch/tpch_test.go +++ b/go/test/endtoend/vtgate/queries/tpch/tpch_test.go @@ -196,6 +196,82 @@ where l_partkey = p_partkey and l_shipdate >= '1996-12-01' and l_shipdate < date_add('1996-12-01', interval '1' month);`, }, + { + name: "Q7", + query: `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`, + }, + { + name: "Q8", + query: `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`, + }, + { + name: "Q9", + query: `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`, + }, + { + name: "simple derived table", + query: `select * +from (select l.l_extendedprice * o.o_totalprice + from lineitem l + join orders o) as dt`, + }, } for _, testcase := range testcases {