zhangfengcdt opened a new pull request, #7762:
URL: https://github.com/apache/datafusion-comet/pull/7762

   ## Which issue does this PR close?
   
   Closes #7689.
   
   **Stacked on #7316.** Until that merges, this diff also shows its commits. 
The changes here are the last two commits: `b84315957` (join filter and Expand) 
and `0ba605423` (full sort).
   
   ## Rationale for this change
   
   #7316 bounds the batch under the operators that expand a large string or 
binary scalar. #7689 lists the ones it left out. Each case below failed with 
`byte array offset overflow`.
   
   ## What changes are included in this PR?
   
   - **Join filter.** A join evaluates its filter on the row pairs it matched, 
up to a batch size of them at a time, and one input row can match many. So a 
split under the join cannot bound it. A new `CometBatchSizeScopeExec` runs a 
hash, sort-merge or nested loop join with the session batch size lowered to the 
scalar's cap. It is added only when the join's filter expands such a scalar. It 
also lowers the batch size of the operators below the join, and it reports the 
join's metrics as its own.
   - **Expand.** Expand evaluates its projections over its input batch, so its 
input gets the same split as a projection's.
   - **Full sort.** Bounding the keys fixes the overflow, but DataFusion's sort 
computes every row's key when it merges its sorted runs and holds all of them: 
2 GiB for a 256 KiB literal over 8192 rows, however the input is split. Spark's 
sort compares keys row by row. So a full sort whose keys expand a string or 
binary literal past the 1 GiB bound at the session batch size now falls back to 
Spark. A scalar subquery's result is not known at planning, so it is not 
covered. A sort with a limit stays native and is bounded by #7316.
   - **Window partition and order expressions.** No change. Spark's 
`ExtractWindowExpressions` moves them into a projection below the window, which 
#7316 already bounds.
   
   ## How are these changes tested?
   
   - New fixture `operators/large_scalar_string_join_expand.sql`: a sort-merge, 
a shuffled hash and a broadcast nested loop join whose filter expands a 256 KiB 
literal over 8192 matched pairs, a distinct aggregate whose Expand expands it, 
and a full sort on a key that expands it. Each failed with the offset overflow 
before this change. The joins and Expand run natively and match Spark. The sort 
falls back with its reason and matches Spark.
   - Rust unit tests: `CometBatchSizeScopeExec` runs its input at the scoped 
batch size and leaves the caller's context alone; the planner scopes a join 
whose filter expands a large scalar, and not one with a small scalar or no 
filter.
   - `CometJoinSuite` and `CometAggregateSuite` pass.
   


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