alamb commented on code in PR #14271:
URL: https://github.com/apache/datafusion/pull/14271#discussion_r1934473333


##########
datafusion/core/tests/physical_optimizer/enforce_sorting.rs:
##########
@@ -238,6 +241,338 @@ async fn test_remove_unnecessary_sort5() -> Result<()> {
     Ok(())
 }
 
+#[test]
+fn test_aggregate_set_monotonic_no_group() -> Result<()> {
+    let schema = create_test_schema4()?;
+
+    let source = memory_exec(&schema);
+
+    let sort_exprs = vec![sort_expr("a", &schema)];
+    let sort = sort_exec(sort_exprs.clone(), source);
+
+    let aggregate = aggregate_exec_set_monotonic(sort, vec![]);
+
+    let sort_exprs = LexOrdering::new(vec![sort_expr("count", 
&aggregate.schema())]);
+    let physical_plan: Arc<dyn ExecutionPlan> =
+        Arc::new(SortExec::new(sort_exprs.clone(), aggregate)) as _;
+
+    let expected_input = [
+        "SortExec: expr=[count@0 ASC], preserve_partitioning=[false]",
+        "  AggregateExec: mode=Single, gby=[], aggr=[count]",
+        "    SortExec: expr=[a@0 ASC], preserve_partitioning=[false]",
+        "      MemoryExec: partitions=1, partition_sizes=[0]",
+    ];
+
+    let expected_optimized = [
+        "AggregateExec: mode=Single, gby=[], aggr=[count]",

Review Comment:
   When there are no `group by` expressions, I think the output is always 
sorted (as there is a single row output). I don't think the aggregate matters



-- 
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]

Reply via email to