vegarsti commented on code in PR #16985: URL: https://github.com/apache/datafusion/pull/16985#discussion_r2441583246
########## datafusion/sqllogictest/test_files/unnest.slt: ########## @@ -941,3 +941,242 @@ where min_height * width1 = ( ) ---- 4 7 4 28 + +## Unnest with ordering on unrelated column is preserved +query TT +EXPLAIN WITH unnested AS (SELECT + ROW_NUMBER() OVER () AS generated_id, + unnest(array[value]) as ar + FROM range(1,5)) SELECT array_agg(ar) FROM unnested group by generated_id; +---- +logical_plan +01)Projection: array_agg(unnested.ar) +02)--Aggregate: groupBy=[[unnested.generated_id]], aggr=[[array_agg(unnested.ar)]] +03)----SubqueryAlias: unnested +04)------Projection: generated_id, __unnest_placeholder(make_array(range().value),depth=1) AS UNNEST(make_array(range().value)) AS ar +05)--------Unnest: lists[__unnest_placeholder(make_array(range().value))|depth=1] structs[] +06)----------Projection: row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS generated_id, make_array(range().value) AS __unnest_placeholder(make_array(range().value)) +07)------------WindowAggr: windowExpr=[[row_number() ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]] +08)--------------TableScan: range() projection=[value] +physical_plan +01)ProjectionExec: expr=[array_agg(unnested.ar)@1 as array_agg(unnested.ar)] +02)--AggregateExec: mode=FinalPartitioned, gby=[generated_id@0 as generated_id], aggr=[array_agg(unnested.ar)], ordering_mode=Sorted +03)----SortExec: expr=[generated_id@0 ASC NULLS LAST], preserve_partitioning=[true] Review Comment: Hm, this test is from your comment here https://github.com/apache/datafusion/issues/15231#issuecomment-2726553122 By "the comment" here do you mean "Unnest with ordering on unrelated column is preserved"? The point of the test is to show that we don't lose the inherent ordering of `generated_id` (through `row_number()`) when we do unnest, so if we look at `11) BoundedWindowAggExec`, we see `mode=[Sorted]` and then we also see `ordering_mode=Sorted` at `06) AggregateExec`, and at `02) AggregateExec`. I will include this in the comment. -- 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]
