goingforstudying-ctrl opened a new pull request, #2978:
URL: https://github.com/apache/datafusion-ballista/pull/2978

   Ran into #2961 while looking at the planner. On a standalone cluster,
   
   ```sql
   SELECT a FROM (VALUES (0), (1), (2), (3), (4), (5)) AS v(a) LIMIT 2
   ```
   
   returns all six rows, under both the static and the adaptive planner. The 
optimized plan is just
   
   ```
   ProjectionExec
     DataSourceExec: partitions=1, partition_sizes=[1], fetch=2
   ```
   
   so the optimizer absorbs the whole LIMIT into the scan's own `fetch` and no 
limit operator survives in the plan. When the scheduler restricts the scan to a 
task's partitions, `task_builder` rebuilds the `MemorySourceConfig` with 
`try_new`, which resets `fetch` (and `show_sizes` and the sort orderings). The 
executor then runs a fetch-less scan and every row comes back.
   
   The rebuild now carries `fetch` and `show_sizes` over, and re-applies the 
sort orderings when the scan has no projection. When there is one, the stored 
orderings are already projected, and `try_with_sort_information` would map them 
through the projection a second time, so those stay as they were. Slightly 
awkward corner of the API, might be a cleaner way to say that.
   
   Verification: a unit test on the restriction and an end-to-end test running 
the query from the issue on a standalone cluster under both planners. On main 
the e2e test fails with 6 rows where 2 are expected; with the patch it passes, 
and the existing task_builder suite still passes (26 tests).
   
   ```
   cargo test -p ballista-scheduler --lib state::task_builder
   cargo test -p ballista --test limit_memory_scan
   ```
   


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