Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit ad37149

Browse files
authored
test: add planner test for working tpch query (Q18) (#76)
1 parent cb3e3a7 commit ad37149

File tree

2 files changed

+116
-1
lines changed

2 files changed

+116
-1
lines changed

optd-sqlplannertest/tests/tpch.planner.sql

+86
Original file line numberDiff line numberDiff line change
@@ -856,3 +856,89 @@ PhysicalSort
856856
└── PhysicalScan { table: nation }
857857
*/
858858

859+
-- TPC-H Q18
860+
SELECT
861+
c_name,
862+
c_custkey,
863+
o_orderkey,
864+
o_orderdate,
865+
o_totalprice,
866+
sum(l_quantity) as total_quantity
867+
FROM
868+
customer,
869+
orders,
870+
lineitem
871+
WHERE
872+
c_custkey = o_custkey
873+
AND o_orderkey = l_orderkey
874+
GROUP BY
875+
c_name,
876+
c_custkey,
877+
o_orderkey,
878+
o_orderdate,
879+
o_totalprice
880+
HAVING
881+
sum(l_quantity) > 300
882+
ORDER BY
883+
o_totalprice DESC,
884+
o_orderdate;
885+
886+
/*
887+
LogicalSort
888+
├── exprs:
889+
│ ┌── SortOrder { order: Desc }
890+
│ │ └── #4
891+
│ └── SortOrder { order: Asc }
892+
│ └── #3
893+
└── LogicalProjection { exprs: [ #0, #1, #2, #3, #4, #5 ] }
894+
└── LogicalFilter
895+
├── cond:Gt
896+
│ ├── #5
897+
│ └── Cast { cast_to: Decimal128(25, 2), expr: 300 }
898+
└── LogicalAgg
899+
├── exprs:Agg(Sum)
900+
│ └── [ #21 ]
901+
├── groups: [ #1, #0, #8, #12, #11 ]
902+
└── LogicalFilter
903+
├── cond:And
904+
│ ├── Eq
905+
│ │ ├── #0
906+
│ │ └── #9
907+
│ └── Eq
908+
│ ├── #8
909+
│ └── #17
910+
└── LogicalJoin { join_type: Cross, cond: true }
911+
├── LogicalJoin { join_type: Cross, cond: true }
912+
│ ├── LogicalScan { table: customer }
913+
│ └── LogicalScan { table: orders }
914+
└── LogicalScan { table: lineitem }
915+
PhysicalSort
916+
├── exprs:
917+
│ ┌── SortOrder { order: Desc }
918+
│ │ └── #4
919+
│ └── SortOrder { order: Asc }
920+
│ └── #3
921+
└── PhysicalProjection { exprs: [ #0, #1, #2, #3, #4, #5 ] }
922+
└── PhysicalFilter
923+
├── cond:Gt
924+
│ ├── #5
925+
│ └── Cast { cast_to: Decimal128(25, 2), expr: 300 }
926+
└── PhysicalAgg
927+
├── aggrs:Agg(Sum)
928+
│ └── [ #21 ]
929+
├── groups: [ #1, #0, #8, #12, #11 ]
930+
└── PhysicalFilter
931+
├── cond:And
932+
│ ├── Eq
933+
│ │ ├── #0
934+
│ │ └── #9
935+
│ └── Eq
936+
│ ├── #8
937+
│ └── #17
938+
└── PhysicalNestedLoopJoin { join_type: Cross, cond: true }
939+
├── PhysicalNestedLoopJoin { join_type: Cross, cond: true }
940+
│ ├── PhysicalScan { table: customer }
941+
│ └── PhysicalScan { table: orders }
942+
└── PhysicalScan { table: lineitem }
943+
*/
944+

optd-sqlplannertest/tests/tpch.yml

+30-1
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,33 @@
246246
o_year DESC;
247247
desc: TPC-H Q9
248248
tasks:
249-
- explain:logical_optd,physical_optd
249+
- explain:logical_optd,physical_optd
250+
- sql: |
251+
SELECT
252+
c_name,
253+
c_custkey,
254+
o_orderkey,
255+
o_orderdate,
256+
o_totalprice,
257+
sum(l_quantity) as total_quantity
258+
FROM
259+
customer,
260+
orders,
261+
lineitem
262+
WHERE
263+
c_custkey = o_custkey
264+
AND o_orderkey = l_orderkey
265+
GROUP BY
266+
c_name,
267+
c_custkey,
268+
o_orderkey,
269+
o_orderdate,
270+
o_totalprice
271+
HAVING
272+
sum(l_quantity) > 300
273+
ORDER BY
274+
o_totalprice DESC,
275+
o_orderdate;
276+
desc: TPC-H Q18
277+
tasks:
278+
- explain:logical_optd,physical_optd

0 commit comments

Comments
 (0)