xudong963 commented on code in PR #14569: URL: https://github.com/apache/datafusion/pull/14569#discussion_r1948961642
########## datafusion/core/tests/physical_optimizer/enforce_sorting.rs: ########## @@ -1943,6 +1943,30 @@ async fn test_remove_unnecessary_spm1() -> Result<()> { Ok(()) } +#[tokio::test] +async fn test_remove_unnecessary_spm2() -> Result<()> { + let schema = create_test_schema()?; + let source = memory_exec(&schema); + let input = sort_preserving_merge_exec_with_fetch( + vec![sort_expr("non_nullable_col", &schema)], + source, + 100, + ); + + let expected_input = [ + "SortPreservingMergeExec: [non_nullable_col@1 ASC], fetch=100", + " DataSourceExec: partitions=1, partition_sizes=[0]", + ]; + let expected_optimized = [ + "LocalLimitExec: fetch=100", + " SortExec: expr=[non_nullable_col@1 ASC], preserve_partitioning=[false]", Review Comment: we should optimize such pattern to topk later -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org