robtandy opened a new issue, #13860: URL: https://github.com/apache/datafusion/issues/13860
### Describe the bug Substrait round trip fails for a query that produces a logical plan where the Sort node includes a fetch. As an example, ``` Sort: data.b ASC NULLS LAST, fetch=2 Filter: data.a > Int64(1) TableScan: data projection=[a, b, c, d, e, f], partial_filters=[data.a > Int64(1)] ``` Upon returning from the round trip produces ``` Sort: data.b ASC NULLS LAST Filter: data.a > Int64(1) TableScan: data projection=[a, b, c, d, e, f], partial_filters=[data.a > Int64(1)] ``` the fetch is lost. I'm happy to take and fix this issue, but I wasn't sure where the fix should be made. Should this fix the Sort Rel in substrait that cannot hold a `fetch` member? Or should this be a fix in the substrait producer to produce a plan with a Limit and a Sort? ### To Reproduce Add a test to `datafusion/substrait/tests/cases/round_trip_logical_plan.rs` such as ```rust #[tokio::test] async fn select_with_filter_sort_limit() -> Result<()> { roundtrip("SELECT * FROM data WHERE a > 1 ORDER BY b ASC LIMIT 2").await } ``` in this repo, run ```shell cd datafusion/substrait cargo test -- --nocapture select_with_filter_sort_limit ``` ### Expected behavior A round trip for this plan should work. ### Additional context _No response_ -- 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.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