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

   ## Which issue does this PR close?
   
   Draft backport of #7721 to `branch-1.2`, part of #6834. [Backport 
request](https://github.com/apache/datafusion-comet/pull/7721#pullrequestreview-6067560295)
   
   - [ ] After #7721 merges, replace the provisional commit with `git 
cherry-pick -x` of its squash commit on `main` and verify release CI before 
marking this PR ready. [Backport 
guide](https://github.com/apache/datafusion-comet/blob/f67d51d24aa9cac69a428df2a7b6655e4b042456/docs/source/contributor-guide/backporting.md#L95-L110)
   
   ## Rationale for this change
   
   Comet 1.2.0 can drop matching rows when a query filters cached strings with 
`startswith(s, CAST(X'C3' AS STRING))`. The row predicate matches `é` because 
its UTF-8 bytes begin with `C3`. Spark's batch filter takes one character from 
the lower bound. If that character is `é`, its bytes `C3 A9` sort after `C3`, 
so the scan skips the batch before evaluating the row predicate. [Released 
serializer](https://github.com/apache/datafusion-comet/blob/ab46419fcc99bcd34aa4d89f7b545d5d51694a88/spark/src/main/scala/org/apache/spark/sql/comet/execution/arrow/ArrowCachedBatchSerializer.scala#L465-L491)
   
   ## What changes are included in this PR?
   
   For a malformed prefix literal under the default binary collation, use its 
byte range when pruning cached batches. For `C3`, the range is `[C3, C4)`. 
Spark can prune on both bounds inside a compound predicate and apply the 
original `startswith` to the surviving rows.
   
   The serializer and regression tests apply directly to `branch-1.2`, the 
newest release branch. The two-file patch matches #7721 at `f008989`. The older 
`branch-1.1` also has the affected code and would need a separate backport if 
maintainers choose to include it in that release line. [1.1 
serializer](https://github.com/apache/datafusion-comet/blob/17700f1dcd9d3b6e65dfcd5256020eccfa5e1767/spark/src/main/scala/org/apache/spark/sql/comet/execution/arrow/ArrowCachedBatchSerializer.scala#L461-L487)
   
   ## How are these changes tested?
   
   `CometInMemoryCachePruningSuite` compares the IDs returned by `startswith(s, 
CAST(X'C3' AS STRING)) OR id = 0` with uncached Spark and checks that the scan 
reads exactly two of sixteen batches across native Arrow, Spark columnar, and 
row inputs. A second SQL test covers a prefix ending in `FF FF` and a prefix 
consisting entirely of `FF` bytes.
   
   `git diff --check` passed against `branch-1.2` at `8afafe4`. The source and 
backport have the same stable patch ID. Hosted release CI will validate the 
patch on this branch.
   


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