Dandandan commented on issue #15734: URL: https://github.com/apache/datafusion/issues/15734#issuecomment-2865642345
@UBarney good find. It looks like the group by is removed in
`eliminate_group_by_constant` :
<details>
```
> set datafusion.explain.format = "indent";
0 row(s) fetched.
Elapsed 0.001 seconds.
> explain verbose select 'wat' as key, count(1) as count from (select * from
unnest(array[]::text[])) as b(field) group by key;
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan_type | plan
|
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| initial_logical_plan | Projection:
Utf8("wat") AS key, count(Int64(1)) AS count
|
| | Aggregate:
groupBy=[[Utf8("wat")]], aggr=[[count(Int64(1))]]
|
| |
SubqueryAlias: b
|
| |
Projection: UNNEST(make_array()) AS field
|
| |
Projection: UNNEST(make_array())
|
| |
Projection: __unnest_placeholder(make_array(),depth=1) AS UNNEST(make_array())
|
| |
Unnest: lists[__unnest_placeholder(make_array())|depth=1] structs[]
|
| |
Projection: CAST(make_array() AS List(Field { name: "item", data_type: Utf8,
nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })) AS
__unnest_placeholder(make_array()) |
| |
EmptyRelation
|
| logical_plan after resolve_grouping_function | SAME TEXT AS
ABOVE
|
| logical_plan after type_coercion | SAME TEXT AS
ABOVE
|
| analyzed_logical_plan | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_nested_union | SAME TEXT AS
ABOVE
|
| logical_plan after simplify_expressions | Projection:
Utf8("wat") AS key, count(Int64(1)) AS count
|
| | Aggregate:
groupBy=[[Utf8("wat")]], aggr=[[count(Int64(1))]]
|
| |
SubqueryAlias: b
|
| |
Projection: UNNEST(make_array()) AS field
|
| |
Projection: UNNEST(make_array())
|
| |
Projection: __unnest_placeholder(make_array(),depth=1) AS UNNEST(make_array())
|
| |
Unnest: lists[__unnest_placeholder(make_array())|depth=1] structs[]
|
| |
Projection: List([]) AS __unnest_placeholder(make_array())
|
| |
EmptyRelation
|
| logical_plan after replace_distinct_aggregate | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_join | SAME TEXT AS
ABOVE
|
| logical_plan after decorrelate_predicate_subquery | SAME TEXT AS
ABOVE
|
| logical_plan after scalar_subquery_to_join | SAME TEXT AS
ABOVE
|
| logical_plan after extract_equijoin_predicate | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_duplicated_expr | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_filter | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_cross_join | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_limit | SAME TEXT AS
ABOVE
|
| logical_plan after propagate_empty_relation | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_one_union | SAME TEXT AS
ABOVE
|
| logical_plan after filter_null_join_keys | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_outer_join | SAME TEXT AS
ABOVE
|
| logical_plan after push_down_limit | SAME TEXT AS
ABOVE
|
| logical_plan after push_down_filter | SAME TEXT AS
ABOVE
|
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_group_by_constant | Projection:
Utf8("wat") AS key, count(Int64(1)) AS count
|
| | Projection:
Utf8("wat"), count(Int64(1))
|
| |
Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]]
|
| |
SubqueryAlias: b
|
| |
Projection: UNNEST(make_array()) AS field
|
| |
Projection: UNNEST(make_array())
|
| |
Projection: __unnest_placeholder(make_array(),depth=1) AS UNNEST(make_array())
|
| |
Unnest: lists[__unnest_placeholder(make_array())|depth=1] structs[]
|
| |
Projection: List([]) AS __unnest_placeholder(make_array())
|
| |
EmptyRelation
|
| logical_plan after optimize_projections | Projection:
Utf8("wat") AS key, count(Int64(1)) AS count
|
| | Aggregate:
groupBy=[[]], aggr=[[count(Int64(1))]]
|
| |
SubqueryAlias: b
|
| |
Projection:
|
| |
Unnest: lists[__unnest_placeholder(make_array())|depth=1] structs[]
|
| |
Projection: List([]) AS __unnest_placeholder(make_array())
|
| |
EmptyRelation
|
| logical_plan after eliminate_nested_union | SAME TEXT AS
ABOVE
|
| logical_plan after simplify_expressions | SAME TEXT AS
ABOVE
|
| logical_plan after replace_distinct_aggregate | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_join | SAME TEXT AS
ABOVE
|
| logical_plan after decorrelate_predicate_subquery | SAME TEXT AS
ABOVE
|
| logical_plan after scalar_subquery_to_join | SAME TEXT AS
ABOVE
|
| logical_plan after extract_equijoin_predicate | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_duplicated_expr | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_filter | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_cross_join | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_limit | SAME TEXT AS
ABOVE
|
| logical_plan after propagate_empty_relation | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_one_union | SAME TEXT AS
ABOVE
|
| logical_plan after filter_null_join_keys | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_outer_join | SAME TEXT AS
ABOVE
|
| logical_plan after push_down_limit | SAME TEXT AS
ABOVE
|
| logical_plan after push_down_filter | SAME TEXT AS
ABOVE
|
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS
ABOVE
|
| logical_plan after eliminate_group_by_constant | SAME TEXT AS
ABOVE
|
| logical_plan after optimize_projections | SAME TEXT AS
ABOVE
|
| logical_plan | Projection:
Utf8("wat") AS key, count(Int64(1)) AS count
|
| | Aggregate:
groupBy=[[]], aggr=[[count(Int64(1))]]
|
| |
SubqueryAlias: b
|
| |
Projection:
|
| |
Unnest: lists[__unnest_placeholder(make_array())|depth=1] structs[]
|
| |
Projection: List([]) AS __unnest_placeholder(make_array())
|
| |
EmptyRelation
|
| initial_physical_plan |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))]
|
| |
ProjectionExec: expr=[]
|
| |
UnnestExec
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())]
|
| |
PlaceholderRowExec
|
| |
|
| initial_physical_plan_with_stats |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count],
statistics=[Rows=Exact(1), Bytes=Absent, [(Col[0]:),(Col[1]:)]]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))],
statistics=[Rows=Exact(1), Bytes=Absent, [(Col[0]:)]]
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))],
statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:)]]
|
| |
ProjectionExec: expr=[], statistics=[Rows=Absent, Bytes=Absent, []]
|
| |
UnnestExec, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:)]]
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())],
statistics=[Rows=Exact(1), Bytes=Exact(0), [(Col[0]:)]]
|
| |
PlaceholderRowExec, statistics=[Rows=Exact(1), Bytes=Exact(0), []]
|
| |
|
| initial_physical_plan_with_schema |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count],
schema=[key:Utf8, count:Int64]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))],
schema=[count(Int64(1)):Int64]
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))],
schema=[count(Int64(1))[count]:Int64]
|
| |
ProjectionExec: expr=[], schema=[]
|
| |
UnnestExec, schema=[__unnest_placeholder(make_array(),depth=1):Utf8;N]
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())],
schema=[__unnest_placeholder(make_array()):List(Field { name: "item",
data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} })] |
| |
PlaceholderRowExec, schema=[]
|
| |
|
| physical_plan after OutputRequirements |
OutputRequirementExec
|
| |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))]
|
| |
ProjectionExec: expr=[]
|
| |
UnnestExec
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())]
|
| |
PlaceholderRowExec
|
| |
|
| physical_plan after aggregate_statistics | SAME TEXT AS
ABOVE
|
| physical_plan after join_selection | SAME TEXT AS
ABOVE
|
| physical_plan after LimitedDistinctAggregation | SAME TEXT AS
ABOVE
|
| physical_plan after EnforceDistribution |
OutputRequirementExec
|
| |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
|
| |
CoalescePartitionsExec
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))]
|
| |
RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1
|
| |
ProjectionExec: expr=[]
|
| |
UnnestExec
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())]
|
| |
PlaceholderRowExec
|
| |
|
| physical_plan after CombinePartialFinalAggregate | SAME TEXT AS
ABOVE
|
| physical_plan after EnforceSorting | SAME TEXT AS
ABOVE
|
| physical_plan after OptimizeAggregateOrder | SAME TEXT AS
ABOVE
|
| physical_plan after ProjectionPushdown | SAME TEXT AS
ABOVE
|
| physical_plan after coalesce_batches | SAME TEXT AS
ABOVE
|
| physical_plan after OutputRequirements |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
|
| |
CoalescePartitionsExec
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))]
|
| |
RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1
|
| |
ProjectionExec: expr=[]
|
| |
UnnestExec
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())]
|
| |
PlaceholderRowExec
|
| |
|
| physical_plan after LimitAggregation | SAME TEXT AS
ABOVE
|
| physical_plan after LimitPushdown | SAME TEXT AS
ABOVE
|
| physical_plan after ProjectionPushdown | SAME TEXT AS
ABOVE
|
| physical_plan after SanityCheckPlan | SAME TEXT AS
ABOVE
|
| physical_plan |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
|
| |
CoalescePartitionsExec
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))]
|
| |
RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1
|
| |
ProjectionExec: expr=[]
|
| |
UnnestExec
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())]
|
| |
PlaceholderRowExec
|
| |
|
| physical_plan_with_stats |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count],
statistics=[Rows=Exact(1), Bytes=Absent, [(Col[0]:),(Col[1]:)]]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))],
statistics=[Rows=Exact(1), Bytes=Absent, [(Col[0]:)]]
|
| |
CoalescePartitionsExec, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:)]]
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))],
statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:)]]
|
| |
RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1,
statistics=[Rows=Absent, Bytes=Absent, []]
|
| |
ProjectionExec: expr=[], statistics=[Rows=Absent, Bytes=Absent, []]
|
| |
UnnestExec, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:)]]
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())],
statistics=[Rows=Exact(1), Bytes=Exact(0), [(Col[0]:)]]
|
| |
PlaceholderRowExec, statistics=[Rows=Exact(1), Bytes=Exact(0), []]
|
| |
|
| physical_plan_with_schema |
ProjectionExec: expr=[wat as key, count(Int64(1))@0 as count],
schema=[key:Utf8, count:Int64]
|
| |
AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))],
schema=[count(Int64(1)):Int64]
|
| |
CoalescePartitionsExec, schema=[count(Int64(1))[count]:Int64]
|
| |
AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))],
schema=[count(Int64(1))[count]:Int64]
|
| |
RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1,
schema=[]
|
| |
ProjectionExec: expr=[], schema=[]
|
| |
UnnestExec, schema=[__unnest_placeholder(make_array(),depth=1):Utf8;N]
|
| |
ProjectionExec: expr=[[] as __unnest_placeholder(make_array())],
schema=[__unnest_placeholder(make_array()):List(Field { name: "item",
data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata:
{} })] |
| |
PlaceholderRowExec, schema=[]
|
| |
|
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
66 row(s) fetched.
Elapsed 0.006 seconds.
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
