adriangb commented on PR #18817:
URL: https://github.com/apache/datafusion/pull/18817#issuecomment-3569088218

   I haven't looked into all of this discussion and code (I just got tagged). 
I've been looking into optimizing sorted scanning in DataFusion and IMO where 
we should land is:
   1. Via metadata (`FileScanConfig` / `ORDERED BY ...` in SQL) users declare a 
known sort order of their files.
   2. The planner uses statistics from the files + any `ORDER BY` clauses in 
the query to arrange file ordering to best match the query. The `FileSource` 
implementation can also receive the `ORDER BY` information and optimize scan 
order within a file (e.g. reversing the order of reads which is what I think 
this PR is doing).
   3. If the planner is able to deduce from file level stats that the files can 
be ordered and the `FileSource` reports that it is able to produce batches in 
sorted order then the optimizer can optimize away the sort completely.
   
   I hope that is helpful.


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