@@ -856,3 +856,89 @@ PhysicalSort
856
856
└── PhysicalScan { table: nation }
857
857
*/
858
858
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
+
0 commit comments