+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan_type     | plan                                                                                                                                                                                                                                                                                          |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| logical_plan  | Sort: all_nations.o_year ASC NULLS LAST                                                                                                                                                                                                                                                       |
|               |   Projection: all_nations.o_year, SUM(CASE WHEN all_nations.nation = Utf8("BRAZIL") THEN all_nations.volume ELSE Int64(0) END) / SUM(all_nations.volume) AS mkt_share                                                                                                                         |
|               |     Aggregate: groupBy=[[all_nations.o_year]], aggr=[[SUM(CASE WHEN all_nations.nation = Utf8("BRAZIL") THEN all_nations.volume ELSE Decimal128(Some(0),38,4) END) AS SUM(CASE WHEN all_nations.nation = Utf8("BRAZIL") THEN all_nations.volume ELSE Int64(0) END), SUM(all_nations.volume)]] |
|               |       SubqueryAlias: all_nations                                                                                                                                                                                                                                                              |
|               |         Projection: datepart(Utf8("YEAR"), orders.o_orderdate) AS o_year, CAST(lineitem.l_extendedprice AS Decimal128(38, 4)) * CAST(Decimal128(Some(100),23,2) - CAST(lineitem.l_discount AS Decimal128(23, 2)) AS Decimal128(38, 4)) AS volume, n2.n_name AS nation                         |
|               |           Inner Join: n1.n_regionkey = region.r_regionkey                                                                                                                                                                                                                                     |
|               |             Projection: lineitem.l_extendedprice, lineitem.l_discount, orders.o_orderdate, n1.n_regionkey, n2.n_name                                                                                                                                                                          |
|               |               Inner Join: supplier.s_nationkey = n2.n_nationkey                                                                                                                                                                                                                               |
|               |                 Projection: lineitem.l_extendedprice, lineitem.l_discount, supplier.s_nationkey, orders.o_orderdate, n1.n_regionkey                                                                                                                                                           |
|               |                   Inner Join: customer.c_nationkey = n1.n_nationkey                                                                                                                                                                                                                           |
|               |                     Projection: lineitem.l_extendedprice, lineitem.l_discount, supplier.s_nationkey, orders.o_orderdate, customer.c_nationkey                                                                                                                                                 |
|               |                       Inner Join: orders.o_custkey = customer.c_custkey                                                                                                                                                                                                                       |
|               |                         Projection: lineitem.l_extendedprice, lineitem.l_discount, supplier.s_nationkey, orders.o_custkey, orders.o_orderdate                                                                                                                                                 |
|               |                           Inner Join: lineitem.l_orderkey = orders.o_orderkey                                                                                                                                                                                                                 |
|               |                             Projection: lineitem.l_orderkey, lineitem.l_extendedprice, lineitem.l_discount, supplier.s_nationkey                                                                                                                                                              |
|               |                               Inner Join: lineitem.l_suppkey = supplier.s_suppkey                                                                                                                                                                                                             |
|               |                                 Projection: lineitem.l_orderkey, lineitem.l_suppkey, lineitem.l_extendedprice, lineitem.l_discount                                                                                                                                                            |
|               |                                   Inner Join: part.p_partkey = lineitem.l_partkey                                                                                                                                                                                                             |
|               |                                     Projection: part.p_partkey                                                                                                                                                                                                                                |
|               |                                       Filter: part.p_type = Utf8("ECONOMY ANODIZED STEEL")                                                                                                                                                                                                    |
|               |                                         TableScan: part projection=[p_partkey, p_type]                                                                                                                                                                                                        |
|               |                                     TableScan: lineitem projection=[l_orderkey, l_partkey, l_suppkey, l_extendedprice, l_discount]                                                                                                                                                            |
|               |                                 TableScan: supplier projection=[s_suppkey, s_nationkey]                                                                                                                                                                                                       |
|               |                             Filter: orders.o_orderdate >= Date32("9131") AND orders.o_orderdate <= Date32("9861")                                                                                                                                                                             |
|               |                               TableScan: orders projection=[o_orderkey, o_custkey, o_orderdate]                                                                                                                                                                                               |
|               |                         TableScan: customer projection=[c_custkey, c_nationkey]                                                                                                                                                                                                               |
|               |                     SubqueryAlias: n1                                                                                                                                                                                                                                                         |
|               |                       TableScan: nation projection=[n_nationkey, n_regionkey]                                                                                                                                                                                                                 |
|               |                 SubqueryAlias: n2                                                                                                                                                                                                                                                             |
|               |                   TableScan: nation projection=[n_nationkey, n_name]                                                                                                                                                                                                                          |
|               |             Projection: region.r_regionkey                                                                                                                                                                                                                                                    |
|               |               Filter: region.r_name = Utf8("AMERICA")                                                                                                                                                                                                                                         |
|               |                 TableScan: region projection=[r_regionkey, r_name]                                                                                                                                                                                                                            |
| physical_plan | SortPreservingMergeExec: [o_year@0 ASC NULLS LAST]                                                                                                                                                                                                                                            |
|               |   SortExec: expr=[o_year@0 ASC NULLS LAST]                                                                                                                                                                                                                                                    |
|               |     ProjectionExec: expr=[o_year@0 as o_year, SUM(CASE WHEN all_nations.nation = Utf8("BRAZIL") THEN all_nations.volume ELSE Int64(0) END)@1 / SUM(all_nations.volume)@2 as mkt_share]                                                                                                        |
|               |       AggregateExec: mode=FinalPartitioned, gby=[o_year@0 as o_year], aggr=[SUM(CASE WHEN all_nations.nation = Utf8("BRAZIL") THEN all_nations.volume ELSE Int64(0) END), SUM(all_nations.volume)]                                                                                            |
|               |         CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                                           |
|               |           RepartitionExec: partitioning=Hash([Column { name: "o_year", index: 0 }], 2), input_partitions=2                                                                                                                                                                                    |
|               |             AggregateExec: mode=Partial, gby=[o_year@0 as o_year], aggr=[SUM(CASE WHEN all_nations.nation = Utf8("BRAZIL") THEN all_nations.volume ELSE Int64(0) END), SUM(all_nations.volume)]                                                                                               |
|               |               ProjectionExec: expr=[datepart(YEAR, o_orderdate@2) as o_year, CAST(l_extendedprice@0 AS Decimal128(38, 4)) * CAST(Some(100),23,2 - CAST(l_discount@1 AS Decimal128(23, 2)) AS Decimal128(38, 4)) as volume, n_name@4 as nation]                                                |
|               |                 CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                                   |
|               |                   HashJoinExec: mode=Partitioned, join_type=Inner, on=[(Column { name: "n_regionkey", index: 3 }, Column { name: "r_regionkey", index: 0 })]                                                                                                                                  |
|               |                     CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                               |
|               |                       RepartitionExec: partitioning=Hash([Column { name: "n_regionkey", index: 3 }], 2), input_partitions=2                                                                                                                                                                   |
|               |                         ProjectionExec: expr=[l_extendedprice@0 as l_extendedprice, l_discount@1 as l_discount, o_orderdate@3 as o_orderdate, n_regionkey@4 as n_regionkey, n_name@6 as n_name]                                                                                               |
|               |                           CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                         |
|               |                             HashJoinExec: mode=Partitioned, join_type=Inner, on=[(Column { name: "s_nationkey", index: 2 }, Column { name: "n_nationkey", index: 0 })]                                                                                                                        |
|               |                               CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                     |
|               |                                 RepartitionExec: partitioning=Hash([Column { name: "s_nationkey", index: 2 }], 2), input_partitions=2                                                                                                                                                         |
|               |                                   ProjectionExec: expr=[l_extendedprice@0 as l_extendedprice, l_discount@1 as l_discount, s_nationkey@2 as s_nationkey, o_orderdate@3 as o_orderdate, n_regionkey@6 as n_regionkey]                                                                           |
|               |                                     CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                               |
|               |                                       HashJoinExec: mode=Partitioned, join_type=Inner, on=[(Column { name: "c_nationkey", index: 4 }, Column { name: "n_nationkey", index: 0 })]                                                                                                              |
|               |                                         CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                           |
|               |                                           RepartitionExec: partitioning=Hash([Column { name: "c_nationkey", index: 4 }], 2), input_partitions=2                                                                                                                                               |
|               |                                             ProjectionExec: expr=[l_extendedprice@0 as l_extendedprice, l_discount@1 as l_discount, s_nationkey@2 as s_nationkey, o_orderdate@4 as o_orderdate, c_nationkey@6 as c_nationkey]                                                                 |
|               |                                               CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                     |
|               |                                                 HashJoinExec: mode=Partitioned, join_type=Inner, on=[(Column { name: "o_custkey", index: 3 }, Column { name: "c_custkey", index: 0 })]                                                                                                        |
|               |                                                   CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                 |
|               |                                                     RepartitionExec: partitioning=Hash([Column { name: "o_custkey", index: 3 }], 2), input_partitions=2                                                                                                                                       |
|               |                                                       ProjectionExec: expr=[l_extendedprice@1 as l_extendedprice, l_discount@2 as l_discount, s_nationkey@3 as s_nationkey, o_custkey@5 as o_custkey, o_orderdate@6 as o_orderdate]                                                           |
|               |                                                         CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                           |
|               |                                                           HashJoinExec: mode=Partitioned, join_type=Inner, on=[(Column { name: "l_orderkey", index: 0 }, Column { name: "o_orderkey", index: 0 })]                                                                                            |
|               |                                                             CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                       |
|               |                                                               RepartitionExec: partitioning=Hash([Column { name: "l_orderkey", index: 0 }], 2), input_partitions=2                                                                                                                            |
|               |                                                                 ProjectionExec: expr=[l_orderkey@0 as l_orderkey, l_extendedprice@2 as l_extendedprice, l_discount@3 as l_discount, s_nationkey@5 as s_nationkey]                                                                             |
|               |                                                                   CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                 |
|               |                                                                     HashJoinExec: mode=Partitioned, join_type=Inner, on=[(Column { name: "l_suppkey", index: 1 }, Column { name: "s_suppkey", index: 0 })]                                                                                    |
|               |                                                                       CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                             |
|               |                                                                         RepartitionExec: partitioning=Hash([Column { name: "l_suppkey", index: 1 }], 2), input_partitions=2                                                                                                                   |
|               |                                                                           ProjectionExec: expr=[l_orderkey@1 as l_orderkey, l_suppkey@3 as l_suppkey, l_extendedprice@4 as l_extendedprice, l_discount@5 as l_discount]                                                                       |
|               |                                                                             CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                       |
|               |                                                                               HashJoinExec: mode=Partitioned, join_type=Inner, on=[(Column { name: "p_partkey", index: 0 }, Column { name: "l_partkey", index: 1 })]                                                                          |
|               |                                                                                 CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                   |
|               |                                                                                   RepartitionExec: partitioning=Hash([Column { name: "p_partkey", index: 0 }], 2), input_partitions=2                                                                                                         |
|               |                                                                                     RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=0                                                                                                                                      |
|               |                                                                                       ProjectionExec: expr=[p_partkey@0 as p_partkey]                                                                                                                                                         |
|               |                                                                                         CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                           |
|               |                                                                                           FilterExec: p_type@1 = ECONOMY ANODIZED STEEL                                                                                                                                                       |
|               |                                                                                             MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                      |
|               |                                                                                 CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                   |
|               |                                                                                   RepartitionExec: partitioning=Hash([Column { name: "l_partkey", index: 1 }], 2), input_partitions=0                                                                                                         |
|               |                                                                                     MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                              |
|               |                                                                       CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                             |
|               |                                                                         RepartitionExec: partitioning=Hash([Column { name: "s_suppkey", index: 0 }], 2), input_partitions=0                                                                                                                   |
|               |                                                                           MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                                        |
|               |                                                             CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                       |
|               |                                                               RepartitionExec: partitioning=Hash([Column { name: "o_orderkey", index: 0 }], 2), input_partitions=2                                                                                                                            |
|               |                                                                 RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=0                                                                                                                                                          |
|               |                                                                   CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                 |
|               |                                                                     FilterExec: o_orderdate@2 >= 9131 AND o_orderdate@2 <= 9861                                                                                                                                                               |
|               |                                                                       MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                                            |
|               |                                                   CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                 |
|               |                                                     RepartitionExec: partitioning=Hash([Column { name: "c_custkey", index: 0 }], 2), input_partitions=0                                                                                                                                       |
|               |                                                       MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                                                            |
|               |                                         CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                           |
|               |                                           RepartitionExec: partitioning=Hash([Column { name: "n_nationkey", index: 0 }], 2), input_partitions=0                                                                                                                                               |
|               |                                             MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                                                                      |
|               |                               CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                     |
|               |                                 RepartitionExec: partitioning=Hash([Column { name: "n_nationkey", index: 0 }], 2), input_partitions=0                                                                                                                                                         |
|               |                                   MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                                                                                |
|               |                     CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                               |
|               |                       RepartitionExec: partitioning=Hash([Column { name: "r_regionkey", index: 0 }], 2), input_partitions=2                                                                                                                                                                   |
|               |                         RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=0                                                                                                                                                                                                  |
|               |                           ProjectionExec: expr=[r_regionkey@0 as r_regionkey]                                                                                                                                                                                                                 |
|               |                             CoalesceBatchesExec: target_batch_size=8192                                                                                                                                                                                                                       |
|               |                               FilterExec: r_name@1 = AMERICA                                                                                                                                                                                                                                  |
|               |                                 MemoryExec: partitions=0, partition_sizes=[]                                                                                                                                                                                                                  |
|               |                                                                                                                                                                                                                                                                                               |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+